Computer Science Canada help me plz |
Author: | meidan [ Wed Jun 14, 2006 8:12 pm ] |
Post subject: | help me plz |
how do you make a computer opponent in tic tac toe? |
Author: | CodeMonkey2000 [ Wed Jun 14, 2006 8:14 pm ] |
Post subject: | |
you can have a whole bunch of if statements where if this square and this square is taken, then the opponent must go in this square to block me off. |
Author: | meidan [ Wed Jun 14, 2006 8:17 pm ] |
Post subject: | |
ok i know the logic but how do i say that this square is blocked and for it to go to the other square? |
Author: | CodeMonkey2000 [ Wed Jun 14, 2006 8:22 pm ] |
Post subject: | |
mark it. sqre 1 is taken, so sqre1=1 and squr2 is taken sor squr2=1 if sqre1 and sqre2 =1 then you have to go to sqre3 etc... |
Author: | Tony [ Wed Jun 14, 2006 8:41 pm ] |
Post subject: | |
meidan wrote: ok i know the logic but how do i say that this square is blocked and for it to go to the other square?
how do you know if the square is blocked or not for the human player? same approach. |
Author: | meidan [ Wed Jun 14, 2006 8:47 pm ] |
Post subject: | |
ok i understand but i made my sqaures like this... i made a box and said the coordinates so like x >100 but <200 and y> 300 but <500 so how do i make this as a variable??? |
Author: | CodeMonkey2000 [ Wed Jun 14, 2006 8:52 pm ] |
Post subject: | |
are you using ifs? because if you are, then you can have it within the if statement. eg. if x>30 and y<90 then squre x is taken. |
Author: | Tony [ Wed Jun 14, 2006 8:54 pm ] |
Post subject: | |
perhaps you should figure out how to let a user play, before attempting to figure out how to have a computer play. |