ai-snake-lab 0.4.4__py3-none-any.whl → 0.4.6__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.
@@ -16,9 +16,8 @@ can also be passed in when invoking the main asg.py front end.
16
16
 
17
17
  import random
18
18
  from random import randint
19
- import os, sys
20
19
 
21
- from constants.DEpsilon import DEpsilon
20
+ from ai_snake_lab.constants.DEpsilon import DEpsilon
22
21
 
23
22
 
24
23
  class EpsilonAlgo:
@@ -12,12 +12,12 @@ This file contains the ReplayMemory class.
12
12
 
13
13
  import os
14
14
  from collections import deque
15
- import random, sys
15
+ import random
16
16
  import sqlite3, pickle
17
17
 
18
- from constants.DReplayMemory import MEM_TYPE
19
- from constants.DFile import DFile
20
- from constants.DDir import DDir
18
+ from ai_snake_lab.constants.DReplayMemory import MEM_TYPE
19
+ from ai_snake_lab.constants.DFile import DFile
20
+ from ai_snake_lab.constants.DDir import DDir
21
21
 
22
22
 
23
23
  class ReplayMemory:
@@ -18,7 +18,7 @@ from textual.reactive import var
18
18
  from rich.segment import Segment
19
19
  from rich.style import Style
20
20
 
21
- from game.GameElements import Direction
21
+ from ai_snake_lab.game.GameElements import Direction
22
22
 
23
23
  emptyA = "#111111"
24
24
  emptyB = "#000000"
@@ -14,8 +14,8 @@ import numpy as np
14
14
 
15
15
  from textual.geometry import Offset
16
16
 
17
- from game.GameBoard import GameBoard
18
- from game.GameElements import Direction
17
+ from ai_snake_lab.game.GameBoard import GameBoard
18
+ from ai_snake_lab.game.GameElements import Direction
19
19
 
20
20
  # Maximum number of moves. This is multiplied by the length of the snake. The game
21
21
  # ends if game moves > MAX_MOVES * length-of-snake. This avoids enless AI looping behavior.
@@ -129,12 +129,6 @@ class SnakeGame:
129
129
  game_over = True
130
130
  reward = -10
131
131
 
132
- # Set a negative reward if the snake head is adjacent to the snake body.
133
- # This is to discourage snake collisions.
134
- for segment in self.snake[1:]:
135
- if abs(self.head.x - segment.x) < 2 and abs(self.head.y - segment.y) < 2:
136
- reward -= -1
137
-
138
132
  if game_over == True:
139
133
  # Game is over: Snake or wall collision or exceeded max moves
140
134
  self.game_reward += reward
@@ -159,6 +153,12 @@ class SnakeGame:
159
153
  reward -= 2
160
154
  self.distance_to_food = cur_distance
161
155
 
156
+ ## 6. Set a negative reward if the snake head is adjacent to the snake body.
157
+ # This is to discourage snake collisions.
158
+ for segment in self.snake[1:]:
159
+ if abs(self.head.x - segment.x) < 2 and abs(self.head.y - segment.y) < 2:
160
+ reward -= -2
161
+
162
162
  self.game_reward += reward
163
163
  self.game_board.update_snake(snake=self.snake, direction=self.direction)
164
164
  self.game_board.update_food(food=self.food)
@@ -426,6 +426,10 @@ def minutes_to_uptime(seconds: int):
426
426
  return f"{seconds}s"
427
427
 
428
428
 
429
- if __name__ == "__main__":
429
+ def main():
430
430
  app = AISim()
431
431
  app.run()
432
+
433
+
434
+ if __name__ == "__main__":
435
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-snake-lab
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: Interactive reinforcement learning sandbox for experimenting with AI agents in a classic Snake Game environment.
5
5
  License: GPL-3.0
6
6
  License-File: LICENSE
@@ -1,8 +1,7 @@
1
- ai_snake_lab/AISim.py,sha256=GiqzvU0LAvjjmjP_0JDeak7DAF0R-pEzrPgVpCN-gs8,15148
2
1
  ai_snake_lab/ai/AIAgent.py,sha256=p_O7zC15s_tBcI7oqu60X2-3AbrzAWlGXWkrLVC4UsQ,3005
3
2
  ai_snake_lab/ai/AITrainer.py,sha256=ssX6B03yZLEKhNCJv9D83iFAEEhU3_XbW4sA0z5QMRM,3304
4
- ai_snake_lab/ai/EpsilonAlgo.py,sha256=iNVXOqlyjh5vlFePpksR0PTT9M5FDDwJi7P6pYegSrA,2144
5
- ai_snake_lab/ai/ReplayMemory.py,sha256=eGdszKKeYuvppmmkA9AtypLRbGZQGZO-uCSHb8qcesw,3986
3
+ ai_snake_lab/ai/EpsilonAlgo.py,sha256=Q2U_Ow28ZRQn1hlLybWEhB2Gn101x99mrQWupAooRjk,2142
4
+ ai_snake_lab/ai/ReplayMemory.py,sha256=dtF6CkYWBvjqnKPdNA_0Dgr1DWQYAE-KMpB9IIxkoCk,4020
6
5
  ai_snake_lab/ai/models/ModelL.py,sha256=hK7MoPyIF1_K43R_9xW_MYuaweQGo9qSMUIVrHDQZnQ,1249
7
6
  ai_snake_lab/ai/models/ModelRNN.py,sha256=Ky63BUqJEmwe1PbM4gtjvqd7SmSy_2XA1n-yu8DNexI,1104
8
7
  ai_snake_lab/constants/DDb4EPlot.py,sha256=2g8SdDVZWrTVSTw-rpO84OrNfl7ToBYtf6J7sYB7q8w,442
@@ -18,14 +17,15 @@ ai_snake_lab/constants/DModelLRNN.py,sha256=nyPYa1-8JB7KERWEJM5jBFH3PmISNcr9JPi-
18
17
  ai_snake_lab/constants/DReplayMemory.py,sha256=m0SSxFL6v2mVXVxf0lJTJzKfXguxrnsnrJph0v-2lX8,589
19
18
  ai_snake_lab/constants/DSim.py,sha256=ULi_e9g2eBPPZv_swQQoagKLT8dL3gJTwlQihkQk8RY,510
20
19
  ai_snake_lab/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- ai_snake_lab/game/GameBoard.py,sha256=VjjNXnZZJ_lTo4bcxflB9TWxi792Do7yMnvL3umrMCc,8452
20
+ ai_snake_lab/game/GameBoard.py,sha256=iNgain-8YQg2Ky0GkmGX-ViVmL8P7zPiZYU6Qwrp9Cc,8465
22
21
  ai_snake_lab/game/GameElements.py,sha256=9vcNH2YWAzYyBZosvj1DzO6ZmUCUMUd8MaIhORWQ8go,470
23
- ai_snake_lab/game/SnakeGame.py,sha256=_gyxhLPggPF7B2XvmWLgWP2ywnYWX7QjmwLmi21QuIw,6476
22
+ ai_snake_lab/game/SnakeGame.py,sha256=ADJSVD-bXBruSHf0rzQFh2P9hPWUAnCkQ95B-RFk1vI,6506
23
+ ai_snake_lab/ui/AISim.py,sha256=_XUJtiQ_CMWB7beiXq3o9wgmIL-3QGwjHxy8KbSmd_c,15173
24
24
  ai_snake_lab/ui/Db4EPlot.py,sha256=pcEb0ydXNX2wL0EFBSrqhIoTEhryk4GD0Ua8FFEaZHY,5352
25
25
  ai_snake_lab/utils/AISim.tcss,sha256=XnhqjuxtOiNQHDyXFrbAYSlCw-6ch4e1o52nbytoeF0,2118
26
26
  ai_snake_lab/utils/ConstGroup.py,sha256=ZYyQxFd9PudBUZmc_NsNvWCp___utOe1MptqD3eyVH8,1174
27
- ai_snake_lab-0.4.4.dist-info/METADATA,sha256=dNvC3Ia4TfGeL5L4N6rS2snjbydNdT_ZCo1XGyYGSMU,3689
28
- ai_snake_lab-0.4.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
29
- ai_snake_lab-0.4.4.dist-info/entry_points.txt,sha256=VXWDqigE8D35J7scdqjR0EVvOjtP1mm0uS76xMnvodo,56
30
- ai_snake_lab-0.4.4.dist-info/licenses/LICENSE,sha256=f-FHFu0xzHH8O_mvKTw2jUZKhTpw6obpmVOI9rnpKeU,35151
31
- ai_snake_lab-0.4.4.dist-info/RECORD,,
27
+ ai_snake_lab-0.4.6.dist-info/METADATA,sha256=shfnaQS9q3tefXcTuISZbAJRVCGUQ79ivMNrHgDQkKE,3689
28
+ ai_snake_lab-0.4.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
29
+ ai_snake_lab-0.4.6.dist-info/entry_points.txt,sha256=ThFx-0yPF5pdwOXUbEo95FEXLUUbOcjfhgMv67PHuIw,59
30
+ ai_snake_lab-0.4.6.dist-info/licenses/LICENSE,sha256=f-FHFu0xzHH8O_mvKTw2jUZKhTpw6obpmVOI9rnpKeU,35151
31
+ ai_snake_lab-0.4.6.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ ai-snake-lab=ai_snake_lab.ui.AISim:main
3
+
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- ai-snake-lab=ai_snake_lab.AISim:main
3
-