// the current player plays a turn bool Turn() { AIDebug.PlayLog("------------------------------"); AIDebug.PlayLog(CurrentPlayer.Name + "'s Turn"); float T2 = Time.realtimeSinceStartup; AIPick pick = PickMemory(); AIDebug.PlayLog("PICK MEMORY: " + (Time.realtimeSinceStartup - T2)); if (pick == null) { float T3 = Time.realtimeSinceStartup; pick = PickRandom(); AIDebug.PlayLog("PICK RAND: " + (Time.realtimeSinceStartup - T3)); } float T4 = Time.realtimeSinceStartup; bool p = PlayCards(pick); AIDebug.PlayLog("PLAY CARDS: " + (Time.realtimeSinceStartup - T4)); CurrentPlayer.DebugMemory(); OtherPlayer.DebugMemory(); //AvailableCards.Clear (); AvailableCards = null; return(p); }
public void Forget(int index) { for (int i = 0; i < card_memory_list.Count; i++) { if (CardMemoryList[i].Index == index) { CardMemoryList.RemoveAt(i); AIDebug.PlayLog(this.Name + " - Forgot Card " + index); return; } } }
public void Memorize(MemoryCard card) { // return if the memory is full if (card_memory_list.Count >= MemMax) { return; } if (CardMemoryList.Contains(card)) { return; } AIDebug.PlayLog(this.Name + " - Memorized Card " + card.Index); CardMemoryList.Add(card); }
public void DebugMemory() { if (AIDebug.enable_play_log == false) { return; } string log = Name + "'s memory: "; foreach (MemoryCard card in CardMemoryList) { log += card.Index + "(" + card.Value + "), "; } AIDebug.PlayLog(log); }
// 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); }