if you want to program tic tac toe and make a possibility for the - TopicsExpress



          

if you want to program tic tac toe and make a possibility for the player to play against the computer, there are 2 solutions: you get the player input and then switch this requires kind of a list or array, where your program can see what to do next example: user inputs X to 1|1 then your program switches switch(input) { case 11://reaction of your program case 12://reaction of your program //and so on: 13,21,22,23,31,32,33 } this is the easy way the difficult way is that you make kind of an AI(artificial intelligence) the AI thinks over how the program COULD react, and what the user COULD do then then the AI decides what to do to have the highest chance to win this is the VERY difficult way practise makes perfect #include #include #include //lib for pseudo-random #include //lib for time to random char GameBoard[3][3]={{.,.,.},{.,.,.},{.,.,.}}; using namespace std; /****************************************************************** * Verify if Player/Computer Won * ******************************************************************/ void VictoryConf () { // Verify diagonals if(GameBoard[0][0]==GameBoard[1][1] && GameBoard[1][1]==GameBoard[2][2] && GameBoard[0][0]!=.) { cout
Posted on: Wed, 05 Mar 2014 13:43:43 +0000

Trending Topics



Recently Viewed Topics




© 2015