how can i make the computer block when im about to score, like do something like this XXXO?
and how can i make the computer to make an OOOO for it to score too?
im not allowed to use internet libraries in this one, need help

Recommended Answers

All 3 Replies

You really need to get your head around the logic, lets say (since im guessing you are using a 2d array for your board) your board is arrange something like this small scale

- - - - -
- - - - -
- O - - -
x O - - -
x O - - -

the line of 3 'O' would be in the array as board[1][x] where x is the height, so loop through it see if there are 3 in a row is so block it, if it is a valid move.

assuming O is player x is compuer in that example

Chris

oops, not that much info, im actually using a function. arrays are sadly not within our scope so i cant use it. so could i still loop it?

What method are you using to store your board then?

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.