Sunday, May 10, 2009

Help with simple C++ game?

Ok, Befor you look at this. Im young (13) and trying to learn C++. tonight i tryed making this TicTacToe game. It looks like its fine, but it dosnt work proply. No mader with my imput is i alwas get Square 1 being Filled in





And does any one no any good sites on AI.


Here it is.

Help with simple C++ game?
Pretty good logic for 13 and you almost have it working.





Beginning college level programming classes do stuff like this.





-------------


This is common mistake professors tell students to watch out for





if(number = 1) it should be if(number == 1)





--------------


Also, to avoid printing out the tic-tac-toe twice, you can put the first printout before the while statement.





-----------------


Look at this





if( number = 9)


{


i = "X";


Show = Show + 1;


}


else


{


cout%26lt;%26lt;"thats not a square in the box"%26lt;%26lt;endl;


}








Every time when number is not 9, it will print a statement that the number is not in the box.





Try this instead (the || means or)





if(number%26lt;1 || number%26gt;9)


cout%26lt;%26lt;"thats not a square in the box"%26lt;%26lt;endl;
Reply:All your if statements have "=" as the condition. Change that to "==". Very common mistake. Don't worry, you are doing fine! :)

thank you cards

No comments:

Post a Comment