regenerates mines and snacks

may still try to add more difficulty and update any docstrings and old commented code
This commit is contained in:
Chris Mekelburg
2024-12-08 21:31:20 -05:00
parent 729e1085ee
commit 947f9647ba
16 changed files with 208 additions and 27 deletions

View File

@@ -17,7 +17,8 @@ direction_vectors = {
class Man:
character = "&" #try google asci full table?,
color = "blue"
#name = "man"
snack=False
mine=False
def __init__(self,position):
self.position = position
@@ -50,7 +51,6 @@ class Man:
if obstacle.snack:
game.state['Score'] += 1
game.remove_agent(agents[0])
self.generate_new_snack()
else:
game.state['Score'] -= 10
game.remove_agent(agents[0])
@@ -61,28 +61,16 @@ class Man:
else:
self.position = future_position
'''Indicates what happens when the game is over.'''
def die(self,game):
'''Indicates what happens when the game is over.'''
game.state["message"] = "Game Over"
self.color = "black"
game.end()
def get_all_positions(self):
positions=[]
for i in range(width):
for j in range(height):
positions.append((i,j))
return positions
'''issue here, is_empty is not generating a coordinate positon,
but I am not sure why it is not'''
def generate_new_snack(self):
all_positions=self.get_all_positions()
shuffle(all_positions)
index =0
while Game.is_empty(all_positions[index]) == False:
index = index + 1
Snack(all_positions[index])
'''
def __init__(self, position):
self.position = position