コード例 #1
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void addSinglePieceToClusterCorrectLiberties()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);

            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            PieceCluster simpleCluster = new PieceCluster(loc, Space.Black, testgame);

            Coordinate loc2 = new Coordinate(4, 2);
            testgame.addPiece(loc2, Space.White);

            Coordinate loc3 = new Coordinate(4, 3);
            testgame.addPiece(loc3, Space.Black);
            simpleCluster.piecesAdd(loc3);
            simpleCluster.removeLiberty(loc3);
            simpleCluster.addLibertiesOf(loc3);

            int expected = 5;

            //act
            int actual = simpleCluster.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void basicClusterHasFourLiberties()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            int expected = 4;

            //act
            PieceCluster simpleCluster = new PieceCluster(loc, Space.Black, testgame);
            int actual = simpleCluster.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void basicClusterContainsSelf()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            bool expected = true;

            //act
            PieceCluster simpleCluster = new PieceCluster(loc, Space.Black, testgame);
            bool actual = simpleCluster.Pieces.Contains(loc);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void basicKoDenial()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            testgame.addPiece(new Coordinate(3, 3), Space.Black);
            testgame.addPiece(new Coordinate(3, 2), Space.White);
            testgame.addPiece(new Coordinate(2, 2), Space.Black);
            testgame.addPiece(new Coordinate(3, 4), Space.White);
            testgame.addPiece(new Coordinate(1, 3), Space.Black);
            testgame.addPiece(new Coordinate(4, 3), Space.White);
            testgame.addPiece(new Coordinate(2, 4), Space.Black);
            testgame.addPiece(new Coordinate(2, 3), Space.White);
            bool expected = false;

            //act
            bool actual = testgame.addPiece(new Coordinate(3, 3), Space.Black);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void enemyNeighborHasLessLiberties()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            Coordinate loc2 = new Coordinate(4,3);
            testgame.addPiece(loc2, Space.White);
            int expected = 3;

            //act
            PieceCluster simpleCluster = new PieceCluster(loc2, Space.White, testgame);
            int actual = simpleCluster.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void libertyUpdatingWithLittleCluster()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);

            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            PieceCluster black1 = new PieceCluster(loc, Space.Black, testgame);

            Coordinate loc2 = new Coordinate(4, 2);
            testgame.addPiece(loc2, Space.White);
            PieceCluster white1 = new PieceCluster(loc2, Space.White, testgame);

            Coordinate loc3 = new Coordinate(4, 3);
            testgame.addPiece(loc3, Space.Black);

            black1.piecesAdd(loc3);
            black1.removeLiberty(loc3);
            black1.addLibertiesOf(loc3);

            white1.removeLiberty(loc3);

            int expected = 3;

            //act
            int actual = white1.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
ファイル: PieceClusterTests.cs プロジェクト: Hdbcoding/GoGame
        public void libertyUpdatingForSimpleClustersWorks()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);

            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);
            PieceCluster simpleCluster = new PieceCluster(loc, Space.Black, testgame);

            Coordinate loc2 = new Coordinate(4, 3);
            testgame.addPiece(loc2, Space.White);
            simpleCluster.removeLiberty(loc2);

            int expected = 3;

            //act

            int actual = simpleCluster.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void BoardCreatesPieceClusters()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            Coordinate location = new Coordinate(3, 3);
            testgame.addPiece(location, Space.Black);
            bool expected = true;

            //act
            PieceCluster thiscluster = testgame.getClusterContainingCoordinate(location, Space.Black);
            bool actual = (thiscluster.Pieces.Contains(location));

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void edgeClusterCapture()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            testgame.addPiece(new Coordinate(3, 3), Space.Black);
            testgame.addPiece(new Coordinate(4, 2), Space.White);
            testgame.addPiece(new Coordinate(4, 3), Space.Black);
            testgame.addPiece(new Coordinate(3, 2), Space.White);
            testgame.addPiece(new Coordinate(2, 2), Space.Black);
            testgame.addPiece(new Coordinate(2, 1), Space.White);
            testgame.addPiece(new Coordinate(3, 1), Space.Black);
            testgame.addPiece(new Coordinate(4, 1), Space.White);
            testgame.addPiece(new Coordinate(5, 2), Space.Black);
            testgame.addPiece(new Coordinate(5, 1), Space.White);
            testgame.addPiece(new Coordinate(3, 1), Space.Black);

            Coordinate location = new Coordinate(4, 1);
            Space expected = Space.Empty;

            //act
            Space actual = testgame.getSpace(location);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void libertyUpdatingWithLittleCluster()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);

            Coordinate loc = new Coordinate(3, 3);
            testgame.addPiece(loc, Space.Black);

            Coordinate loc2 = new Coordinate(4, 2);
            testgame.addPiece(loc2, Space.White);

            Coordinate loc3 = new Coordinate(4, 3);
            testgame.addPiece(loc3, Space.Black);

            PieceCluster white1 = testgame.getClusterContainingCoordinate(loc2, Space.White);

            int expected = 3;

            //act
            int actual = white1.Liberties.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void clusterCombinationLiberties()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            testgame.addPiece(new Coordinate(3, 3), Space.Black);
            testgame.addPiece(new Coordinate(4, 2), Space.White);
            testgame.addPiece(new Coordinate(4, 3), Space.Black);
            testgame.addPiece(new Coordinate(3, 2), Space.White);
            testgame.addPiece(new Coordinate(2, 2), Space.Black);
            testgame.addPiece(new Coordinate(2, 1), Space.White);
            testgame.addPiece(new Coordinate(3, 1), Space.Black);
            testgame.addPiece(new Coordinate(4, 1), Space.White);
            testgame.addPiece(new Coordinate(5, 2), Space.Black);
            testgame.addPiece(new Coordinate(5, 1), Space.White);
            testgame.addPiece(new Coordinate(3, 1), Space.Black);
            testgame.addPiece(new Coordinate(2, 4), Space.White);
            testgame.addPiece(new Coordinate(3, 2), Space.Black);

            Coordinate loc = new Coordinate(3, 2);
            PieceCluster bigCluster = testgame.getClusterContainingCoordinate(loc, Space.Black);
            int expected = 7;

            //act
            int actual = bigCluster.Liberties.Count();

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void CantOverlapPieces()
        {
            //arrange
            GoBoard testgame = new GoBoard();
            Coordinate location = new Coordinate(1, 1);
            bool expected = false;

            //act
            testgame.addPiece(location, Space.Black);
            bool actual = testgame.addPiece(location, Space.White);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void CantAddOutOfBounds()
        {
            //arrange
            GoBoard testgame = new GoBoard();
            Coordinate location = new Coordinate(0, 0);
            bool expected = false;

            //act
            bool actual = testgame.addPiece(location, Space.Black);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void CantAddForbiddenPieces()
        {
            //arrange
            GoBoard testgame = new GoBoard();
            Coordinate location = new Coordinate(1, 1);
            bool expected = false;

            //act
            bool actual = testgame.addPiece(location, Space.Forbidden);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #15
0
ファイル: GoBoardTests.cs プロジェクト: Hdbcoding/GoGame
        public void CantAddBlackSecond()
        {
            //arrange
            GoBoard testgame = new GoBoard();
            Coordinate locationa = new Coordinate(1, 1);
            Coordinate locationb = new Coordinate(1, 2);
            bool expected = false;
            //act
            testgame.addPiece(locationa, Space.Black);
            bool actual = testgame.addPiece(locationb, Space.Black);

            //assert
            Assert.AreEqual(expected, actual);
        }