using System.Collections.Generic;
public enum Piece {empty, white, black}
public Board CopyBoard () {
Board newBoard = new Board();
newBoard.pieces = pieces;
newBoard.blacksTurn = blacksTurn;
public List<Board> boards;
public static bool gameFinished;
public static void Main()
GameHistory history = new GameHistory();
history.boards = new List<Board>();
Board board = new Board ();
board.pieces = new Piece[8,8];
board.pieces[4,4] = Piece.black;
board.pieces[4,3] = Piece.black;
board.pieces[3,3] = Piece.white;
board.pieces[3,4] = Piece.white;
int inputX = int.Parse (Console.ReadLine());
int inputY = int.Parse (Console.ReadLine());
if (GameRules.IsMoveLegal(board, inputX, inputY)) {
GameRules.MakeMove(board, inputX, inputY);
Board currentBoardCopy = board.CopyBoard();
history.boards.Add(currentBoardCopy);
Console.Write( "Illegal move!");
public static void DisplayBoard ( Board board ) {
for (int x=0; x<8; x++) {
for (int y=0; y<8; y++) {
display += PieceToChar ( board.pieces[x,y] );
public static char PieceToChar ( Piece piece ) {
if (piece == Piece.white) return 'W';
if (piece == Piece.black) return 'B';
public static class GameRules
public static bool IsMoveLegal ( Board board, int x, int y )
Piece oppositeStone = Piece.black;
if (board.blacksTurn) oppositeStone = Piece.white;
if (board.pieces[x,y] != Piece.empty)
private static bool CheckDirectionCapture ( Board board, int moveX, int moveY, int dirX, int dirY )
if (IsWithinBoard (moveX+dirX, moveY+dirY) == false) return false;
Piece ourStone = Piece.white;
Piece oppositeStone = Piece.black;
if (board.blacksTurn) ourStone = Piece.black;
if (board.blacksTurn) oppositeStone = Piece.white;
bool neighborIsOpposite = false;
if ( board.pieces[moveX+dirX, moveY+dirY] == oppositeStone )
neighborIsOpposite = true;
bool ourStoneExists = false;
while ( IsWithinBoard (x, y) )
if ( board.pieces [x,y] == ourStone )
if ( board.pieces [x,y] == Piece.empty )
if (neighborIsOpposite && ourStoneExists)
private static bool IsWithinBoard ( int x, int y )
if (x > 7 || x < 0 || y > 7 || y < 0)
public static void MakeMove ( Board board, int x, int y )
if (board.blacksTurn) board.pieces[x, y] = Piece.black;
else board.pieces[x, y] = Piece.white;
board.blacksTurn = !board.blacksTurn;