private Card SetStrategy(PlayerState p, List<Card> hand) { Card bestCard = null; int currentAge = ResourceManager.GetInstance().getGameState().getAge(); if (p.getPlayedCards().Count() == 0) bestCard = BuildWonder(p, hand); if (bestCard == null) if (noOfPlayers == 3 || noOfPlayers == 7) if (p.getBoard().getCurrentWonderLevel() != currentAge) bestCard = BuildWonder(p, hand); if (bestCard == null) SetMilitaryStrategy(p, hand); if (bestCard == null) bestCard = SetScienceStrategy(p, hand); if (bestCard == null) bestCard = SetCommerceStrategy(p, hand); if (bestCard == null) bestCard = SetCivilianStrategy(p, hand); if (bestCard == null) { strategy = new RandomStrategy(); bestCard = strategy.getNextCard(p, hand); } return bestCard; }
public Card discardCard(PlayerState p, List<Card> hand) { for (int i = 0; i < hand.Count(); i++) { if (hand[i].getType() == 3) return hand[i]; } for (int i = 0; i < hand.Count(); i++) { if (hand[i].getType() == 4) return hand[i]; } for (int i = 0; i < hand.Count(); i++) { if ( hand[i].getType() == 1 || hand[i].getType() == 2) return hand[i]; } Random r = new Random(); int index = r.Next(0, hand.Count); return hand[index]; }
public Card getNextCard(PlayerState p, List<Card> hand) { Card cur = ult.playPrimary(p, hand); if (cur != null) { return cur; } if(((p.getBoard().getName().Equals("WB1")) || (p.getBoard().getName().Equals("WB1")) && (p.getBoard().getCurrentWonderLevel() == 2))){ cur = ult.buildWonder(p, hand); if (cur != null) { return cur; } } cur = ult.playSecondary(p, hand); if (cur != null) { return cur; } cur = ult.buildWonder(p, hand); if (cur != null) { return cur; } return ult.playAnyCard(p, hand); }
public Card getNextCard(PlayerState p, List<Card> hand) { noOfPlayers = ResourceManager.GetInstance().getGameState().getPlayers().Count(); Card c = SetStrategy(p, hand); Console.WriteLine("[{0}] [{1}]", "Adaptive Strategy", strategy.Name()); return c; }
public void CheckingCoins(PlayerState p, Card c) { if (Log(p)) Console.WriteLine("[{0}] Checking to see if we have enough coins: Cost {1} Has {2}" , _class.GetType().Name , c.getCoinCost() , p.getCoins()); }
protected List<ResourceCard> SRCardInitializer(PlayerState p) { List<ResourceCard> tempList = new List<ResourceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() > 7) && (p.getPlayedCards()[i].getNumber() < 14)) { tempList.Add((ResourceCard)p.getPlayedCards()[i]); } } return tempList; }
private Card SetScienceStrategy(PlayerState p, List<Card> hand) { if (noOfPlayers == 5 || noOfPlayers == 7) if (hand.Count() > 3) { strategy = new ScienceStrategy(); return strategy.getNextCard(p, hand); } return null; }
public PlayerState getRightPlayer(PlayerState p) { if (p.getSeatNumber() == (players.Count-1)) { return this.players[0];//first player } else { return this.players[(p.getSeatNumber() + 1)]; } }
private Card SetCivilianStrategy(PlayerState p, List<Card> hand) { for (int i = 0; i < hand.Count(); i++) { if (noOfPlayers == 3 || noOfPlayers == 7) if (hand[i].getName() == "C22" || hand[i].getName() == "C23" || hand[i].getName() == "C63" || hand[i].getName() == "C64") if (ResourceManager.GetInstance().ValidateCard(p, hand[i])) { strategy = new CivilianStrategy(); p.addPlayedCards(hand[i]); return hand[i]; } if (noOfPlayers == 3 || noOfPlayers == 6) if (hand[i].getName() == "C24" || hand[i].getName() == "C25" || hand[i].getName() == "C108" || hand[i].getName() == "C109") if (ResourceManager.GetInstance().ValidateCard(p, hand[i])) { strategy = new CivilianStrategy(); p.addPlayedCards(hand[i]); return hand[i]; } } int vc = 0, index = 0; for (int i = 0; i < hand.Count(); i++) { if (hand[i] is CivilianCard) { CivilianCard c = (CivilianCard)hand[i]; if (c.getVictoryPoints() > vc) { vc = c.getVictoryPoints(); index = i; } } } if (index != 0) if (ResourceManager.GetInstance().ValidateCard(p, hand[index])) { strategy = new CivilianStrategy(); p.addPlayedCards(hand[index]); return hand[index]; } return null; }
public ResourceBuying(Resources res, Card c, PlayerGameBoard p) { rc = res; card = c; board = p; you = rm.getGameState().getPlayerNum(rc.getPlayerName()[1]); InitializeComponent(); createButtons(); createValueFields(); }
public int countCardType(int cType, PlayerState pState) { int count = 0; foreach (Card cCard in pState.getPlayedCards()) { if (cCard.getType() == cType) { count++; } } return count; }
public PlayerState getLeftPlayer(PlayerState p) { if (p == null) { Console.WriteLine("Snap: PlayerState is null"); } if (p.getSeatNumber() == 0) { return this.players[players.Count-1];//last player } else { return this.players[(p.getSeatNumber()-1)]; } }
public WonderBuyingWindow(Resources res, Card c, PlayerGameBoard p, GameState g) { resources = res; card = c; board = p; game = g; manager = ResourceManager.GetInstance(); you = manager.getGameState().getPlayerNum(resources.getPlayerName()[1]); InitializeComponent(); createButtons(); createValueFields(); }
public bool ValidateCard (PlayerState p, Card c) { //_logger.ValidatingCard(p, c); //_logger.CheckDictionary(p,hashtable); //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] < 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } // First check what the coin costs and total resource cost are if (c.getCoinCost() == 0 && c.getTotalResourceCost() == 0) { //_logger.print(p,"Card dosn't cost anything"); UpdateResources(p, c); return true; } // If the coin cost is not equal to 0 then does the player have enoguh coins ? if (c.getCoinCost() != 0 && c.getTotalResourceCost() == 0) { //_logger.CheckingCoins(p, c); if (c.getCoinCost() <= p.getCoins()) { UpdateResources(p, c); p.updateCoins(-c.getCoinCost()); // _logger.CheckingPlayersCoins(p); return true; } return false; } if (c.getTotalResourceCost() != 0) { //_logger.print(p,"Now we are working on the players Resources"); return CheckResourceCost(p,c); } return false; }
public Card getNextCard(PlayerState p, List<Card> hand) { Card cur = ult.playPrimary(p, hand); if (cur != null) { return cur; } //attempts to play wonder to increase science if((p.getBoard().getName().Equals("WB3")) && (p.getBoard().getCurrentWonderLevel() < 2) && (ResourceManager.GetInstance().ValidateWonder(p))){ for (int i = 0; i < hand.Count; i++){ if(hand[i].getType() != 6){ p.setWonderCards(hand[i]); p.getBoard().incrementWonderLevel(p); return hand[i]; } } } if((p.getBoard().getName().Equals("WB4")) && (p.getBoard().getCurrentWonderLevel() < 3) && (ResourceManager.GetInstance().ValidateWonder(p))){ for (int i = 0; i < hand.Count; i++){ if(hand[i].getType() != 6){ p.setWonderCards(hand[i]); p.getBoard().incrementWonderLevel(p); return hand[i]; } } } cur = ult.playSecondary(p, hand); if (cur != null) { return cur; } cur = ult.buildWonder(p, hand); if (cur != null) { return cur; } return ult.playAnyCard(p, hand); }
//attempts to build a wonder public Card buildWonder(PlayerState p, List<Card> hand) { if (ResourceManager.GetInstance().ValidateWonder(p)) { for (int i = 0; i < hand.Count; i++) { if (hand[i].getType() == strategy) { p.setWonderCards(hand[i]); p.getBoard().incrementWonderLevel(p); return hand[i]; } } return hand[0]; } return null; }
private int civScore(PlayerState p) { List<CivilianCard> civlist; //Civilian Structures civlist = new List<CivilianCard>(); int score = 0; //Cycle through played cards //Add all civilian cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 3) { civlist.Add((CivilianCard)p.getPlayedCards()[i]); } } //Cycle through civ card list to add points for (int i = 0; i < civlist.Count; i++) { score = score + civlist[i].getVictoryPoints(); } return score; }
//Base Constructor, Needs GameState and PlayerState protected resourceChecks(GameState g, PlayerState p) { //coinTransactions = new int[3]{0,0,0}; //Getting left and right player of player P left = g.getLeftPlayer(p); right = g.getRightPlayer(p); //Initialize base resources baseResources = ResourceInitializer(p); lResources = ResourceInitializer(left); rResources = ResourceInitializer(right); //List of important resource cards SRCardLst = SRCardInitializer(p); lSRCardLst = SRCardInitializer(left); rSRCardLst = SRCardInitializer(right); }
public ResourceBuying(Resources res, Card c, PlayerGameBoard p, GameState g) { resources = res; //Console.WriteLine(resources.ToString()); card = c; board = p; game = g; manager = ResourceManager.GetInstance(); you = manager.getGameState().getPlayerNum(resources.getPlayerName()[1]); InitializeComponent(); createButtons(); createValueFields(); }
// public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: victoryPoints = 3; return; case 2: p.updateCoins(9); break; case 3: victoryPoints = 10; break; } } }
//public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: victoryPoints = 3; break; case 2: freeBuild = true; break; case 3: victoryPoints = 10; break; } } }
//public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: victoryPoints = 3; return; case 2: resources = new int[7] {1,1,1,1,1,0,0}; break; case 3: victoryPoints = 10; break; } } }
/* * Input: A Player and a Card * * * Output: True or False -> Can the player play this card for free? If they have correct pre-card -> True */ private bool preCardCheck(PlayerState p, Card c) { //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] < 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } return false; }
//public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: victoryPoints = 3; return; case 2: doubleCard = true; break; case 3: scienceActivated = true; break; } } }
//public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: p.updateMilitaryPower(1); victoryPoints = 3; p.updateCoins(3); return; case 2: p.updateMilitaryPower(1); victoryPoints = 7; p.updateCoins(4); break; } } }
public Card getNextCard(PlayerState p, List<Card> hand) { strategy = new MilitaryStrategy(); Card c = strategy.getNextCard(p, hand); if (c == null) { strategy = new ScienceStrategy(); c = strategy.getNextCard(p,hand); } if (c == null) { strategy = new CommerceStrategy(); c = strategy.getNextCard(p, hand); } return c; }
//public int[] getResources() { return resources; } public override void incrementWonderLevel(PlayerState p) { if(notMaxYet()){ currentWonderLevel++; switch (currentWonderLevel) { case 1: resourceTrade = true; break; case 2: victoryPoints = 5; break; case 3: copyGuildCard = true; break; } } }
//preCardCheck checks if the player p has the prerequisite card for free play protected bool preCardCheck(Card c, PlayerState p) { //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards console.writeline(preCard[0] + " " + preCard[1] + " " + preCard[2] + " " + preCard[3]); for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] > 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } //else return false return false; }
private int sciScore(PlayerState p) { List<ScienceCard> scilist; scilist = new List<ScienceCard>(); int score = 0; //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 3) { scilist.Add((ScienceCard)p.getPlayedCards()[i]); } } //Cycle through science card list to add up sciencetype totals int[] sciTotals = new int[3] { 0, 0, 0 }; for (int i = 0; i < scilist.Count; i++) { sciTotals[scilist[i].getSciType()]++; } //Set points score = score + (sciTotals.Min() * 7); //Points for types score = score + (sciTotals[0] * sciTotals[0]); score = score + (sciTotals[1] * sciTotals[1]); score = score + (sciTotals[2] * sciTotals[2]); return score; }
private int comScore(PlayerState p) { int score = 0; List<CommerceCard> comlist; //Commercial Structure comlist = new List<CommerceCard>(); //Cycle through played cards //Add all Commerce cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getType() == 4) && (p.getPlayedCards()[i].getAct() == 3)) { comlist.Add((CommerceCard)p.getPlayedCards()[i]); } } for (int i = 0; i < comlist.Count; i++){ //Victorypoints per wonder if (comlist[i].getPerWonder() == 2) { score = score + p.getBoard().getCurrentWonderLevel(); } //Victorypoint per card if((comlist[i].getCollect()[2] > 0)){ //crawl through all played cards of player for (int j = 0; j < p.getPlayedCards().Count; j++) { //if card type matches victorypoint condition of commercial card if (p.getPlayedCards()[j].getType() == comlist[i].getCollect()[0]) { //add points appropriate to commercial card parameters score = score + comlist[i].getCollect()[2]; } } } } return score; //Guilds }