// play the picked cards bool PlayCards(AIPick pick) { int ind1 = pick.Index(0); int ind2 = pick.Index(1); MemoryCard card1 = GameCards[ind1]; MemoryCard card2 = GameCards[ind2]; // if the values are equal, current player scores and plays again if (card1.Value == card2.Value) { // both cards are set as "played" card1.Played = true; card2.Played = true; AIDebug.PlayLog("SCORE (" + card1.Value + ") " + card1.Index + "-" + card2.Index); CurrentPlayer.Score += 2; return(true); } AIDebug.PlayLog("MISS " + card1.Index + "(" + card1.Value + ") " + card2.Index + "(" + card2.Value + ") "); CurrentPlayer.MemorizeSelf(card1, card2); OtherPlayer.MemorizeOther(card1, card2); // the cards are not equal, player passes the turn return(false); }
// pick a random set of cards AIPick PickRandom() { if (AvailableCards == null) { FindAvailableCards(); } AIDebug.PlayLog(CurrentPlayer.Name + " is picking random cards"); AIPick pick = new AIPick(); pick.Set(0, GetRandomAvailable()); pick.Set(1, CurrentPlayer.FindMatch(GameCards[pick.Index(0)])); if (pick.Index(1) == -1) { pick.Set(1, GetRandomAvailable()); } return(pick); }