mastermind-game
v1.1.3
Published
Play Mastermind in your terminal.
Downloads
32
Readme
mastermind-game
Play Mastermind in your terminal!
Install
To play, you'll need node.js installed. Then, use npm to install:
$ npm i -g mastermind-game
Then, just type this in your terminal:
$ mastermind-game
...and the game will begin!
It looks like this:
$ mastermind-game
Do you want to play a game?
I am thinking of a sequence of 4 numbers between 1 and 6.
Can you guess the sequence?
Please enter your guess: 1 1 2 2
┌─────────┬──────────────────┬────────────────┐
│ Guess │ Correct Position │ Correct Number │
├─────────┼──────────────────┼────────────────┤
│ 1 1 2 2 │ 1 │ 1 │
└─────────┴──────────────────┴────────────────┘
Please enter your guess:
For more information, try mastermind-game -h
or mastermind-game --help
!
Writing Strategies
You can use mastermind-game
as a module and write your own strategies! Install it like so:
npm i -S mastermind-game
Then, sub-class GameForMachines
and implement .guess()
:
const {GameForMachines} = require('mastermind-game')
class MyStrategy extends GameForMachines {
guess (history) {
// write your strategy's logic here!
}
}
Check out GameForMachines for more information on writing strategies.
Tests
Download the project's source in order to run the test suite:
git clone https://github.com/garbados/mastermind-game.git
cd mastermind-game
npm install
npm test
You can run npm run cov
to see a report of test coverage.
Contributing
All contributions are welcome: bug reports, feature requests, "why doesn't this work" questions, patches for fixes and features, etc. For all of the above, file an issue or submit a pull request.