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.
http-server
from root directory. That's it.
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.
Shared files (between browser and Node) can be found in the /src
directory. Build the bundle for browser with browserify.
yarn build
- Adventurer
- Bureaucrat
- Cellar
- Chancellor
- Chapel
- Council Room
- Feast
- Festival
- Gardens
- Laboratory
- Library
- Market
- Mine
- Moneylender
- Remodel
- Smithy
- Spy
- Thief
- Village
- Witch
- Woodcutter
- Workshop
- Moat
- Militia
- Throne Room
See initCards
function in src/game.js
.
I hand-coded a few AI strategies to test against the human opponent. Descriptions below. You can find the code in player-strategies.js
.
Each turn, buy a province if you can afford it. Otherwise, buy gold or silver. If cannot afford either of those, buy nothing.
Same as "Big Money", but buy Duchies near the end.
- 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
???
???
yarn install
yarn lint
yarn test
- play dominion against computer opponent(s)
- simulate strategies over large number of iterations to see their effectiveness
- written in JavaScript, with Angular framework and Bootstrap for prettiness
- uses Underscore library for shuffling cards (Fisher-Yates shuffle)