Skip to content

Commit

Permalink
fix bug in apple spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanaltvorst committed Jul 8, 2024
1 parent d60b4b4 commit c6931aa
Show file tree
Hide file tree
Showing 9 changed files with 9,258 additions and 10,603 deletions.
Binary file modified snake-a2c/agent_10x10.state
Binary file not shown.
Binary file modified snake-a2c/rewards_10x10.state
Binary file not shown.
13,893 changes: 6,962 additions & 6,931 deletions snake-a2c/rewards_episodes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion snake-a2c/snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def step(self, action):
np.random.randint(self.width),
np.random.randint(self.height),
)
if (self.apple_x, self.apple_y) not in self.tail.queue:
if (self.apple_x, self.apple_y) not in self.tail.queue and cur_x != self.apple_x and cur_y != self.apple_y:
break
else:
# Get rid of far tail section
Expand Down
Binary file modified snake-a2c/snake_game_visualisation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion snake-a2c/train.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down
5,740 changes: 2,270 additions & 3,470 deletions snake-a2c/visualise.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion snake-ppo/snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def step(self, action):
np.random.randint(self.width),
np.random.randint(self.height),
)
if (self.apple_x, self.apple_y) not in self.tail.queue:
if (self.apple_x, self.apple_y) not in self.tail.queue and cur_x != self.apple_x and cur_y != self.apple_y:
break
else:
# Get rid of far tail section
Expand Down
222 changes: 23 additions & 199 deletions snake-ppo/visualise.ipynb

Large diffs are not rendered by default.

0 comments on commit c6931aa

Please sign in to comment.