Skip to content

Commit

Permalink
adding indiana
Browse files Browse the repository at this point in the history
  • Loading branch information
Aisthetic committed Dec 10, 2020
1 parent 20db39f commit b35b710
Showing 1 changed file with 61 additions and 3 deletions.
64 changes: 61 additions & 3 deletions players/indianajones.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def play(self, game: Game) -> Action:
# Renvoie `True` si le chemin est sûr
is_safe = (
lambda x, y: game.background[y][x] == Tile.FLOOR
and not game.tile_grid[y][x].is_dangerous()
and not (game.tile_grid[y][x].is_dangerous() and )
)

line_fireball = (
lambda x, y: game.background
)

# Si on est en danger, on cherche un endroit sûr
Expand All @@ -42,21 +46,25 @@ def play(self, game: Game) -> Action:
Action.MOVE_DOWN,
Action.MOVE_LEFT,
Action.MOVE_RIGHT,
Action.ATTACK_UP,
Action.ATTACK_DOWN,
Action.ATTACK_LEFT,
Action.ATTACK_RIGHT,
):
# Coordonnées de la case voisine
x, y = direction.apply((self.x, self.y))

# Si on peut aller dans cette direction, on explore les possibilités offertes
if self.is_action_valid(direction):
# On retient quelle est la direction de départ
paths.append((x, y, direction))
paths.append((x, y, direction, cost(x, y)))
explored[y][x] = True

# Tant qu'il existe des chemins possibles
while len(paths) > 0:

# On regarde un chemin envisageable
x, y, direction = paths.pop(0)
x, y, direction = paths.pop()

# Si sa destination est acceptable, on va dans la direction de départ
# pour s'y rendre
Expand All @@ -70,6 +78,10 @@ def play(self, game: Game) -> Action:
Action.MOVE_DOWN,
Action.MOVE_LEFT,
Action.MOVE_RIGHT,
Action.ATTACK_UP,
Action.ATTACK_DOWN,
Action.ATTACK_LEFT,
Action.ATTACK_RIGHT,
):
# On regarde la case voisine
new_x, new_y = d.apply((x, y))
Expand All @@ -80,3 +92,49 @@ def play(self, game: Game) -> Action:
explored[new_y][new_x] = True

return Action.WAIT

def line_fireball(x, y, game):
x_line = game.entity_grid[:][x]
y_line = game.entity_grid[y][:]
# Checking if coming toward player
for index in range(len(game.tile_grid):
entity = game.entity_grid[index][x]
if isinstance(entity, entities.Fireball):
chibool = True
if index > y and entity.action == Action.MOVE_UP:

for indexa in range(y, index):
if game.tile_grid[indexa][x] == Tile.WALL:
chibool = False
if chibool:
return chibool
if index < y and entity.action == Action.MOVE_DOWN:
for indexa in range(index, y):
if game.tile_grid[indexa][x] == Tile.WALL:
chibool = False
if chibool:
return chibool

oumtity = game.entity_grid[y][index]
if isinstance(oumtity, entities.Fireball):
chibool = True
if index > x and entity.action == Action.MOVE_LEFT:

for indexa in range(x, index):
if game.tile_grid[x][indexa] == Tile.WALL:
chibool = False
if chibool:
return chibool
if index < x and entity.action == Action.MOVE_RIGHT:
for indexa in range(index, x):
if game.tile_grid[x][indexa] == Tile.WALL:
chibool = False
if chibool:
return chibool
return False


# L9wada l7assiba
def cost(x, y):
if accept_target

0 comments on commit b35b710

Please sign in to comment.