Beispiel #1
0
       public override GameState execute(GameState gs)
       {
           Player newFrom = from.removeCard(card);
           Player newTo = to.addCard(card);
           gs = gs.adjustPlayer(newFrom);
           gs = gs.recalcBestCardHolder(gs, newFrom, card.color);
           gs = gs.adjustPlayer(newTo);
           gs = gs.recalcForAddCard(newTo, card);
 
           gs.advanceMove();
           return gs;
       }
Beispiel #2
0
        public override GameState execute(GameState gs)
        {
            Player newFrom = from.removeCard(card);
            Player newTo   = to.addCard(card);

            gs = gs.adjustPlayer(newFrom);
            gs = gs.recalcBestCardHolder(gs, newFrom, card.color);
            gs = gs.adjustPlayer(newTo);
            gs = gs.recalcForAddCard(newTo, card);

            gs.advanceMove();
            return(gs);
        }
Beispiel #3
0
        public GameEngine(Player.Type hType, int difficultyLevel, Boolean allAI)
        {
            //initialize infection and player decks and map
            Map         map   = initializeCities();
            Deck <City> ideck = initializeInfectionDeck(map);

            //initialize player deck

            gs     = new GameState(atlanta, map, 4, 4, ideck, initializePlayerDeck(map));
            gs.map = initializeBoard(map);
            if (!allAI)
            {
                gs.players[0].isAI = false;
            }

            foreach (Player p in gs.players)
            {
                gs = gs.drawPlayerCards(p, 5);
                List <City> drawn = gs.playerDeck.mostRecent(5);
                p.cards.AddRange(drawn);
                gs = gs.adjustPlayer(p);
            }


            List <int> cardLocations = makeEpidemicCards(gs.playerDeck.drawDeck.Count, difficultyLevel);

            for (int i = 0; i < cardLocations.Count; i++)
            {
                cardLocations[i] = cardLocations[i] + gs.playerDeck.cardWeAreOn + 1;
            }

            gs.playerDeck.epidemicCards = cardLocations;
            //ev = new HatesDisease(100);
            ev = new outbreakHater(true);
        }
Beispiel #4
0
        public GameState drawPlayerCards(Player cp, int num = 2)
        {
            GameState newGS = new GameState(this);

            for (int i = 0; i < num; i++)
            {
                if (newGS.playerDeck.isNextCardEpidemic())
                {
                    newGS.epidemicCard();
                    newGS.playerDeck.cardWeAreOn++;
                }
                else
                {
                    newGS.playerDeck = newGS.playerDeck.draw(1);
                    if (newGS.playerDeck.isOverdrawn)
                    {
                        //we just lost
                        return(newGS);
                    }
                    newGS = newGS.adjustPlayer(cp.addCard(newGS.playerDeck.mostRecent(1)[0]));
                    newGS.recalcForAddCard(cp, newGS.playerDeck.mostRecent(1)[0]);
                }
            }

            return(newGS);
        }
Beispiel #5
0
 public override GameState execute(GameState gs)
 {
     //Debug.Assert(debug_gs == null || debug_gs == gs, "Action used on an unintended gamestate");
     Player movedPlayer = new Player(dest, gs.currentPlayer());
     GameState result = gs.adjustPlayer(movedPlayer);
     result.advanceMove();
     return result;
 }
 public override GameState execute(GameState current)
 {
     Player newPlayer = new Player(card, player);
     newPlayer = newPlayer.removeCard(card);
     GameState g = current.adjustPlayer(newPlayer);
     g.advanceMove();
     g = g.recalcBestCardHolder(g, newPlayer, card.color);
     return g;
 }
Beispiel #7
0
        public override GameState execute(GameState gs)
        {
            //Debug.Assert(debug_gs == null || debug_gs == gs, "Action used on an unintended gamestate");
            Player    movedPlayer = new Player(dest, gs.currentPlayer());
            GameState result      = gs.adjustPlayer(movedPlayer);

            result.advanceMove();
            return(result);
        }
Beispiel #8
0
        public override GameState execute(GameState current)
        {
            Player newPlayer = new Player(card, player);

            newPlayer = newPlayer.removeCard(card);
            GameState g = current.adjustPlayer(newPlayer);

            g.advanceMove();
            g = g.recalcBestCardHolder(g, newPlayer, card.color);
            return(g);
        }
Beispiel #9
0
        public override GameState execute(GameState gs)
        {
            Player player       = gs.currentPlayer();
            int    cardsRemoved = 0;

            foreach (City card in player.cards)
            {
                if (cardsRemoved == 5 || (cardsRemoved == 4 && gs.currentPlayer().type == Player.Type.SCIENTIST))
                {
                    break;
                }
                if (color == card.color)
                {
                    player = player.removeCard(card);
                    cardsRemoved++;
                }
            }
            GameState result = gs.cureDisease(color);

            result = result.adjustPlayer(player);
            result.advanceMove();
            result = result.recalcBestCardHolder(result, gs.currentPlayer(), color);
            return(result);
        }
Beispiel #10
0
        public GameEngine(Player.Type hType, int difficultyLevel, Boolean allAI)
        {

            //initialize infection and player decks and map
            Map map = initializeCities();
            Deck<City> ideck = initializeInfectionDeck(map);
            //initialize player deck

            gs = new GameState(atlanta, map, 4, 4, ideck, initializePlayerDeck(map));
            gs.map = initializeBoard(map);
            if (!allAI)
            {
                gs.players[0].isAI = false;
            }

            foreach (Player p in gs.players)
            {
                gs = gs.drawPlayerCards(p, 5);
                List<City> drawn = gs.playerDeck.mostRecent(5);
                p.cards.AddRange(drawn);
                gs = gs.adjustPlayer(p);
            }


            List<int> cardLocations = makeEpidemicCards(gs.playerDeck.drawDeck.Count, difficultyLevel);

            for (int i = 0; i < cardLocations.Count; i++)
            {
                cardLocations[i] = cardLocations[i] + gs.playerDeck.cardWeAreOn + 1;
            }

            gs.playerDeck.epidemicCards = cardLocations;
            //ev = new HatesDisease(100);
            ev = new outbreakHater(true);

        }
        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 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);

        }
Beispiel #14
0
        public GameState drawPlayerCards(Player cp, int num = 2)
        {
            GameState newGS = new GameState(this);
            for (int i = 0; i < num; i++)
            {
                if (newGS.playerDeck.isNextCardEpidemic())
                {

                    newGS.epidemicCard();
                    newGS.playerDeck.cardWeAreOn++;
                }
                else
                {
                    newGS.playerDeck = newGS.playerDeck.draw(1);
                    if (newGS.playerDeck.isOverdrawn)
                    {
                        //we just lost
                        return newGS;
                    }
                    newGS = newGS.adjustPlayer(cp.addCard(newGS.playerDeck.mostRecent(1)[0]));
                    newGS.recalcForAddCard(cp, newGS.playerDeck.mostRecent(1)[0]);
                }
            }
            
            return newGS;
        }