Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();

            SetClientSizeCore(CellSize * BoardSize, CellSize * BoardSize);
            Board = new Board(BoardSize);
            Logic = new SimpleLogic(Board, GameSize);
        }
Esempio n. 2
0
 public Logic(Board board, int gameSize)
 {
     if(board == null)
         throw new ArgumentNullException();
     if(gameSize < 2)
         throw new ArgumentException();
     this.board = board;
     this.gameSize = gameSize;
 }
Esempio n. 3
0
        public void EstimateForStageThree()
        {
            var board = new Board(5);
            var logic = new SimpleLogic(board, 3);

            var estimateCenter = logic.EstimateForStageThree(2, 2, CellState.None);
            var estimate11 = logic.EstimateForStageThree(1, 1, CellState.None);
            var estimate00 = logic.EstimateForStageThree(0, 0, CellState.None);

            Assert.Less(estimate11, estimateCenter);
            Assert.Less(estimate00, estimate11);
        }
Esempio n. 4
0
        public void GetStone()
        {
            Board board = new Board(3);

            board.PutStone(CellState.Black, 1, 1);
            board.PutStone(CellState.White, 2, 2);

            Assert.AreEqual(CellState.None, board.GetStone(0, 0));
            Assert.AreEqual(CellState.Black, board.GetStone(1, 1));
            Assert.AreEqual(CellState.White, board.GetStone(2, 2));
            Assert.AreEqual(CellState.None, board.GetStone(-1, -1));
        }
Esempio n. 5
0
        public void FilterCellsStageOne()
        {
            var board = new Board(4);
            var logic = new SimpleLogic(board, 4);

            board.PutStone(CellState.White, 3, 0);
            board.PutStone(CellState.White, 0, 3);

            var filteredCells = logic.FilterCellsStageOne(CellState.White);

            Assert.AreEqual(6, filteredCells.Count);
            Assert.IsFalse(filteredCells.Contains(new Point(0, 0)));
            Assert.IsTrue(filteredCells.Contains(new Point(2, 0)));
            Assert.IsTrue(filteredCells.Contains(new Point(1, 2)));
            Assert.IsFalse(filteredCells.Contains(new Point(2, 3)));
        }
Esempio n. 6
0
        public void EstimateForStageTwo()
        {
            var board = new Board(3);
            var logic = new SimpleLogic(board, 3);

            board.PutStone(CellState.White, 0, 0);
            board.PutStone(CellState.White, 1, 2);
            board.PutStone(CellState.Black, 2, 0);

            Assert.AreEqual(3, logic.EstimateForStageTwo(1, 0, CellState.White));
            Assert.AreEqual(4, logic.EstimateForStageTwo(0, 1, CellState.White));
            Assert.AreEqual(5, logic.EstimateForStageTwo(1, 1, CellState.White));
            Assert.AreEqual(3, logic.EstimateForStageTwo(2, 1, CellState.White));
            Assert.AreEqual(2, logic.EstimateForStageTwo(0, 2, CellState.White));
            Assert.AreEqual(2, logic.EstimateForStageTwo(2, 2, CellState.White));
        }
Esempio n. 7
0
        public void IsOutside()
        {
            Board b = new Board(3);

            // Outside bounds
            Assert.IsTrue(b.IsOutside(1, -1));
            Assert.IsTrue(b.IsOutside(3, 1));
            Assert.IsTrue(b.IsOutside(1, 3));
            Assert.IsTrue(b.IsOutside(-1, 1));

            // Inside bounds
            Assert.IsFalse(b.IsOutside(0, 0));
            Assert.IsFalse(b.IsOutside(2, 2));

            Assert.IsFalse(b.IsOutside(1, 1));
        }
Esempio n. 8
0
        public void EstimateForStageOne()
        {
            var board = new Board(3);
            var logic = new SimpleLogic(board, 3);

            board.PutStone(CellState.Black, 2, 0);
            board.PutStone(CellState.White, 0, 1);
            board.PutStone(CellState.White, 0, 2);

            Assert.AreEqual(3, logic.EstimateForStageOne(0, 0, CellState.Black));
            Assert.AreEqual(2, logic.EstimateForStageOne(1, 0, CellState.Black));
            Assert.AreEqual(2, logic.EstimateForStageOne(1, 1, CellState.Black));
            Assert.AreEqual(2, logic.EstimateForStageOne(2, 1, CellState.Black));
            Assert.AreEqual(2, logic.EstimateForStageOne(1, 2, CellState.Black));
            Assert.AreEqual(1, logic.EstimateForStageOne(2, 2, CellState.Black));

            Assert.AreEqual(int.MaxValue, logic.EstimateForStageOne(0, 0, CellState.White));
        }
Esempio n. 9
0
        public void HaveVictoryAt()
        {
            Board board = new Board(5);
            board.PutStone(CellState.Black, 0, 2);
            board.PutStone(CellState.White, 1, 2);
            board.PutStone(CellState.White, 3, 2);

            Logic logic = new LogicStub(board, 5);

            Assert.IsFalse(logic.HaveVictoryAt(2, 2, CellState.White));

            board.PutStone(CellState.White, 4, 2);
            Assert.IsFalse(logic.HaveVictoryAt(2, 2, CellState.White));

            board.PutStone(CellState.White, 0, 2);
            Assert.IsFalse(logic.HaveVictoryAt(2, 2, CellState.White));

            board.PutStone(CellState.White, 2, 2);
            Assert.IsTrue(logic.HaveVictoryAt(2, 2, CellState.White));
            Assert.IsFalse(logic.HaveVictoryAt(2, 1, CellState.White));
            Assert.IsFalse(logic.HaveVictoryAt(2, 2, CellState.Black));
        }
Esempio n. 10
0
 public DumbLogic(Board board, int gameSize)
     : base(board, gameSize)
 {
 }
Esempio n. 11
0
        public void FilterCellsStageOne_Victory()
        {
            var board = new Board(3);
            var logic = new SimpleLogic(board, 3);

            board.PutStone(CellState.White, 0, 1);
            board.PutStone(CellState.White, 0, 2);
            board.PutStone(CellState.Black, 2, 1);
            board.PutStone(CellState.Black, 2, 2);

            var bestWhite = logic.FilterCellsStageOne(CellState.White);
            var bestBlack = logic.FilterCellsStageOne(CellState.Black);

            Assert.AreEqual(1, bestWhite.Count);
            Assert.AreEqual(1, bestBlack.Count);
        }
Esempio n. 12
0
 public SimpleLogic(Board board, int gameSize)
     : base(board, gameSize)
 {
 }
Esempio n. 13
0
 public LogicStub(Board board, int gameSize)
     : base(board, gameSize)
 {
 }