• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help in othello game

 
Lolo Mohammed
Greenhorn
Posts: 13
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12123
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vinaykumar jg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
othello.JPG
[Thumbnail for othello.JPG]
 
Lolo Mohammed
Greenhorn
Posts: 13
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lolo Mohammed
Greenhorn
Posts: 13
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your replay

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

 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic