输入命令:
(pytorch) PS E:\ai projection\snake-ai-master\main> python .\snake_game.py
报错:
Traceback (most recent call last):
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 259, in
game = SnakeGame(seed=seed, silent_mode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 51, in init
self.reset()
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 60, in reset
self.food = self._generate_food()
^^^^^^^^^^^^^^^^^^^^^
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 140, in _generate_food
food = random.sample(self.non_snake, 1)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\anaconda\envs\pytorch\Lib\random.py", line 439, in sample
raise TypeError("Population must be a sequence. "
TypeError: Population must be a sequence. For dicts or sets, use sorted(d).
需要修改的地方:
and
输入命令: (pytorch) PS E:\ai projection\snake-ai-master\main> python .\snake_game.py 报错: Traceback (most recent call last): File "E:\ai projection\snake-ai-master\main\snake_game.py", line 259, in
game = SnakeGame(seed=seed, silent_mode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 51, in init
self.reset()
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 60, in reset
self.food = self._generate_food()
^^^^^^^^^^^^^^^^^^^^^
File "E:\ai projection\snake-ai-master\main\snake_game.py", line 140, in _generate_food
food = random.sample(self.non_snake, 1)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\anaconda\envs\pytorch\Lib\random.py", line 439, in sample
raise TypeError("Population must be a sequence. "
TypeError: Population must be a sequence. For dicts or sets, use sorted(d).
需要修改的地方:
and