FutureAIGuru / BrainSimII

Neural Simulator for AGI research and development
http://brainsim.org
MIT License
87 stars 25 forks source link

Engine Speed not being saved/restore from network file #172

Closed FutureAIGuru closed 2 years ago

FutureAIGuru commented 3 years ago

Describe the bug See title

This used to work so it was likely introduced by my most recent suspend/resume "improvement".

ghost commented 3 years ago

This is most likely because the engine speed is set to a constant value outside the 0 to 10 range when paused. Then when the engine is paused it becomes impossible to to find the true value when it would be running. If instead we set the speed to minus the running speed for a paused engine, we can still determine the speed (absolute of speed) and the state (positive=running, negative=paused).

ghost commented 3 years ago

Further investigation shows the speed is still written to the file, it just does not get initialized once the file is reloaded.

FutureAIGuru commented 3 years ago

This good idea should be implemented as part of code cleanup event if it isn’t the specific cause of the issue.

ghost commented 3 years ago

The problem in the end was pushing and popping the engineDelay, which overwrote any speed changes between the two, so a loaded network would set delay correctly, only to be overwritten when the resume popped the previous delay. Now pop discards the value so it no longer wreaks havoc on the engine delay. Also, IsEngineSuspended() was created, which basically checks just the size of the stack. Fix has been committed.