google-code-export / bwapi-mono-bridge

Automatically exported from code.google.com/p/bwapi-mono-bridge
0 stars 0 forks source link

Restart Game after end match (onEnd Event) #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Call restartGame in the onEnd Event...

What is the expected output? What do you see instead?
Want to run a Generic Algorithm, where I calculate fitness after end match and 
restart it afterwards.
Expected that the game would restart after calling restartGame in the onEnd 
event.
It looks like it restart the game twice very fast and the second time it 
crashes (see attached error file).
It should be possible to restart the game from code after the game ended right?

What version of the product are you using? On what operating system?
BWAPI 3.2Beta
bwapi-mono-bridge 3.2b
Windows 7 x64
Starcraft 1.16.1

Please provide any additional information below.
If I try to restart the game atter for instance 120 Game frames, it works as it 
should.

Original issue reported on code.google.com by twsandb...@gmail.com on 11 Nov 2010 at 1:56

Attachments:

GoogleCodeExporter commented 9 years ago
I have made a work around where I in the onFrame event checks if any of the 
teams has any unit left. If they don't I restart the game manually.
Instead of having a Trigger on the map, that ends the game, when any of the 
teams has 0 units left.

if (BWAPI.bwapi.Broodwar.getFrameCount() != 0 && !gameRestarted && 
!AnyUnitsLeftOnTeams() && numberOfRestartExecutions <= numberOfRestarts)
            {
                Logger.AddAndPrint(string.Format("numberOfRestartExecutions: {0}", numberOfRestartExecutions)); 
                Logger.AddAndPrint(string.Format("framecount: {0} gameRestarted: {1}", BWAPI.bwapi.Broodwar.getFrameCount(), gameRestarted));
                Logger.AddAndPrint("One of the teams has now no units left. The game should be restarted...");
                Logger.AddAndPrint("Set Game Restarted to true");
                gameRestarted = true;
                Game.RestartSinglePlayerGame();

                numberOfRestartExecutions++;
            }

It can now run and restart 7-15 times, but sometimes the game still crashes and 
I don't know why.

Do you know if the onEnd Frame should be called when RestartGame is executed, 
because I can see that it is called. But i'm not sure if it is my Restart call 
that makes the onEnd event be executed or it is something else in BWAPI that 
checks if there is no units left.

Is there any way I can save a counter value, that will be remained after a 
restart. Can it be saved somehow in StarcraftBotProxy. Or will I have to save 
it to a file, and manually reset the counter each time I start the bot?

Original comment by twsandb...@gmail.com on 12 Nov 2010 at 12:03

GoogleCodeExporter commented 9 years ago
From the ClrAIModuleLoader would it be possible to get information out of my 
bot. I mean can I somehow say MyBot.getSomeValue. The reason I ask is because, 
maybe I could control the overall Genetic Algorithm from your 
ClrAIModuleLoader, and from here save values like fitness and restart my Bot 
after each run.

Original comment by twsandb...@gmail.com on 12 Nov 2010 at 11:59

GoogleCodeExporter commented 9 years ago
This is a bug with BWAPI, not bwapi-mono-bridge, and has been fixed for the 
next release.

Original comment by lowerlo...@gmail.com on 19 Nov 2010 at 9:06

GoogleCodeExporter commented 9 years ago
@twsandberg this is definately possible, ClrAIModuleLoader is just .net code 
that loads up another dll that implements IStarcraftBot. You maybe could extend 
the IStarcraftBot interface with your getSomeValue function, and make the 
module loader load a bot of type IStarcraftBotExtended.

Btw I am about to release a version for 3.3

Original comment by dpershouse@gmail.com on 25 Nov 2010 at 1:42

GoogleCodeExporter commented 9 years ago
version 3.3a of bwapi-mono-bridge uses BWAPI 3.3 so I will assume this is fixed 
for now.

Original comment by dpershouse@gmail.com on 25 Nov 2010 at 2:42