コード例 #1
0
ファイル: TestSearchEvaluate.cs プロジェクト: hewner/pandemic
        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));
        }
コード例 #2
0
ファイル: ActionTests.cs プロジェクト: hewner/pandemic
        public void cureExecuteTest()
        {
            Map  map     = new Map();
            City atlanta = map.addCity("Atlanta", DiseaseColor.BLUE);
            City newyork = map.addCity("NewYork", DiseaseColor.BLUE);

            City.makeAdjacent(atlanta, newyork);
            map = map.addDisease(atlanta);
            GameState      gs     = new GameState(atlanta, map);
            CureCityAction action = new CureCityAction(atlanta, DiseaseColor.BLUE);
            GameState      newGs  = action.execute(gs);

            Assert.AreEqual(1, gs.map.diseaseLevel(atlanta, DiseaseColor.BLUE));
            Assert.AreEqual(atlanta, newGs.currentPlayer().position);
            Assert.AreEqual(0, newGs.map.diseaseLevel(atlanta, DiseaseColor.BLUE));
        }