I'm trying to improve the VERY SIMPLE ai version of my tic-tac-toe game. Right now I have about 200 lines worth of if statements, and it looks ugly.
I'm pretty sure there is a way of handling it another way. Keep in mind that I'm only using functions and not arrays or strings. I was thinking about rotating the board. If, for example, the board looks like this:
where px is a position on the board. How could I make the board "rotate"? basically what I mean, if lets say player X takes p1 and than the program O chooses p5, on the next move player X chooses p7, and O should go for the block at p4. But a similar situation could start from all four corners. So, instead of writing all the possibilities I would like to make it simpler.Code:p1 | p2 | p3 --------------- p4 | p5 | p6 --------------- p7 | p8 | p9