my dog learned polymorphism*
The moose likes Game Development and the fly likes help in othello game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "help in othello game " Watch "help in othello game " New topic
Author

help in othello game

Lolo Mohammed
Greenhorn

Joined: Mar 17, 2011
Posts: 13

Hello,

I built an othello game that can be played by 2 humans , human and computer or two computers.

Everything works correctly but the problem is that when 2 computers play with each other the fram doesn't appear until the game is finish.

I think it is becase the 2 computers is very fast, for that i tried to use the timer but it give me many errors and the result of the game is completely wrong.

Also i used the (thread.sleep) but it didn't solve the problem...

can you help me please..

thank you .
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

We can't help you unless you give us something to help you with. "Many errors" doesn't tell us what the problem is. If you posted the exact text of the first few, we could focus on those.

If you could also post the relevant code, that would also help. Please don't post 1000 lines of code and expect someone to go through it all. Just post the chunk where the errors are - and please use the 'code' tags.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
vinaykumar jg
Greenhorn

Joined: Mar 18, 2011
Posts: 3
is that frame?

if so, Is that getting visible after the game has finished?

if this is the condition, just check the event that starts the game. Please post your code. let me have a look at it.

sorry if i am wrong.
Lolo Mohammed
Greenhorn

Joined: Mar 17, 2011
Posts: 13

Thank you for your replay ..

this function must called when it is the computer turn to play.


the function is like a recursion because 2 computer is play agine each other.

and when i use a timer this erroe appear many time whith different index and size :

Exception in thread "Timer-24" java.lang.IndexOutOfBoundsException: Index: 10, Size: 5

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at OthelloGame.Search.MiniMax_Search(Search.java:61)

at OthelloGame.OthelloBoard.Computer_Play(OthelloBoard.java:236)

at OthelloGame.OthelloBoard$DoComputerPlay.run(OthelloBoard.java:275)

at java.util.TimerThread.mainLoop(Timer.java:512)

at java.util.TimerThread.run(Timer.java:462)


I attach a picture of what happen when i run the program whith out timer.
after the computer finish playing, the complete frame is appear.


[Thumbnail for othello.JPG]

Lolo Mohammed
Greenhorn

Joined: Mar 17, 2011
Posts: 13

Lolo Mohammed wrote:Thank you for your replay ..

this function must called when it is the computer turn to play.
the function is like a recursion because 2 computer is play agine each other.

and when i use a timer this erroe appear many time whith different index and size :

Exception in thread "Timer-24" java.lang.IndexOutOfBoundsException: Index: 10, Size: 5

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at OthelloGame.Search.MiniMax_Search(Search.java:61)

at OthelloGame.OthelloBoard.Computer_Play(OthelloBoard.java:236)

at OthelloGame.OthelloBoard$DoComputerPlay.run(OthelloBoard.java:275)

at java.util.TimerThread.mainLoop(Timer.java:512)

at java.util.TimerThread.run(Timer.java:462)


I attach a picture of what happen when i run the program whith out timer.
after the computer finish playing, the complete frame is appear.
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
You always want to to paint the screen and have a delay between each move.

The search for the best move should use recursion but not the part that plays the actual move.
You can store the details of each move in a stack.

Print out what moves are being played and a few key variables after each move - this will help you/us debug.
It also helps if the line numbers in the stack trace correspond to the line numbers in the code.

Mike


Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Lolo Mohammed
Greenhorn

Joined: Mar 17, 2011
Posts: 13

Thank you for your replay

I change the Computer_play function. but the problem is not solved!!!

Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 250
    
    1
I suggest you learn the marvellous art of debugging then!

The stack trace you showed said there was an error at line 61 in your old code.
It's trying to get the 10th element of a 5 element array and falling over.

Mike

Exception in thread "Timer-24" java.lang.IndexOutOfBoundsException: Index: 10, Size: 5
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at OthelloGame.Search.MiniMax_Search(Search.java:61)
 
wood burning stoves
 
subject: help in othello game
 
Similar Threads
[Netbeans] Integrating external Jpanel to a Jframe
Turn Based Strategy Games
Creating a cartesian product with to lists
Hash tables and transposition tables
Othello/Reversi Game Play