Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

TicTacToe Game..

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 9103
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several solutions to a 'wordfinder' program here
https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic