Executing out of order

V

vaughanPCR

I'm creating a neural network to look at tic tac toe. I randomly
create places to 'pick' on the board. When the game is over I test to
see who won.

Theoretically (in the code) my playing board (a 4x4x4 array) is reset
(set to all zeros) after each win or loss is declared. For some reason
when I execute the code it will run the same board through several
times in a row without reseting. When I went to debug it by steping
through I couldn't repeat the error. When I put a delay in the problem
goes away (which is why I couldn't catch it in debug). When I shorten
the pause the problem almost goes away.

I've tried placing my reset() function in different places. I refuse
to believe it's actually doing the execution out of order. Anyone have
some ideas? If you need the code I can post it, but the code I use to
pick the winner is really long and hard to step through.
 
J

John Carson

I'm creating a neural network to look at tic tac toe. I randomly
create places to 'pick' on the board. When the game is over I test to
see who won.

Theoretically (in the code) my playing board (a 4x4x4 array) is reset
(set to all zeros) after each win or loss is declared. For some
reason when I execute the code it will run the same board through
several times in a row without reseting. When I went to debug it by
steping through I couldn't repeat the error. When I put a delay in
the problem goes away (which is why I couldn't catch it in debug).
When I shorten the pause the problem almost goes away.

I've tried placing my reset() function in different places. I refuse
to believe it's actually doing the execution out of order. Anyone
have some ideas? If you need the code I can post it, but the code I
use to pick the winner is really long and hard to step through.

Possibilities that occur to me:

1. A multi-threaded application that is not properly synchronised.
2. An operating system call that returns immediately before its execution is
complete.
3. Compiler bug (very unlikely).
4. (catch all) Buggy code that you are getting away with in Debug mode by
pure chance.

Both to assist us and perhaps to solve the problem yourself, I suggest you
make a copy of the program and then rip out large chunks of it in order to
isolate the problem. Test it after each removal. If removing something does
solve the problem, then that will suggest that the removed part may have
been the problem.

In particular, resetting to zero should not depend on who wins, so just
substitute a function that declares player 1 as the winner. If you can
reproduce the problem with a short piece of code but can't figure out the
problem with the code, then post it here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top