Giter Site home page Giter Site logo

cribbage's Introduction

Cribbage

This project contains the code for Cribbage as a reinforcement learning problem.

To get right into it

The agents are: DeepPeg.py, LinearB.py, Myrmidon.py, Monty.py, Monty2.py, NonLinearB.py, and PlayerRandom.py

Each agent can be run directly as a python script >> python3 <agentname>.py This will run the agent in the Arena against Myrmidon and produces learning curve performance graphs.

Supporting files are: TrainHand.py, TrainPegging.py, and TrainingScript.py

These files are configured to be run directly as scripts; TrainHand.py and TrainPegging.py are both interactive scripts.

More detailed file rundown

There are four kinds of files in this folder.

CRIBBAGE FILES

  1. Cribbage.py: Main file for playing a game of cribbage. Plays through hands one at a time, scoring for nobs, pegging and hands as it goes. Winner is declared as soon as one player reaches 121 points.
  2. Deck.py: Classes representing Suits, Ranks, Cards and Decks.
  3. Scoring.py: Scores cards according to the rules of cribbage.

PLAYER FILES

  1. Player.py: An abstract class defining what methods a player class must have in order to play well with Cribbage.py.
  2. PlayerRandom.py: A simple instantiation of a Player. Makes decisions randomly.
  3. Myrmidon.py: A Player that makes use of one-step rollouts and heuristics.
  4. LinearB.py: A Player that represents hands using a linear combination of features. These features are then used for episodic semi-gradient one-step Sarsa during the throwing cards phase and for true online Sarsa during the pegging phase.
  5. NonLinearB: A Player that represents hands using a non-linear combination of features. These features are then used for episodic semi-gradient one-step Sarsa during the throwing cards phase and for true online Sarsa during the pegging phase.
  6. DeepPeg: A Player that uses two multilayer perceptron regressors to encode Q values: one for pegging and one for throwing cards.
  7. Monty.py: A player that uses first visit Monte Carlo to learn the Q values for different states. A minor modification of QLearner.
  8. Monty2.py: A second player that uses first visit Monte Carlo to learn the Q values for different states. A minor modification of QLearner.

GENERAL FILES

  1. Arena.py: Records performance data for a player over a number of hands. Can be used to produce training curve data or to measure final performance levels.
  2. CriticSessions.py: Allows you to use one agent to critique the decisions of another agent during play.
  3. TrainPegging.py: Trains players on pegging phase of Cribbage.
  4. TrainHand.py: Trains players on a single hand of Cribbage.
  5. TrainingScript.py: Automates the processes of training agents against each other, providing critiques by other agents, and of running round robin tournaments.
  6. Utilities.py: Useful functions that are used throughout the project.

MEMORY FILES

A number of learning agents store parameters in files. These are: throwWeights.npy and pegWeights.npy: LinearB NLBthrowWeights.npy and NLBpegWeights.npy: NonLinearB Brain files in the directory 'BrainsInJars': QLearner, Monty, and Monty2

Dependencies

These files have a number of dependencies on standard python libraries:

  • abc
  • enum
  • math
  • numpy
  • sklearn
  • os
  • joblib
  • warnings
  • itertools
  • matplotlib

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.