-
Notifications
You must be signed in to change notification settings - Fork 0
/
playerExample2.py
42 lines (39 loc) · 1.31 KB
/
playerExample2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import annotations
import numpy as np
# pylint: disable=unused-import
from challenge import (
TYPE_PIERRE,
TYPE_CISEAUX,
TYPE_FEUILLE,
BasePlayer
)
import random
class Player(BasePlayer):
DIRECTIONS=((0, 1), (0, -1), (1, 0), (-1, 0))
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
# Utiliser self.config pour acceder à la configuration de la partie si nécéssaire (lecture seule)
self.name = 'Partiellement Aléatoire'
self.dir = 0
# pylint: disable=unused-argument
def play(
self,
maze: np.array,
myPosition: tuple[int, int],
enemyPosition: tuple[int, int],
myType: int,
enemyType: int,
myScore: int,
enemyScore: int,
):
d = self.DIRECTIONS[self.dir]
p = (myPosition[0] + d[0], myPosition[1] + d[1])
if maze[p[1]][p[0]] == -1:
self.dir = random.randrange(len(self.DIRECTIONS))
d = self.DIRECTIONS[self.dir]
p = (myPosition[0] + d[0], myPosition[1] + d[1])
while maze[p[1]][p[0]] == -1:
self.dir = (self.dir + 1) % len(self.DIRECTIONS)
d = self.DIRECTIONS[self.dir]
p = (myPosition[0] + d[0], myPosition[1] + d[1])
return p