Package: gobblet-rl
gobblet-rlInteractive Multi-Agent Reinforcement Learning Environment for theGobbletboard game usingPettingZooandPygame.Allows for users to play in the same environment, and even play against RL agents trained withTianshou.InstallationUsing pip (recommended)pipinstallgobblet-rlLocalgitclonehhttps://github.com/elliottower/gobblet-rl.gitcdgobblet-rl
pipinstall-e.UsageSetting up a basic environmentIn a Python shell, run the following:fromgobblet_rlimportgobblet_v1env=gobblet_v1.env()Play against a greedy agentIn the terminal, run the following:python gobblet/example_tianshou_greedy.py --cpu-players 1This will launch a game vs a greedy agent, which is a very strong baseline. This agent considers all possible moves with a depth of 2, winning if possible, blocking enemy wins, and even forcing the enemy to make losing moves.Note: this policy exploits domain knowledge to reconstruct the internal game board from the observation (perfect information) and directly uses functions fromboard.py. Tianshou policies do not get direct access to the environment, only observations/action masks. So the greedy agent should not be directly compared with other RL agents.Play against a DQN agent trained with TianshouIn the terminal, run the following:python gobblet/example_tianshou_DQN.py --epoch 50 --player 1 --cpu-players 2This will train aDQNmodel from Tianshou for 50 epochs, and launch an interactive game against the pre-trained agent.Use the argument--cpu-playerto determine the number of CPU agents (1 or 2)  and--playerto choose which agent goes first (human first: 0, CPU first: 1)Use the argument--self-playto train agents using self-play.Play an interactive gameIn the terminal, run the following:python gobblet/examples/example_user_input.py"Note: Interactive play can be enabled in other scripts using the argument--num-cpu 1To select a piece size, press a number key1,2, or3, or pressspaceto cycle through pieces. Placing a piece is done by clicking on a square on the board. A preview will appear showing legal moves with the selected piece size. Clicking on an already placed piece will pick it up and prompt you to place it in a new location (re-placing in the same location is an illegal move).Create screen recording of a gameIn the terminal, run the following:python gobblet/examples/example_record_game.py"This will save a screen recording of a game togobblet/examples/game.gifWatch a game between two basic CPU agentsIn the terminal, run the following:python gobblet/examples/example_basic.py"This will launch a game with two basic agents choosing random actions. This file can be used as a starting point for prototyping future methods.Command Line ArgumentsGame ModesAll scripts besidesexample_basic.py(no support for interactive play) take the following arguments:The default game mode is human vs CPU, with the human playing as red and CPU as yellow.--player 1sets the human player as yellow, with the CPU moving first as red.--cpu-players 1will launch a game with one CPU agent and one human agent. (default)--cpu-players 0will launch a game with no CPU agents, taking interactive input for both agents.--cpu-player 2will launch a game with two CPU agents, and takes no interactive input.Display Modesexample_basic.pytakes the following arguments to change display mode:--render_mode="human"will render the game board visually using pygame. Player 1 plays red and goes first, while player 2 plays yellow.When playing interactively, possible moves can be previewed by hovering the mouse over each square. To move a piece which is already placed, simply click on it.--render_mode="text"will render a 3x3 board only showing the topmost pieces (pieces which are covered by others, or 'gobbled', are hidden):TURN: 2, AGENT: player_1, ACTION: 51, POSITION: 6, PIECE: 3
       |       |       
  -    |   -   |   -3  
_______|_______|_______
       |       |       
  -    |   -   |   +2  
_______|_______|_______
       |       |       
  -    |   -   |   -   
       |       |--render_mode="text_full"will render three different 3x3 boards representing the small, medium and large pieces. This gives full information about pieces which are covered or 'gobbled' by other pieces. :TURN: 3, AGENT: player_0, ACTION: 42, POSITION: 6, PIECE: 5
         SMALL                     MED                     LARGE           
       |       |                |       |                |       |       
  -    |   -   |   -       -    |   -   |   -       -    |   -   |   +5  
_______|_______|_______  _______|_______|_______  _______|_______|_______
       |       |                |       |                |       |       
  -    |   -   |   -2      -    |   -   |   -       -    |   -   |   -   
_______|_______|_______  _______|_______|_______  _______|_______|_______
       |       |                |       |                |       |       
  -    |   -   |   -       -    |   -   |   -       -    |   -   |   -6  
       |       |                |       |                |       |TestingTesting can be done viapytest:gitclonehttps://github.com/elliottower/gobblet-rl.gitcdgobblet-rl
pytest