This code is mainly copied from react official website with some refactors. The React website provides a simple tic tac toe and we released the code in release one. Then we did some refactors and provided a gobang and a go game by extending the existing components.
- npm (run) start: open the app locally under eslint
- npm (run) test: run test on src and see the test coverage
- npm run stylefmt: do the style format
- npm run stylelint: do the style lint
Black stone is placed first and then white, and each move one stone is placed. Our game uses "X" to represent black stone and "O" to white.
If a stone or group of stone is surrounded by the opponent or the side of the board on all orthogonally-adjacent points, in other words, losing last liberty, these stones should be removed from board.
The open points that stone bordering are called 'liberty'. Enclosed liberty is referred to as an 'eye'. Generally, single-point eye cannot be filled by opponent stones. For instance,
- Real eye
An eye is enclosed by connected stones. A typical feature is that the eye can only be filled when all group of stones are surrounded by opponent stones.
- False eye
An eye can be filled when part of the enclosed stones are captured(not all).
The difference between real eye and false eye includes whether enclosed stones are all connected or not and whether all enclosed stones can be captured one time or only part of them.
If a stone group has at least two real eyes, it can be considered as alive. Otherwise, it can be considered as dead. In other words, alive stones cannot be captured by all means.
One capture case is forbidden when black and white stone are mutually surrounded and repeat a previous position to fill a false eye to capture a single stone.
For example, first "X" can capture one "O", and then "X" can capture one "O". Then "X" can repeat to capture "O" and vice versa. This will lead to no end.
One special case is Seki. Seki is that both stones do not have enough eyes for life and cannot capture the opponent in the meanwhile. Look at the following example: