/tictactoe

Primary LanguageCSS

TicTacToe

Build Status

A TicTacToe game using ReactJS and Rails

A little bit of math

I use a matrix of powers of two to determine a winner:

  1   2   4
  8   16  32
  64  128 256

If the Bitwise-AND of any special winner numbers and players sum is the winner number then this player is the winner of the game.

A special winner number is just a sum of horizontal, vertical, or diagonal rows — the condition to win TicTacToe game.

Page structure (react components)

- TicTacToe
  - GameField
    - CurrentPlayer
    - Matrix
      - Cells
    - PlayersForm
    - Winner
  - Leaderbord

Development tools

Database

Application uses sqlite 3 as a database

rake db:create
rake db:schema:load

Server

bin/rails s

Tests

bin/rspec