It's not a secret anymore!*
The moose likes Beginning Java and the fly likes TicTacToe Game.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "TicTacToe Game.." Watch "TicTacToe Game.." New topic
Author

TicTacToe Game..

doburomirushii nikku
Ranch Hand

Joined: Oct 06, 2004
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

Joined: Jul 22, 2000
Posts: 9044
    
  10

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


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
doburomirushii nikku
Ranch Hand

Joined: Oct 06, 2004
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

Joined: Dec 06, 2001
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


Java API Documentation
The Java Tutorial
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Oct 06, 2004
Posts: 31
Yes...This is confusing me more. This what you mean by using my 3x3 one for the loop???

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
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

Joined: Oct 06, 2004
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TicTacToe Game..
 
Similar Threads
TicTacToe! Stop user from changing input
Game Tutorials -->> TicTacToe
TicTacToe game
TicTacToe Game
tictactoe help