Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        // 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);
        }
Exemplo n.º 3
0
        // 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);
        }