title: I am having an issue with my AI trying to delete the card that it just played?
body: <p>I am making a card game, Crazy Eights, I have everything done except I am having a problem with this AI. The AI needs to delete the card it just played from its card options. (Each player is dealt 5 cards, and if the card matches the suit, value, or an 8, it can play). SO far, the computer does play the correct card, it just doesn't remove the card so it can just keep playing and playing.</p>
  
  <p>Main Function</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;time.h&gt;
  #include "CCrazyEight.h"
  #include "stdafx.h"
  using namespace std;
  
  
  void main()
  {
      // Calls Crazy eight and declares a variable, then runs the game
      CCrazyEight E1;
      E1.Menu();
  }
  </code></pre>
  
  <p>CCard Header File</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  #include "stdafx.h"
  using namespace std;
  
  enum CardSuit { Hearts, Diamonds, Spades, Clubs };
  
  class CCard
  {
      friend ostream &amp; operator &lt;&lt; (ostream &amp;left, CCard right);
  private:
      int value;
      CardSuit suit;
  public:
      // Constructor, sets default values to suit and value
      CCard()
      {
          value = 1;
          suit = Hearts;
      }
      // return thes value of the card
      int GetValue()
      {
          return value;
      }
      // returns the suit of the card
      CardSuit GetSuit()
      {
          return suit;
      }
      // Passes values to CDeck constructor, which then randomizes values for the cards
      void InitCard(CardSuit s, int v)
      {
          suit = s;
          if (v &gt; 0 &amp;&amp; v &lt; 14)
          {
              value = v;
          }
      }
  };
  // outputs value and suit of the card
  ostream &amp; operator &lt;&lt; (ostream &amp;left, CCard right)
  {
      if (right.value &lt; 11 &amp;&amp; right.value &gt; 1)
      {
          left &lt;&lt; right.value;
      }
      else if (right.value == 1)
      {
          left &lt;&lt; "Ace";
      }
      else if (right.value == 11)
      {
          left &lt;&lt; "Jack";
      }
      else if (right.value == 12)
      {
          left &lt;&lt; "Queen";
      }
      else if (right.value == 13)
      {
          left &lt;&lt; "King";
      }
      left &lt;&lt; " of ";
      if (right.suit == Hearts)
      {
          left &lt;&lt; "Hearts";
      }
      else if (right.suit == Diamonds)
      {
          left &lt;&lt; "Diamonds";
      }
      else if (right.suit == Spades)
      {
          left &lt;&lt; "Spades";
      }
      else if (right.suit == Clubs)
      {
          left &lt;&lt; "Clubs";
      }
      return left;
  }
  </code></pre>
  
  <p>CDeck Header File</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include "CCard.h"
  #include &lt;time.h&gt;
  using namespace std;
  
  class CDeck
  {
  private:
      CCard Deck[52];
      int TopCard;
  public:
      // constructor
      // randomizes the card numbers for suit and value
      CDeck()
      {
          srand(time(NULL));
          TopCard = 0;
          for (int suit = 0; suit &lt; 4; suit++)
          {
              for (int value = 1; value &lt;= 13; value++)
              {
                  Deck[((suit * 13) + value) - 1].InitCard((CardSuit)suit, value);
              }
          }
      }
      // shuffles the deck, completely randomizes the cards
      void Shuffle()
      {
          TopCard = 0;
          for (int y = 0; y &lt; 10; y++)
          {
              for (int x = 0; x &lt; 52; x++)
              {
                  int SwapPosition = rand() % 52;
                  CCard temp;
                  temp = Deck[x];
                  Deck[x] = Deck[SwapPosition];
                  Deck[SwapPosition] = temp;
              }
          }
      }
      // Draw a card function that gives out a card when called for in crazy eight
      CCard DrawCard()
      {
          if (TopCard &gt; 51)
          {
              cout &lt;&lt; "Deck is Empty." &lt;&lt; endl;
          }
          else
          {
              return Deck[TopCard++];
          }
      }
  };
  </code></pre>
  
  <p>CrazyEight header file</p>
  
  <pre><code>    #pragma once
  
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  #include "CCard.h"
  #include "CDeck.h"
  #include "CPlayer.h"
  using namespace std;
  
  
  
  
  
  
  
  
  
  
  
  // Having an issue trying to get the computer to play something different
  
  
  class CCrazyEight
  {
  private:
      CDeck d1;
      CCard c1;
      int index;
      CCard Topcard;
      CPlayer Computer;
      CPlayer Human;
  public:
      // constructor
      // shuffles the deck to the played, and assigns the topcard to start the game
      CCrazyEight()
      {
          d1.Shuffle();
          c1 = d1.DrawCard();
          Topcard = c1;
      }
      // plays the game, dealing cards to computer and human
      void PlayGame()
      {
          cout &lt;&lt; "Welcome to Crazy Eight!" &lt;&lt; endl;
          cout &lt;&lt; "You get to go first!" &lt;&lt; endl;
          cout &lt;&lt; endl;
          for (int k = 0; k &lt; 5; k++)
          {
              Computer.GetCard(d1.DrawCard());
              Human.GetCard(d1.DrawCard());
          }
      }
      // displays the topmost card
      void TopCard()
      {
          cout &lt;&lt; Topcard &lt;&lt; endl;
      }
      // displays the cards for the human, and the options they can chose, and anything else they need about the game
      void Menu()
      {
          PlayGame();
          while (Human.NumCards() != 0 || Computer.NumCards() != 0)
          {
              cout &lt;&lt; endl;
              cout &lt;&lt; "Top Card is: "; TopCard();
              cout &lt;&lt; endl;
              cout &lt;&lt; "You Have " &lt;&lt; Human.NumCards() &lt;&lt; " Cards Left." &lt;&lt; endl;
              cout &lt;&lt; "Your play: " &lt;&lt; endl;
              cout &lt;&lt; "0) Draw Card" &lt;&lt; endl;
              cout &lt;&lt; Human &lt;&lt; endl;
              cin &gt;&gt; index;
              if (index == 0)
              {
                  Human.GetCard(d1.DrawCard());
                  Topcard = Topcard;
              }
              else if (index &gt; 0 &amp;&amp; index &lt;= Human.NumCards())
              {
                  Topcard = Human.CardPlayed(index, Topcard);
              }
              cout &lt;&lt; endl;
              Topcard = Computer.ComputerAI(Topcard);
              cout &lt;&lt; "Computer Played: " &lt;&lt; Topcard &lt;&lt; endl;
              if (Computer.NumCards() &gt; 0)
              {
                  cout &lt;&lt; "Computer has " &lt;&lt; Computer.NumCards() &lt;&lt; " Cards Left." &lt;&lt; endl;
              }
              else
                  cout &lt;&lt; "You Lose!" &lt;&lt; endl;
          }
      }
  };
  </code></pre>
  
  <p>CPlayer Header File</p>
  
  <pre><code>#pragma once
  #include "CCard.h"
  #include &lt;time.h&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  class CPlayer
  {
      friend ostream &amp; operator &lt;&lt; (ostream &amp;left, CPlayer right);
  private:
      CCard Hand[25];
      CDeck d1;
      int NumberOfCard;
      bool Computer;
      const int MaxHand = 26;
      bool TopCard;
  public:
      // Constructor for the computer, sets computer to true
      CPlayer(bool computer = true)
      {
          Computer = computer;
          NumberOfCard = 0;
      }
      // Computers AI, checks and sees if they can play, if not then they draw until they can play, or they play a card that is playable******Easy mode**** Lol
      CCard ComputerAI(CCard Topcard)
      {
              for (int i = 0; i &lt; NumberOfCard; i++)
              {
                  if (Hand[i].GetSuit() == Topcard.GetSuit() || Hand[i].GetValue() == 8 || Hand[i].GetValue() == Topcard.GetValue())
                  {
                      for (int i = 0; i &lt; NumberOfCard; i++)
                      {
                          if (Topcard.GetSuit() == Hand[i].GetSuit() &amp;&amp; Hand[i].GetValue() != 8)
                          {
                              NumberOfCard--;
                              return Hand[i];
                          }
                      }
                      for (int i = 0; i &lt; NumberOfCard; i++)
                      {
                          if (Topcard.GetValue() == Hand[i].GetValue() &amp;&amp; Hand[i].GetValue() != 8)
                          {
                              NumberOfCard--;
                              return Hand[i];
                          }
                      }
                      for (int i = 0; i &lt; NumberOfCard; i++)
                      {
                          if (Hand[i].GetValue() == 8)
                          {
                              NumberOfCard--;
                              return Hand[i];
                          }
                      }
                  }
                  else
                  {
                      GetCard(d1.DrawCard());
                  }
              }
      }
      // Is not the computer, sets computer to fasle. i.e. its the human
      void Human()
      {
          Computer = false;
      }
      int NumCards()
      {
          return NumberOfCard;
      }
      // will hand out a card
      bool GetCard(CCard NewCard)
      {
          if (NumberOfCard &lt; MaxHand)
          {
              // Now is taking the card
              Hand[NumberOfCard] = NewCard;
              NumberOfCard++;
              return true;
          }
          else
              return false;
      }
      // subtracts the card that was played from the deck of the human user
      CCard CardPlayed(int index, CCard Topcard)
      {
          if (CheckCard(index, Topcard) == true)
          {
              CCard TempTopcard = Hand[index - 1];
              for (int i = index - 1; i &lt;= NumberOfCard - 1; i++)
              {
                  Hand[i] = Hand[i + 1];
              }
              NumberOfCard--;
              return TempTopcard;
          }
          else
              cout &lt;&lt; "Not a valid Card." &lt;&lt; endl;
              return Topcard;
      }
      // checks the card and see's if it is playable or not
      bool CheckCard(int index, CCard Topcard)
      {
          if (Hand[index - 1].GetSuit() == Topcard.GetSuit() || Hand[index - 1].GetValue() == 8 || Hand[index - 1].GetValue() == Topcard.GetValue())
          {
              return true;
          }
          else
              return false;
      }
  };
  // overloads the output to cout the card
  ostream &amp; operator &lt;&lt; (ostream &amp;left, CPlayer right)
  {
      for (int i = 0; i &lt; right.NumberOfCard; i++)
      {
              left &lt;&lt; i + 1 &lt;&lt; ") " &lt;&lt; right.Hand[i] &lt;&lt; endl;
      }
      return left;
  }
  </code></pre>