Exemple #1
0
        public void basicClusterHasFourLiberties()
        {
            //arrange
            GoBoard testgame = new GoBoard(5);
            Coordinate location = new Coordinate(3, 3);
            testgame.addPiece(location, Space.Black);
            int expected = 4;

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

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void addSinglePieceToClusterCorrectLiberties()
        {
            //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 simpleCluster = testgame.getClusterContainingCoordinate(loc, Space.Black);

            int expected = 5;

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

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        public void libertyUpdatingForSimpleClustersWorks()
        {
            //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);

            PieceCluster simpleCluster = testgame.getClusterContainingCoordinate(loc, Space.Black);
            int expected = 3;

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

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #6
0
        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);
        }