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...
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.
Never ascribe to malice that which can be adequately explained by stupidity.
vinaykumar jg
Greenhorn
Joined: Mar 18, 2011
Posts: 3
posted
0
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.
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: 185
posted
0
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.
I change the Computer_play function. but the problem is not solved!!!
Mich Robinson
Ranch Hand
Joined: Jun 28, 2009
Posts: 185
posted
0
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)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.