kaggle-environments 1.16.9__py2.py3-none-any.whl → 1.16.10__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kaggle-environments might be problematic. Click here for more details.

Files changed (60) hide show
  1. kaggle_environments/__init__.py +1 -1
  2. kaggle_environments/agent.py +1 -1
  3. kaggle_environments/envs/chess/chess.js +8 -3
  4. kaggle_environments/envs/chess/chess.json +7 -2
  5. kaggle_environments/envs/chess/chess.py +12 -5
  6. kaggle_environments/envs/connectx/connectx.ipynb +3183 -0
  7. kaggle_environments/envs/connectx/connectx.py +1 -1
  8. kaggle_environments/envs/football/football.ipynb +75 -0
  9. kaggle_environments/envs/halite/halite.ipynb +44736 -0
  10. kaggle_environments/envs/halite/halite.py +1 -1
  11. kaggle_environments/envs/hungry_geese/hungry_geese.py +1 -1
  12. kaggle_environments/envs/kore_fleets/kore_fleets.ipynb +112 -0
  13. kaggle_environments/envs/kore_fleets/kore_fleets.py +1 -1
  14. kaggle_environments/envs/kore_fleets/starter_bots/java/Bot.java +54 -0
  15. kaggle_environments/envs/kore_fleets/starter_bots/java/README.md +26 -0
  16. kaggle_environments/envs/kore_fleets/starter_bots/java/jars/hamcrest-core-1.3.jar +0 -0
  17. kaggle_environments/envs/kore_fleets/starter_bots/java/jars/junit-4.13.2.jar +0 -0
  18. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Board.java +518 -0
  19. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Cell.java +61 -0
  20. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Configuration.java +24 -0
  21. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Direction.java +166 -0
  22. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Fleet.java +72 -0
  23. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/KoreJson.java +97 -0
  24. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Observation.java +72 -0
  25. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Pair.java +13 -0
  26. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Player.java +68 -0
  27. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Point.java +65 -0
  28. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Shipyard.java +70 -0
  29. kaggle_environments/envs/kore_fleets/starter_bots/java/kore/ShipyardAction.java +59 -0
  30. kaggle_environments/envs/kore_fleets/starter_bots/java/test/BoardTest.java +567 -0
  31. kaggle_environments/envs/kore_fleets/starter_bots/java/test/ConfigurationTest.java +25 -0
  32. kaggle_environments/envs/kore_fleets/starter_bots/java/test/KoreJsonTest.java +62 -0
  33. kaggle_environments/envs/kore_fleets/starter_bots/java/test/ObservationTest.java +46 -0
  34. kaggle_environments/envs/kore_fleets/starter_bots/java/test/PointTest.java +21 -0
  35. kaggle_environments/envs/kore_fleets/starter_bots/java/test/ShipyardTest.java +22 -0
  36. kaggle_environments/envs/kore_fleets/starter_bots/ts/README.md +55 -0
  37. kaggle_environments/envs/llm_20_questions/llm_20_questions.py +1 -1
  38. kaggle_environments/envs/lux_ai_2021/README.md +3 -0
  39. kaggle_environments/envs/lux_ai_2021/dimensions/754.js.LICENSE.txt +296 -0
  40. kaggle_environments/envs/lux_ai_2021/test_agents/js_simple/simple.tar.gz +0 -0
  41. kaggle_environments/envs/lux_ai_2021/testing.md +23 -0
  42. kaggle_environments/envs/lux_ai_2021/todo.md.og +18 -0
  43. kaggle_environments/envs/lux_ai_s2/.gitignore +1 -0
  44. kaggle_environments/envs/lux_ai_s2/README.md +21 -0
  45. kaggle_environments/envs/lux_ai_s2/luxai_s2/.DS_Store +0 -0
  46. kaggle_environments/envs/lux_ai_s2/luxai_s2/map_generator/.DS_Store +0 -0
  47. kaggle_environments/envs/lux_ai_s3/README.md +21 -0
  48. kaggle_environments/envs/lux_ai_s3/lux_ai_s3.json +1 -1
  49. kaggle_environments/envs/lux_ai_s3/luxai_s3/env.py +15 -8
  50. kaggle_environments/envs/lux_ai_s3/luxai_s3/pygame_render.py +6 -29
  51. kaggle_environments/envs/lux_ai_s3/luxai_s3/wrappers.py +0 -17
  52. kaggle_environments/envs/tictactoe/tictactoe.ipynb +1393 -0
  53. kaggle_environments/envs/tictactoe/tictactoe.py +1 -1
  54. kaggle_environments/helpers.py +3 -3
  55. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/METADATA +2 -2
  56. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/RECORD +60 -22
  57. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/WHEEL +1 -1
  58. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/LICENSE +0 -0
  59. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/entry_points.txt +0 -0
  60. {kaggle_environments-1.16.9.dist-info → kaggle_environments-1.16.10.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ package test;
2
+
3
+ import org.junit.Assert;
4
+ import org.junit.Test;
5
+
6
+ import kore.Point;
7
+
8
+ public class PointTest {
9
+
10
+ @Test
11
+ public void fromIndexToIndex_isIdentity() {
12
+ int idx = 254;
13
+ int size = 31;
14
+
15
+ Point point = Point.fromIndex(idx, size);
16
+ int mirroredIdx = point.toIndex(size);
17
+
18
+ Assert.assertEquals(idx, mirroredIdx);
19
+ }
20
+
21
+ }
@@ -0,0 +1,22 @@
1
+ package test;
2
+
3
+ import org.junit.Assert;
4
+ import org.junit.Test;
5
+
6
+ import kore.Point;
7
+ import kore.Shipyard;
8
+
9
+ public class ShipyardTest {
10
+
11
+ @Test
12
+ public void maxSpawn_worksCorrectly() {
13
+ int[] turns = {0, 1, 2, 293, 294, 295};
14
+ int[] expected = {1, 1, 2, 9, 10, 10};
15
+ for (int i = 0; i < turns.length; i ++) {
16
+ Shipyard shipyard = new Shipyard("A", 0, new Point(0, 0), 1, turns[i], null, null);
17
+
18
+ Assert.assertEquals(shipyard.maxSpawn(), expected[i]);
19
+ }
20
+ }
21
+
22
+ }
@@ -0,0 +1,55 @@
1
+ # Kore Fleets typescript bot
2
+
3
+ ## Requirements
4
+
5
+ 1. node and npm/npx/yarn
6
+ 2. typescript installed
7
+ 3. python3 installed
8
+ 4. kaggle_environments pip package installed
9
+
10
+ ## Getting started
11
+
12
+ 1. `npm install`
13
+
14
+ ## Running Locally
15
+
16
+ 1. transpile your bot with `npm run compile` or `tsc`
17
+ 2. run a match with `npm watch4`
18
+
19
+ * if you don't have google-chrome installed, open the replay.html in the browser of your choice
20
+ * see package.json for more options
21
+
22
+ ## Creating a submission
23
+
24
+ 1. `npm run package`
25
+ 2. upload submission.tar.gz to kaggle
26
+ 3. profit!
27
+
28
+ ## Running tests
29
+
30
+ 1. `npm test`
31
+
32
+ ## Interpreter and training
33
+
34
+ A basic TS interpreter has been created in `interpreter.ts`. You can use or modify this file to train machine learning models in JS/TS.
35
+
36
+ Currently it supports 2 agents and customizable number of episodes.
37
+
38
+ It has two modes: `run` and `step`.
39
+
40
+ `run` mode: After each episode, you can access the complete history of the game. For each turn, you can access the full observation (state) as a Board object, actions performed and the reward obtained after performing the action. This mode is useful for evaluating an agent.
41
+
42
+ `step` mode: The interpreter initializes new games and allows stepping through the game interactively. You have complete control over the board and the agent during each step. This mode is useful for training machine learning models.
43
+
44
+ Sample command to run the interpreter can be found in npm scripts as `npm run interpreter:run` and `npm run interpreter:step`.
45
+
46
+ ## Miner bot and Do nothing bot
47
+
48
+ A sample miner bot `MinerBot.ts` is provided, with Python entrypoint as `miner.py`. It has the same logic as the Python `miner` bot in `kore_fleets.py`.
49
+
50
+ To run it aginst Python miner bot with TS interpreter for 20 episodes:
51
+
52
+ 1. `npm run compile`
53
+ 2. `node --require ts-node/register interpreter.ts 20 ./miner.py miner`
54
+
55
+ A sample do nothing bot `DoNothingBot.ts` is also provided.
@@ -293,7 +293,7 @@ with open(jsonpath) as f:
293
293
 
294
294
  def html_renderer():
295
295
  jspath = path.abspath(path.join(path.dirname(__file__), "llm_20_questions.js"))
296
- with open(jspath) as f:
296
+ with open(jspath, encoding="utf-8") as f:
297
297
  return f.read()
298
298
 
299
299
 
@@ -0,0 +1,3 @@
1
+ # Lux AI Challenge Season 1
2
+
3
+ Welcome to the Kaggle Environments wrapped around the Lux AI Challenge Season 1! For more information or if you have an issues or want to make contributes, check out the main repository at https://github.com/Lux-AI-Challenge/Lux-Design-2021
@@ -0,0 +1,296 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*!
8
+ * accepts
9
+ * Copyright(c) 2014 Jonathan Ong
10
+ * Copyright(c) 2015 Douglas Christopher Wilson
11
+ * MIT Licensed
12
+ */
13
+
14
+ /*!
15
+ * body-parser
16
+ * Copyright(c) 2014 Jonathan Ong
17
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
18
+ * MIT Licensed
19
+ */
20
+
21
+ /*!
22
+ * body-parser
23
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
24
+ * MIT Licensed
25
+ */
26
+
27
+ /*!
28
+ * bytes
29
+ * Copyright(c) 2012-2014 TJ Holowaychuk
30
+ * Copyright(c) 2015 Jed Watson
31
+ * MIT Licensed
32
+ */
33
+
34
+ /*!
35
+ * content-disposition
36
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
37
+ * MIT Licensed
38
+ */
39
+
40
+ /*!
41
+ * content-type
42
+ * Copyright(c) 2015 Douglas Christopher Wilson
43
+ * MIT Licensed
44
+ */
45
+
46
+ /*!
47
+ * cookie
48
+ * Copyright(c) 2012-2014 Roman Shtylman
49
+ * Copyright(c) 2015 Douglas Christopher Wilson
50
+ * MIT Licensed
51
+ */
52
+
53
+ /*!
54
+ * depd
55
+ * Copyright(c) 2014 Douglas Christopher Wilson
56
+ * MIT Licensed
57
+ */
58
+
59
+ /*!
60
+ * depd
61
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
62
+ * MIT Licensed
63
+ */
64
+
65
+ /*!
66
+ * depd
67
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
68
+ * MIT Licensed
69
+ */
70
+
71
+ /*!
72
+ * depd
73
+ * Copyright(c) 2015 Douglas Christopher Wilson
74
+ * MIT Licensed
75
+ */
76
+
77
+ /*!
78
+ * destroy
79
+ * Copyright(c) 2014 Jonathan Ong
80
+ * MIT Licensed
81
+ */
82
+
83
+ /*!
84
+ * ee-first
85
+ * Copyright(c) 2014 Jonathan Ong
86
+ * MIT Licensed
87
+ */
88
+
89
+ /*!
90
+ * encodeurl
91
+ * Copyright(c) 2016 Douglas Christopher Wilson
92
+ * MIT Licensed
93
+ */
94
+
95
+ /*!
96
+ * escape-html
97
+ * Copyright(c) 2012-2013 TJ Holowaychuk
98
+ * Copyright(c) 2015 Andreas Lubbe
99
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
100
+ * MIT Licensed
101
+ */
102
+
103
+ /*!
104
+ * etag
105
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
106
+ * MIT Licensed
107
+ */
108
+
109
+ /*!
110
+ * express
111
+ * Copyright(c) 2009-2013 TJ Holowaychuk
112
+ * Copyright(c) 2013 Roman Shtylman
113
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
114
+ * MIT Licensed
115
+ */
116
+
117
+ /*!
118
+ * express
119
+ * Copyright(c) 2009-2013 TJ Holowaychuk
120
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
121
+ * MIT Licensed
122
+ */
123
+
124
+ /*!
125
+ * finalhandler
126
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
127
+ * MIT Licensed
128
+ */
129
+
130
+ /*!
131
+ * forwarded
132
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
133
+ * MIT Licensed
134
+ */
135
+
136
+ /*!
137
+ * fresh
138
+ * Copyright(c) 2012 TJ Holowaychuk
139
+ * Copyright(c) 2016-2017 Douglas Christopher Wilson
140
+ * MIT Licensed
141
+ */
142
+
143
+ /*!
144
+ * http-errors
145
+ * Copyright(c) 2014 Jonathan Ong
146
+ * Copyright(c) 2016 Douglas Christopher Wilson
147
+ * MIT Licensed
148
+ */
149
+
150
+ /*!
151
+ * media-typer
152
+ * Copyright(c) 2014 Douglas Christopher Wilson
153
+ * MIT Licensed
154
+ */
155
+
156
+ /*!
157
+ * merge-descriptors
158
+ * Copyright(c) 2014 Jonathan Ong
159
+ * Copyright(c) 2015 Douglas Christopher Wilson
160
+ * MIT Licensed
161
+ */
162
+
163
+ /*!
164
+ * methods
165
+ * Copyright(c) 2013-2014 TJ Holowaychuk
166
+ * Copyright(c) 2015-2016 Douglas Christopher Wilson
167
+ * MIT Licensed
168
+ */
169
+
170
+ /*!
171
+ * mime-db
172
+ * Copyright(c) 2014 Jonathan Ong
173
+ * MIT Licensed
174
+ */
175
+
176
+ /*!
177
+ * mime-types
178
+ * Copyright(c) 2014 Jonathan Ong
179
+ * Copyright(c) 2015 Douglas Christopher Wilson
180
+ * MIT Licensed
181
+ */
182
+
183
+ /*!
184
+ * negotiator
185
+ * Copyright(c) 2012 Federico Romero
186
+ * Copyright(c) 2012-2014 Isaac Z. Schlueter
187
+ * Copyright(c) 2015 Douglas Christopher Wilson
188
+ * MIT Licensed
189
+ */
190
+
191
+ /*!
192
+ * on-finished
193
+ * Copyright(c) 2013 Jonathan Ong
194
+ * Copyright(c) 2014 Douglas Christopher Wilson
195
+ * MIT Licensed
196
+ */
197
+
198
+ /*!
199
+ * parseurl
200
+ * Copyright(c) 2014 Jonathan Ong
201
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
202
+ * MIT Licensed
203
+ */
204
+
205
+ /*!
206
+ * proxy-addr
207
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
208
+ * MIT Licensed
209
+ */
210
+
211
+ /*!
212
+ * range-parser
213
+ * Copyright(c) 2012-2014 TJ Holowaychuk
214
+ * Copyright(c) 2015-2016 Douglas Christopher Wilson
215
+ * MIT Licensed
216
+ */
217
+
218
+ /*!
219
+ * raw-body
220
+ * Copyright(c) 2013-2014 Jonathan Ong
221
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
222
+ * MIT Licensed
223
+ */
224
+
225
+ /*!
226
+ * send
227
+ * Copyright(c) 2012 TJ Holowaychuk
228
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
229
+ * MIT Licensed
230
+ */
231
+
232
+ /*!
233
+ * serve-static
234
+ * Copyright(c) 2010 Sencha Inc.
235
+ * Copyright(c) 2011 TJ Holowaychuk
236
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
237
+ * MIT Licensed
238
+ */
239
+
240
+ /*!
241
+ * statuses
242
+ * Copyright(c) 2014 Jonathan Ong
243
+ * Copyright(c) 2016 Douglas Christopher Wilson
244
+ * MIT Licensed
245
+ */
246
+
247
+ /*!
248
+ * toidentifier
249
+ * Copyright(c) 2016 Douglas Christopher Wilson
250
+ * MIT Licensed
251
+ */
252
+
253
+ /*!
254
+ * type-is
255
+ * Copyright(c) 2014 Jonathan Ong
256
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
257
+ * MIT Licensed
258
+ */
259
+
260
+ /*!
261
+ * unpipe
262
+ * Copyright(c) 2015 Douglas Christopher Wilson
263
+ * MIT Licensed
264
+ */
265
+
266
+ /*!
267
+ * vary
268
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
269
+ * MIT Licensed
270
+ */
271
+
272
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
273
+
274
+ /**
275
+ * @license
276
+ * Lodash <https://lodash.com/>
277
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
278
+ * Released under MIT license <https://lodash.com/license>
279
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
280
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
281
+ */
282
+
283
+ /**
284
+ * @license Complex.js v2.0.13 12/05/2020
285
+ *
286
+ * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
287
+ * Dual licensed under the MIT or GPL Version 2 licenses.
288
+ **/
289
+
290
+ /**
291
+ * @license Fraction.js v4.1.1 23/05/2021
292
+ * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
293
+ *
294
+ * Copyright (c) 2021, Robert Eisele (robert@xarg.org)
295
+ * Dual licensed under the MIT or GPL Version 2 licenses.
296
+ **/
@@ -0,0 +1,23 @@
1
+ Unfortunately at this moment, there isn't a progammatic way to test if the Kaggle Engine is the exact same as the engine competitors use when local testing. This is part of a TODO to make kaggle replays match the local replays players generate when they develop locally using https://github.com/Lux-AI-Challenge/Lux-Design-2021
2
+
3
+ The following steps work for now:
4
+
5
+ First download the simple kit from https://github.com/Lux-AI-Challenge/Lux-Design-2021/tree/master/kits/python (or another language) or use your own bot
6
+
7
+ First run a game in Kaggle like so:
8
+
9
+ ```
10
+ kaggle-environments run --environment lux_ai_2021 --agents path/to/bot/main.py path/to/bot/main.py --render '{"mode": "json"}' --out out.json --debug=True
11
+ ```
12
+
13
+ Then upload the out.json to https://2021vis.lux-ai.org/ and go to the final turn.
14
+
15
+ Then install the local engine `npm i -g install @lux-ai/2021-challenge` if you haven't done so already (you can remove `-g` and do `npx lux-ai-2021` as opposed to `lux-ai-2021`)
16
+
17
+ Then run
18
+
19
+ ```
20
+ lux-ai-2021 path/to/bot/main.py path/to/bot/main.py --out=replay.json
21
+ ```
22
+
23
+ upload `replay.json` to the replay viewer again in a new tab and compare the final state with the other kaggle produced match. If the statistics and layout of units on the map match, then the engine is working correctly. (Given the complexity of the game and that `lux-ai-2021` generates action based replays, should a single thing be wrong, the differences in the final turn would be fairly massive so this is generally a sufficient test)
@@ -0,0 +1,18 @@
1
+ # TODOs
2
+
3
+
4
+ [x] Setup Visualizer
5
+
6
+ [x] Keep dimensions engine results consistent with kaggle-env integated version
7
+
8
+ [ ] Verify rewards work correctly
9
+
10
+ [ ] display correct agent names
11
+
12
+ [ ] default turn debug mode off
13
+
14
+ [ ] add tests for more bots
15
+
16
+ [ ] allow user to pass in custom configurations
17
+
18
+ [ ] allow user to specify debug mode level for the dimensions engine
@@ -0,0 +1 @@
1
+ build/
@@ -0,0 +1,21 @@
1
+ # Lux AI Challenge Season 2
2
+
3
+ Welcome to the Kaggle Environments wrapped around the Lux AI Challenge Season 2! For more information or if you have an issues or want to make contributes, check out the main repository at https://github.com/Lux-AI-Challenge/Lux-Design-2022
4
+
5
+ ## Test scripts
6
+
7
+ ```
8
+ kaggle-environments run --environment lux_ai_2022 --agents path/to/bot/main.py path/to/bot/main.py --render '{"mode": "json"}' --out out.json --debug=True
9
+ ```
10
+
11
+ ```
12
+ kaggle-environments run --environment lux_ai_2022 --agents ../Lux-Design-2022/kits/js/main.py ../Lux-Design-2022/kits/js/main.py --render '{"mode": "json"}' --out out.json --debug=True
13
+ ```
14
+
15
+ ## Packaging external packages locally
16
+
17
+ git clone open_simplex and petting zoo directly and move them into here
18
+
19
+ ## Visualizer
20
+
21
+ Ensure that the script module is at the bottom of <body> tag.
@@ -0,0 +1,21 @@
1
+ # Lux AI Challenge Season 3
2
+
3
+ Welcome to the Kaggle Environments wrapped around the Lux AI Challenge Season 3! For more information or if you have an issues or want to make contributes, check out the main repository at https://github.com/Lux-AI-Challenge/Lux-Design-S3
4
+
5
+ ## Test scripts
6
+
7
+ ```
8
+ kaggle-environments run --environment lux_ai_s3 --agents path/to/bot/main.py path/to/bot/main.py --render '{"mode": "json"}' --out out.json --debug=True
9
+ ```
10
+
11
+ ```
12
+ kaggle-environments run --environment lux_ai_s3 --agents ../LuxAI/Lux-Design-S3/kits/python/main.py ../LuxAI/Lux-Design-S3/kits/python/main.py --render '{"mode": "json"}' --out out.json --debug=True
13
+ ```
14
+ <!--
15
+ ## Packaging external packages locally
16
+
17
+ git clone open_simplex and petting zoo directly and move them into here -->
18
+
19
+ ## Visualizer
20
+
21
+ Ensure that the script module is at the bottom of <body> tag.
@@ -11,7 +11,7 @@
11
11
  "type": "integer"
12
12
  },
