A React implementation of Tic Tac Toe for one or two players.
It uses a Monte Carlo simulation to power the AI in single-player mode.
Live demo: negomi.github.io/react-tic-tac-toe
To build the examples locally, run:
npm install
npm start
Then open localhost:8080/webpack-dev-server/
in a browser.
To run the tests with a watcher, run:
npm test
Then open localhost:8000/webpack-dev-server/test/
in a browser.
Requires React 0.14
The easiest way to use react-tic-tac-toe is to install it from npm and include it in your own React build process (using Browserify, Webpack, etc).
You can also use the standalone build by including dist/TicTacToe.js
or dist/TicTacToe.min.js
in your page. If you use this, make sure you have already included React, and that it is available as a global variable.
npm install react-tic-tac-toe --save
var TicTacToe = require('react-tic-tac-toe');
ReactDOM.render(<TicTacToe width={ 3 } singlePlayer />, document.getElementById('app'));
Property | Type | Default | Function |
---|---|---|---|
singlePlayer |
boolean |
false |
Specify this flag to trigger single-player mode |
width |
number |
3 |
Determines the size of the board |