Skip to content

Latest commit

 

History

History
83 lines (66 loc) · 3.63 KB

README.md

File metadata and controls

83 lines (66 loc) · 3.63 KB

RL_DaVinciCode

A reinforcement learning model for the Da Vinci Code game

Table of Contents

Structure

flowchart TD
    A[Base Game Logic] --> B[Gymnasium Environment]
    B --> C[Model Trainer]
    C --> D[Trained Model]
    A --> E[Web Game Interface]
    D --> E
Loading

Base Game Logic

Base Game Logic implements the abstracted game classes and methods necessary for the game to function.

Gymnasium Environment

Gymnasium Environment utilizes the game logic to create a Gymnasium environment.

Model Trainer

Model Trainer is a PPO trainer modified and refined from rl_adventure2.

  • Removed the multiple environment parallel training to reduce complexity.
  • Adapted to a multi-discrete action space.
  • Added a shared network before the actor and critic networks to improve training efficiency and model performance.
  • Included additional graphs (correct count, smoothed graphs) for better monitoring.
  • Adjusted hyperparameters to optimize model performance.

Trained Model

Trained Model contains the saved model object for further use in the web game interface.

Web Game Interface

Web Game Interface utilizes the game logic and the Streamlit library to create a web interface for human players. The model is loaded to play against human players. You can try it out on the Streamlit app deployment.

Da Vinci Code Game Rules

Objective

Be the first to expose your opponents' secret codes before your own is fully revealed.

Game Setup

  1. Tile Arrangement: 24 numbered tiles divided into two sets:
    • Dark tiles: 12 tiles numbered 1-12
    • Light tiles: 12 tiles numbered 1-12
  2. Drawing Tiles:
    • Each player draws 4 tiles at random and hides the numbers.
  3. Sorting Tiles:
    • Each player sorts their tiles in numerical order from left to right (lowest to highest). For two tiles with the same number, the dark tile is placed to the left of the light tile.

Play

  1. Drawing a Tile: On your turn, draw one of the remaining tiles and keep it hidden from other players.
  2. Making a Guess:
    • Choose an opponent and guess the number of one of their tiles.
    • Correct Guess: If you are correct, the opponent will reveal the tile.
    • Incorrect Guess: If you are wrong, the tile you drew will be revealed and placed in its correct position. This gives your opponents clues about your hidden tiles.
  3. Continuing Your Turn: If your first guess is correct, you may either:
    • Attack another opponent's tile.
    • End your turn, in which case the tile you drew will be placed in its correct position without revealing it. Your secret code is now one tile longer.

Next Turn / Winning

  • Play continues in turns. The game continues until only one player has tiles still unrevealed. That player is declared the winner.