Team course project (2 people)
Université de Technologie de Compiègne · IA02 Problem Solving and Logic Programming (spring 2024)
An AI for Mark Steere's two-player hex games Gopher and Dodo: axial-coordinate board, legal-move generation, a mobility evaluation and memoised Minimax search.
This was the final project of IA02 “Problem Solving and Logic Programming” at UTC. The course supplied a referee server (gndserver) and an HTTP client (gndclient.py) handling registration, pairing, timing, legality checks and state synchronisation. Our job was the AI core, jeux.py: board modelling, legal-move generation, position evaluation and search.
The opponents are two two-player hex games designed by Mark Steere: Gopher and Dodo. Neither rule set is complicated, but hex adjacency and the counter-intuitive “no legal move means you win” rule make legal-move and terminal detection easier to get wrong than in ordinary board games.
Gopher
A hex board of size n has 3n(n-1)+1 cells: 37 for n=4 and 91 for n=6.
Dodo
corners or one_line layout;(x, y) represent the hex grid; initialize_board builds the n=4/6 cells and the Dodo starting layout.legals): Gopher scans the neighbours of enemy pieces and keeps empty cells with exactly one enemy and no friendly neighbour; Dodo uses three forward directions per colour, with in-bounds and empty-target checks.apply_action): Gopher places a piece; Dodo clears the origin and fills the destination.-len(legals(...)) — fewer available moves means a worse score.minmax plus memoize, keyed on the full board, depth, side to maximise, root player, board size and game name. The root enumerates moves and searches four more plies, five half-moves in total.gndclient.py untouched.With gndserver.exe -game gopher -random running locally, test_client.py completes a full game and prints Ending: 1 wins with a score of 1 and Red wins!.
Rough local measurements (Windows 11, Python 3.14):
The limitations are explicit:
legals rescans state repeatedly, so the real cost is close to O(n⁴);(0,0) instead of searching the first move;The repository’s tp/ folder also keeps the IA02 exercises and tutorial sheets: propositional and first-order logic, SAT (including a Sudoku encoding and Gophersat samples), Prolog (family relations, Mastermind), ASP with Clingo, and a Minimax tic-tac-toe. They are independent of the Gopher & Dodo project and serve as a complete learning archive.
Source and rule documents: https://github.com/yicongl1/Gopher-and-Dodo