13
13
  "actTimeout": 3,
14
- "runTimeout": 60,
14
+ "runTimeout": 1600,
15
15
  "env_cfg": {
16
16
  "description": "Environment configuration. Not to be filled out by user as it is randomly generated.",
17
17
  "type": "object"
@@ -40,23 +40,27 @@ class LuxAIS3Env(environment.Environment):
40
40
  params = jax.tree_map(jax.numpy.array, params)
41
41
  return params
42
42
 
43
- def compute_unit_counts_map(self, state: EnvState, params: EnvParams):
43
+ def compute_unit_counts_map(self, state: EnvState, params: EnvParams, exclude_negative_energy_units: bool = False):
44
44
  # map of total units per team on each tile, shape (num_teams, map_width, map_height)
45
45
  unit_counts_map = jnp.zeros(
46
46
  (self.fixed_env_params.num_teams, self.fixed_env_params.map_width, self.fixed_env_params.map_height), dtype=jnp.int16
47
47
  )
48
48
 
49
- def update_unit_counts_map(unit_position, unit_mask, unit_counts_map):
49
+ def update_unit_counts_map(unit_position, unit_mask, unit_energy_nonnegative, unit_counts_map):
50
+ if exclude_negative_energy_units:
51
+ mask = unit_mask & unit_energy_nonnegative
52
+ else:
53
+ mask = unit_mask
50
54
  unit_counts_map = unit_counts_map.at[
51
55
  unit_position[0], unit_position[1]
52
- ].add(unit_mask.astype(jnp.int16))
56
+ ].add(mask.astype(jnp.int16))
53
57
  return unit_counts_map
