Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TicTacToe Game..

 
doburomirushii nikku
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You want to iterate over a 15 x 15 array, but only check for 5 in a row?
 
doburomirushii nikku
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several solutions to a 'wordfinder' program here
http://www.coderanch.com/t/35083/Programming/June-Newsletter-Puzzle

The wordfinder concept seems similar to what you're trying to achieve.
 
doburomirushii nikku
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes...This is confusing me more. This what you mean by using my 3x3 one for the loop???

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic