Git Product home page Git Product logo

dominion's Introduction

Dominion

A bare-bones simulator and visualizer for the card game Dominion in JavaScript. Simulator can be run headless from command-line with node.js or in the browser. Visualization powered by React.

Currently only supports standard cards. Card descriptions can be found here.

Run

Browser

http-server from root directory. That's it.

Command Line

The simulation can be run headless from the command line. Run

ts-node cli.js

The --help flag will give you available options.

To run the visualization, start up a web server from this directory, for example run http-server. See building instructions on building the bundle first.

Building

Shared files (between browser and Node) can be found in the /src directory. Build the bundle for browser with browserify.

yarn build

Supported Cards

  • Adventurer
  • Bureaucrat
  • Cellar
  • Chancellor
  • Chapel
  • Council Room
  • Feast
  • Festival
  • Gardens
  • Laboratory
  • Library
  • Market
  • Mine
  • Moneylender
  • Remodel
  • Smithy
  • Spy
  • Thief
  • Village
  • Witch
  • Woodcutter
  • Workshop

Unsupported Cards

  • Moat
  • Militia
  • Throne Room

Adding New Cards

See initCards function in src/game.js.

Strategies

I hand-coded a few AI strategies to test against the human opponent. Descriptions below. You can find the code in player-strategies.js.

Big Money

Each turn, buy a province if you can afford it. Otherwise, buy gold or silver. If cannot afford either of those, buy nothing.

Smart Big Money

Same as "Big Money", but buy Duchies near the end.

Smart Duchy

  • always go for province when you have 8
  • always go for duchy when you have 5
  • always go for smithy when you have 4
  • always go for silver when you have 3
  • go for gold when you have 6, if there are 4 or more provinces

Smart Smithy

???

Big Money Smithy

???

Lint & Test

yarn install
yarn lint
yarn test

Uses

  • play dominion against computer opponent(s)
  • simulate strategies over large number of iterations to see their effectiveness

Implementation Details

  • written in JavaScript, with Angular framework and Bootstrap for prettiness
  • uses Underscore library for shuffling cards (Fisher-Yates shuffle)

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.