solved

solved
Last edited on
It was a valiant effort, but still came up short.
https://www.cplusplus.com/articles/jEywvCM9/

Speaking of short, http://sscce.org/

A sprawl of out of context code isn't much to go on.

Build a minimal skeleton of a program which paints the general picture.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Game {
  char board[5][5];
public:
  void HumanTurn();
  void AITurn();
  bool won();     // has anybody won?
  void Winner();  // print the winner
};

void playAGame() {
  Game game;
  cout << "Who first";
  cin >> who;
  bool first = (who == "Human");
  do {
    if ( first ) {
      cout << "Human Turn";
      game.HumanTurn();
    } else {
      cout << "AI Turn";
      game.AITurn();
    }
    first = !first; // toggles between players
  } while ( !game.won() );
  game.Winner();
}

int main ( ) {
  do {
    playAGame();
    cout << "Again?";
    cin >> again;
  } while ( again == 'Y' );
}


Then start to fill in missing functionality and keep testing as you go.
Last edited on
Topic archived. No new replies allowed.