rendu
This commit is contained in:
parent
91cf372a7e
commit
22dfbcbbc1
2
go_player/.gitignore
vendored
2
go_player/.gitignore
vendored
@ -4,3 +4,5 @@ __pycache__
|
|||||||
/go-package.tgz
|
/go-package.tgz
|
||||||
*.ipynb
|
*.ipynb
|
||||||
/chess
|
/chess
|
||||||
|
/tp_player-ndacremont_meyben
|
||||||
|
/tp_player-ndacremont_meyben.tar.gz
|
||||||
|
@ -12,15 +12,13 @@ files += tp_player-ndacremont_meyben/requirements.txt
|
|||||||
.PHONY += all
|
.PHONY += all
|
||||||
all: tp_player-ndacremont_meyben.tar.gz
|
all: tp_player-ndacremont_meyben.tar.gz
|
||||||
|
|
||||||
tp_player-ndacremont_meyben.tar.gz: tp_player-ndacremont_meyben $(files)
|
tp_player-ndacremont_meyben.tar.gz: $(files)
|
||||||
tar -cvzf $@ $^
|
tar -cvzf $@ $^
|
||||||
|
|
||||||
tp_player-ndacremont_meyben/%: %
|
tp_player-ndacremont_meyben/%: %
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
cp $^ $@
|
cp $^ $@
|
||||||
|
|
||||||
tp_player-ndacremont_meyben:
|
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
.PHONY += clean
|
.PHONY += clean
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r tp_player-ndacremont_meyben tp_player-ndacremont_meyben.tar.gz
|
$(RM) -r tp_player-ndacremont_meyben tp_player-ndacremont_meyben.tar.gz
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
# TP Noté joueur Go -- Nemo D'ACREMONT, Martin EYBEN, G1
|
# TP Noté joueur Go -- Nemo D'ACREMONT, Martin EYBEN, G1
|
||||||
|
|
||||||
|
## Librairies nécessaire
|
||||||
|
|
||||||
|
Ces librairies sont listées dans le fichier `requirements.txt` et sont les
|
||||||
|
suivantes :
|
||||||
|
|
||||||
|
* PyTorch
|
||||||
|
* Numpy
|
||||||
|
|
||||||
|
## Techniques utilisées
|
||||||
|
|
||||||
|
* IDDFS avec alphabeta
|
||||||
|
* Stop le calcule du coup dans le parcours alphabeta si on dépasse le temps
|
||||||
|
alloué
|
||||||
|
* Joue des coups classiques sans heuristique lorsqu'il y a peu (<10) de pions
|
||||||
|
sur le plateau
|
||||||
|
* Passe si le joueur l'adversaire vient de passer et qu'on est en train de
|
||||||
|
gagner
|
||||||
|
* Plus de pions sont joués, plus on alloue du temps à jouer, sauf si on est
|
||||||
|
proche de 30min, dans quel cas on joue rapidement
|
||||||
|
@ -97,7 +97,6 @@ def IDDFS(
|
|||||||
shouldStop = lambda: (time.time() - start_time) >= duration
|
shouldStop = lambda: (time.time() - start_time) >= duration
|
||||||
|
|
||||||
for depth in range(1, max_depth + 1):
|
for depth in range(1, max_depth + 1):
|
||||||
|
|
||||||
value, move = _alphabeta(
|
value, move = _alphabeta(
|
||||||
board, heuristic=heuristic, color=color, depth=depth, shouldStop=shouldStop
|
board, heuristic=heuristic, color=color, depth=depth, shouldStop=shouldStop
|
||||||
)
|
)
|
||||||
|
@ -49,7 +49,8 @@ def goban2Go(board: Goban.Board):
|
|||||||
|
|
||||||
goBoard[2, :, :] = 1 if black_plays else 0
|
goBoard[2, :, :] = 1 if black_plays else 0
|
||||||
|
|
||||||
return goBoard
|
# sometime, a little bit of magic is required
|
||||||
|
return torch.from_numpy(np.array([goBoard])).float()
|
||||||
|
|
||||||
|
|
||||||
class GoModel(nn.Module):
|
class GoModel(nn.Module):
|
||||||
@ -154,7 +155,7 @@ class myPlayer(PlayerInterface):
|
|||||||
|
|
||||||
return math.inf if board.winner() == self._mycolor else -math.inf
|
return math.inf if board.winner() == self._mycolor else -math.inf
|
||||||
|
|
||||||
go_board = torch.from_numpy(np.array([goban2Go(board)])).float().to(self.device)
|
go_board = goban2Go(board).to(self.device)
|
||||||
|
|
||||||
self.model.eval()
|
self.model.eval()
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user