From 22dfbcbbc1c711b52eee771a040be368e41e92eb Mon Sep 17 00:00:00 2001 From: Nemo D'ACREMONT Date: Sun, 18 May 2025 20:02:38 +0200 Subject: [PATCH] rendu --- go_player/.gitignore | 2 ++ go_player/Makefile | 6 ++---- go_player/README.md | 16 ++++++++++++++++ go_player/moveSearch.py | 1 - go_player/myPlayer.py | 5 +++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/go_player/.gitignore b/go_player/.gitignore index 44e24de..4bea0b8 100644 --- a/go_player/.gitignore +++ b/go_player/.gitignore @@ -4,3 +4,5 @@ __pycache__ /go-package.tgz *.ipynb /chess +/tp_player-ndacremont_meyben +/tp_player-ndacremont_meyben.tar.gz diff --git a/go_player/Makefile b/go_player/Makefile index c53be46..e6a162d 100644 --- a/go_player/Makefile +++ b/go_player/Makefile @@ -12,15 +12,13 @@ files += tp_player-ndacremont_meyben/requirements.txt .PHONY += all 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 $@ $^ tp_player-ndacremont_meyben/%: % + @mkdir -p $(dir $@) cp $^ $@ -tp_player-ndacremont_meyben: - mkdir -p $@ - .PHONY += clean clean: $(RM) -r tp_player-ndacremont_meyben tp_player-ndacremont_meyben.tar.gz diff --git a/go_player/README.md b/go_player/README.md index 0a47ca3..91dc2bb 100644 --- a/go_player/README.md +++ b/go_player/README.md @@ -1,5 +1,21 @@ # 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 diff --git a/go_player/moveSearch.py b/go_player/moveSearch.py index b5dcbdc..0f005d3 100644 --- a/go_player/moveSearch.py +++ b/go_player/moveSearch.py @@ -97,7 +97,6 @@ def IDDFS( shouldStop = lambda: (time.time() - start_time) >= duration for depth in range(1, max_depth + 1): - value, move = _alphabeta( board, heuristic=heuristic, color=color, depth=depth, shouldStop=shouldStop ) diff --git a/go_player/myPlayer.py b/go_player/myPlayer.py index 8dadb54..c10807c 100644 --- a/go_player/myPlayer.py +++ b/go_player/myPlayer.py @@ -49,7 +49,8 @@ def goban2Go(board: Goban.Board): 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): @@ -154,7 +155,7 @@ class myPlayer(PlayerInterface): 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() with torch.no_grad():