public void TestmedSmartAi()
        {
            City newyork = map.addCity("ny", DiseaseColor.BLUE);
            City atl = map.addCity("atl", DiseaseColor.BLUE);
            City washington = map.addCity("washington", DiseaseColor.BLUE);
            City chicago = map.addCity("chicago", DiseaseColor.BLUE);


            City.makeAdjacent(newyork, atl);
            City.makeAdjacent(atl, washington);
            City.makeAdjacent(washington, chicago);
            //ny-->atl-->washington-->chicago

            map = map.addDisease(newyork, 3);


            gs = new GameState(newyork, map, 2);

            Player p1 = gs.currentPlayer();
            gs = gs.adjustPlayer(p1);
            gs = gs.setTurnAction(new DoNothingTurnAction());
            SearchEvaluate noOutbreaks = new outbreakHater(true);

            List<Action> foo = new List<Action>();
            Action q = new CureCityAction(newyork, newyork.color);
            GameState cured = q.execute(gs);
            float eval = outbreakHater.evalGame(cured);
            Action action = noOutbreaks.bfs_findbest(gs, 1);
            GameState newGS = action.execute(gs);
            float eval2 = outbreakHater.evalGame(newGS);
            Assert.AreEqual(2, newGS.map.diseaseLevel(newyork, newyork.color));
            //Assert.AreEqual(1, gs.map.aboutToOutbreak.Count());



            //testing adding + removin disease from about to outbreak list
            newGS.map = newGS.map.addDisease(chicago, 3);

            Assert.AreEqual(1, gs.map.aboutToOutbreak.Count());

            newGS.map = newGS.map.removeDisease(chicago, chicago.color);

            Assert.AreEqual(1, gs.map.aboutToOutbreak.Count());

            newGS.map = newGS.map.removeDisease(chicago, chicago.color);
            Assert.AreEqual(1, gs.map.aboutToOutbreak.Count());
            Assert.AreEqual(0, gs.map.diseaseLevel(chicago, chicago.color));
        }
 public void TestMakeStationAction()
 {
     gs = new GameState(newyork, map, 2, 1);
     Player p1 = gs.currentPlayer();
     Player p1wCard = p1.addCard(newyork);
     gs = gs.adjustPlayer(p1wCard);
     gs = gs.setTurnAction(new DoNothingTurnAction());
     SearchEvaluate likesStations = new LikesStations(1);
     List<Action> foo = gs.availableActions();
     Action action = likesStations.bfs_findbest(gs, 1);
     GameState newGS = action.execute(gs);
     Assert.AreEqual(0, newGS.players[1].cards.Count);
     // Assert.AreEqual(0, newGS.players[1].cards.Count);
     Assert.AreEqual(true, newGS.map.hasStation(newyork));
 }
 public void TestTwoPlayers()
 {
     City atlanta = map.addCity("Atlanta", DiseaseColor.BLUE);
     City.makeAdjacent(newyork, atlanta);
     map = map.addDisease(newark);
     map = map.addDisease(atlanta);
     gs = new GameState(newyork, map, 2, 2);
     gs = gs.setTurnAction(new DoNothingTurnAction());
     SearchEvaluate hatesDisease = new HatesDisease(2);
     GameState newGS = doSteps(gs, hatesDisease, 5, 5);
     Assert.AreEqual(0, HatesDisease.getTotalDisease(newGS));
 }
        public void TestTrade()
        {
            gs = new GameState(newyork, map, 2, 1);
            Player p1 = gs.currentPlayer();
            Player p1wCard = p1.addCard(newyork);
            gs = gs.adjustPlayer(p1wCard);
            gs = gs.setTurnAction(new DoNothingTurnAction());
            SearchEvaluate likesCards = new LikesCards(1);
            List<Action> foo = gs.availableActions();
            Action action = likesCards.bfs_findbest(gs, 1);
            GameState newGS = action.execute(gs);
            Assert.AreEqual(0, newGS.players[0].cards.Count);
            Assert.AreEqual(1, newGS.players[1].cards.Count);

            gs = new GameState(newyork, map, 2, 1);
            p1 = gs.currentPlayer();
            p1wCard = p1.addCard(newark);
            gs = gs.adjustPlayer(p1wCard);
            gs = gs.setTurnAction(new DoNothingTurnAction());
            action = likesCards.bfs_findbest(gs, 5);
            newGS = action.execute(gs);
            Assert.AreEqual(1, newGS.players[0].cards.Count);
            Assert.AreEqual(0, newGS.players[1].cards.Count);
            newGS = doSteps(newGS, likesCards, 4, 5);
            Assert.AreEqual(0, newGS.players[0].cards.Count);
            Assert.AreEqual(0, newGS.players[1].cards.Count);

        }
Example #5
0
        public void currentPlayerTest()
        {
            //3 players
            gs = new GameState(atlanta, map, 3, 1);
            gs = gs.setTurnAction(new DoNothingTurnAction());

            Player startPlayer = gs.currentPlayer();
            Action someAction = gs.availableActions()[0];
            GameState newGS = someAction.execute(gs);
            Assert.AreEqual(1, newGS.availableActions().Count);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreNotEqual(startPlayer.playernum, newGS.currentPlayer().playernum);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreEqual(1, newGS.availableActions().Count);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);

            Assert.AreNotEqual(startPlayer.playernum, newGS.currentPlayer().playernum);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreEqual(1, newGS.availableActions().Count);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreEqual(startPlayer.playernum, newGS.currentPlayer().playernum);

            //2 moves per player
            gs = new GameState(atlanta, map, 2, 2);
            gs = gs.setTurnAction(new DoNothingTurnAction());
            startPlayer = gs.currentPlayer();
            someAction = gs.availableActions()[0];
            newGS = someAction.execute(gs);
            Assert.AreEqual(startPlayer.playernum, newGS.currentPlayer().playernum);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreEqual(1, newGS.availableActions().Count);
            someAction = newGS.availableActions()[0];
            newGS = someAction.execute(newGS);
            Assert.AreNotEqual(startPlayer.playernum, newGS.currentPlayer().playernum);

        }