54
58
 
55
59
  for t in range(self.fixed_env_params.num_teams):
56
60
  unit_counts_map = unit_counts_map.at[t].add(
57
61
  jnp.sum(
58
- jax.vmap(update_unit_counts_map, in_axes=(0, 0, None), out_axes=0)(
59
- state.units.position[t], state.units_mask[t], unit_counts_map[t]
62
+ jax.vmap(update_unit_counts_map, in_axes=(0, 0, 0, None), out_axes=0)(
63
+ state.units.position[t], state.units_mask[t], state.units.energy[t, :, 0] >= 0, unit_counts_map[t]
60
64
  ),
61
65
  axis=0,
62
66
  dtype=jnp.int16
@@ -378,7 +382,7 @@ class LuxAIS3Env(environment.Environment):
378
382
  & (other_units_adjacent_sapped_count[:, :, None] > 0),
379
383
  all_units.energy[other_team_ids]
380
384
  - jnp.array(
381
- params.unit_sap_cost.astype(jnp.float32)
385
+ jnp.array(params.unit_sap_cost, dtype=jnp.float32)
382
386
  * params.unit_sap_dropoff_factor
383
387
  * other_units_adjacent_sapped_count[:, :, None].astype(jnp.float32),
384
388
  dtype=jnp.int16,
@@ -667,7 +671,10 @@ class LuxAIS3Env(environment.Environment):
667
671
  new_energy_nodes = jnp.clip(
668
672
  state.energy_nodes + energy_node_deltas,
669
673
  min=jnp.array([0, 0], dtype=jnp.int16),
670
- max=jnp.array([self.fixed_env_params.map_width, self.fixed_env_params.map_height], dtype=jnp.int16),
674
+ max=jnp.array(
675
+ [self.fixed_env_params.map_width - 1, self.fixed_env_params.map_height - 1],
676
+ dtype=jnp.int16
677
+ ),
671
678
  )
672
679
  new_energy_nodes = jnp.where(
673
680
  state.steps * params.energy_node_drift_speed % 1 == 0,
@@ -686,7 +693,7 @@ class LuxAIS3Env(environment.Environment):
686
693
 
687
694
  # note we need to recompue unit counts since units can get removed due to collisions
688
695
  team_scores = jax.vmap(team_relic_score)(
689
- self.compute_unit_counts_map(state, params)
696
+ self.compute_unit_counts_map(state, params, exclude_negative_energy_units=True)
690
697
  )
691
698
  # Update team points
692
699
  state = state.replace(team_points=state.team_points + team_scores)
@@ -90,35 +90,12 @@ class LuxAIPygameRenderer:
90
90
  surface.blit(shape_surf, rect)
91
91
 
92
92
  if self.display_options["show_relic_spots"]:
93
- for i in range(params.max_relic_nodes):
94
- if state.relic_nodes_mask[i]:
95
- x, y = state.relic_nodes[i, :2]
96
- config_size = params.relic_config_size
97
- half_size = config_size // 2
98
- for dx in range(-half_size, half_size + 1):
99
- for dy in range(-half_size, half_size + 1):
100
- config_x = x + dx
101
- config_y = y + dy
102
-
103
- if (
104
- 0 <= config_x < params.map_width
105
- and 0 <= config_y < params.map_height
106
- ):
107
-
108
- config_value = state.relic_node_configs[
109
- i, dy + half_size, dx + half_size
110
- ]
111
-
112
- if config_value > 0:
113
- rect = pygame.Rect(
114
- config_x * TILE_SIZE,
115
- config_y * TILE_SIZE,
116
- TILE_SIZE,
117
- TILE_SIZE,
118
- )
119
- draw_rect_alpha(
120
- self.surface, (255, 215, 0, 50), rect
121
- ) # Semi-transparent gold
93
+ mask = state.relic_nodes_map_weights
94
+ for x in range(params.map_width):
95
+ for y in range(params.map_height):
96
+ if mask[x, y] > 0:
97
+ rect = pygame.Rect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE)
98
+ draw_rect_alpha(self.surface, (255, 215, 0, 50), rect)
122
99
 
123
100
  # Draw energy nodes
124
101
  for i in range(params.max_energy_nodes):
@@ -23,23 +23,6 @@ class LuxAIS3GymEnv(gym.Env):
23
23
  self.jax_env = LuxAIS3Env(auto_reset=False)
24
24
  self.env_params: EnvParams = EnvParams()
25
25
 
26
- # auto run compiling steps here:
27
- # print("Running compilation steps")
28
- key = jax.random.key(0)
29
- # Reset the environment
30
- dummy_env_params = EnvParams(map_type=1)
31
- key, reset_key = jax.random.split(key)
32
- obs, state = self.jax_env.reset(reset_key, params=dummy_env_params)
33
- # Take a random action
34
- key, subkey = jax.random.split(key)
35
- action = self.jax_env.action_space(dummy_env_params).sample(subkey)
36
- # Step the environment and compile. Not sure why 2 steps? are needed
37
- for _ in range(2):
38
- key, subkey = jax.random.split(key)
39
- obs, state, reward, terminated, truncated, info = self.jax_env.step(
40
- subkey, state, action, params=dummy_env_params
41
- )
42
- # print("Finish compilation steps")
43
26
  low = np.zeros((self.env_params.max_units, 3))
44
27
  low[:, 1:] = -self.env_params.unit_sap_range
45
28
  high = np.ones((self.env_params.max_units, 3)) * 6