# TicTacToe Game..

doburomirushii nikku
Ranch Hand
Posts: 31
Hi..

I just need some help to change my if statemtent to a loop
because i'm making 15x15 board with 5 in a row wins and it would
be tedious to use if statement. Heres the code with m attempt at
the loop and the old loop for reference.

Marilyn de Queiroz
Sheriff
Posts: 9067
12

You want to iterate over a 15 x 15 array, but only check for 5 in a row?

doburomirushii nikku
Ranch Hand
Posts: 31
yes. There is a 15 x 15 board, and you only need either 5 x's or o's in a row to win the game.

Layne Lund
Ranch Hand
Posts: 3061
Originally posted by Marilyn de Queiroz:

You want to iterate over a 15 x 15 array, but only check for 5 in a row?

I'm pretty sure you could implement that long condition for the if statement with a nested for loop. I'll leave this as the proverbial exercise for the reader, though. (Although, I might take the time to see if I can get it to work on my own as well.)

Layne

Michael Dunn
Ranch Hand
Posts: 4632
There are several solutions to a 'wordfinder' program here

The wordfinder concept seems similar to what you're trying to achieve.

doburomirushii nikku
Ranch Hand
Posts: 31
Yes...This is confusing me more. This what you mean by using my 3x3 one for the loop???

Layne Lund
Ranch Hand
Posts: 3061
Perhaps you are trying to do too much all at once. It might be easier to break it down into simpler steps. For example, you might check each row for a win, then check each column. Perhaps something like this would work for checking rows:

This is pseudocode of course, and hasn't been fully tested, so use at your own discretion. Some modifications may be necessary. A similar set of for loops would be used to check columns instead of rows.

HTH

Layne

doburomirushii nikku
Ranch Hand
Posts: 31
yes ..that looks like something i can understand. Just why is it too 11?

Edit: your code reminds me of my pascal days..man that was so much easier .
[ October 17, 2004: Message edited by: Kenshin Himura ]

 Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters?