Giter Club home page Giter Club logo

catan_rl's Introduction

Learning To Play "Settlers of Catan" With Deep Reinforcement Learning

A custom simulator written in Python and designed with RL in mind. Also included is an implementation of PPO that can be used to train an agent to play, as well as a "forward search" agent that uses the trained RL agent for planning.

A full writeup for this project is available here.

Main dependencies are:

pygame==2.1.2 numpy==1.20.3 torch==1.10.2 stable_baselines3==1.4.0

Install with pip install -e .

Pre-trained agent is included in RL/results. Not quite at the level of a good human, but can still be fun to play against. To launch an interactive game run:

python play.py

which will give you a game where you control all players. To play against three copies of the RL agent:

python play.py --policy1 "human" --policy2 "RL_3825" --policy3 "RL_3825" --policy4 "RL_3825"

here 3825 refers to the file "default_after_update_3825.pt" included in RL/results. In general if you run training the agent should be saved at regular intervals and you could change 3825 to the number of updates the agent has been trained for.

To play against three "forward search" agents:

python play.py --policy1 "human" --policy2 "forward_search_3825" --policy3 "forward_search_3825" --policy4 "forward_search_3825"

where here the forward search agent will be built on top of the RL policy after 3825 updates. There are other arguments that can be configured for the forward search agent as well - ideally you want to set --num-processes to as many CPU cores as you have available, and --thinking-time can also be configured to choose how long the agent can spend on each decision (note that by default they are given extra time for the initial placement phase).

To train an agent from scratch (which will take a long time - the pretrained agent was ran for ~1 month on a 32-core machine with a GTX3090 GPU), run:

python RL/robust_train.py

Note that the arguments to configure the experiment can be found in RL/ppo/arguments.py.

For local running on my mac: python3 RL/robust_train.py --num-processes=1 --num-envs-per-process=1 --num-mini-batch=8

catan_rl's People

Contributors

fortydegrees avatar

Stargazers

Gaspard Culis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.