google-code-export / bwapi-mono-bridge

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

Crashes after some time (maybe 10 seconds) #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compiles MonoBridgeAI, monobridgeai-interop and StarcraftBot, but not 
MonoBridge, becasue it gives some warnings and will not make the dll
2. Copy all the dll's to StarCraft\bwapi-data\AI\bot folder and copy 
examplebots\EmbeddedBot\MonoBridge.dll to the StarCraft\bwapi-data\AI folder.
3. One of my own maps. My bot race Terran. Enemy race Protoss
4. Crash occurs after maybe 10-15 seconds while I have some Golliaths trying to 
move across the map to the enemy.

What is the expected output? What do you see instead?
The golliaths should continue moving.
Game crashes af about 10 seconds.

This is whats happens (taken from the Monoailog.log)

15:05:09 ------------------------------------------------------ 
15:05:09 Mono Init Started 
15:05:09 Setting DLL Dir for Mono to [C:\Program Files (x86)\Mono-2.8\bin] 
15:05:09 Setting DLL Dir for Mono to [C:\Program Files (x86)\Mono-2.8\bin] 
15:05:09 Initializing JIT 
15:05:09 D:\Spil\StarCraft\bwapi-data\AI\bot\MonoBridgeAI.dll 
15:05:09 Loading AI DLL: [D:\Spil\StarCraft\bwapi-data\AI\bot\MonoBridgeAI.dll] 
15:05:09 Loading Assembly 
15:05:09 Finding class: [StarcraftBotProxy] 
15:05:09 Creating Bot Object - Memory Alloc 
15:05:10 Creating Bot Object - Constructor 
15:05:10 Finding Methods 
15:05:10 [onStart] found in StarcraftBotProxy class 
15:05:10 [onEnd] found in StarcraftBotProxy class 
15:05:10 [onFrame] found in StarcraftBotProxy class 
15:05:10 [onSendText] found in StarcraftBotProxy class 
15:05:10 [onReceiveText] found in StarcraftBotProxy class 
15:05:10 [onPlayerLeft] found in StarcraftBotProxy class 
15:05:10 [onNukeDetect] found in StarcraftBotProxy class 
15:05:10 [onUnitDiscover] found in StarcraftBotProxy class 
15:05:10 [onUnitEvade] found in StarcraftBotProxy class 
15:05:10 [onUnitShow] found in StarcraftBotProxy class 
15:05:10 [onUnitHide] found in StarcraftBotProxy class 
15:05:10 [onUnitCreate] found in StarcraftBotProxy class 
15:05:10 [onUnitDestroy] found in StarcraftBotProxy class 
15:05:10 [onUnitMorph] found in StarcraftBotProxy class 
15:05:10 [onUnitRenegade] found in StarcraftBotProxy class 
15:05:10 [onSaveGame] found in StarcraftBotProxy class 
15:05:10 Mono Init Complete 

And then Crashes

I wonder why it stops after Mono Init Complete each time. Why is the Mono 2.8 
necessary, when .NET 3.5 and 4 is installed?

Log from starcraftbot.log

10/28/2010 03:05:10: 
10/28/2010 03:05:10: ***************************************************
10/28/2010 03:05:10: New game start
10/28/2010 03:05:10: ***************************************************
10/28/2010 03:05:10: ...The AI has entered the game...
10/28/2010 03:05:10: number of units: 3
10/28/2010 03:05:10: Terran_Goliath_Agent is created
10/28/2010 03:05:10: Terran_Goliath_Agent is created
10/28/2010 03:05:10: Terran_Goliath_Agent is created
10/28/2010 03:05:10: unit create: Terran_Goliath
10/28/2010 03:05:10: unit show: Terran_Goliath
10/28/2010 03:05:10: unit create: Terran_Goliath
10/28/2010 03:05:10: unit show: Terran_Goliath
10/28/2010 03:05:10: unit create: Terran_Goliath
10/28/2010 03:05:10: unit show: Terran_Goliath

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.
The bot worked fine under 2.6.1 with embedded mono-bridge 0.5.

Original issue reported on code.google.com by twsandb...@gmail.com on 28 Oct 2010 at 1:08

GoogleCodeExporter commented 9 years ago
I tried with another level. where I get this output in the Monoailog.log. But 
the game didn't crash.

15:09:58 ------------------------------------------------------ 
15:09:58 Mono Init Started 
15:09:58 Setting DLL Dir for Mono to [C:\Program Files (x86)\Mono-2.8\bin] 
15:09:58 Setting DLL Dir for Mono to [C:\Program Files (x86)\Mono-2.8\bin] 
15:09:58 Initializing JIT 
15:09:58 D:\Spil\StarCraft\bwapi-data\AI\bot\MonoBridgeAI.dll 
15:09:58 Loading AI DLL: [D:\Spil\StarCraft\bwapi-data\AI\bot\MonoBridgeAI.dll] 
15:09:58 Loading Assembly 
15:09:58 Finding class: [StarcraftBotProxy] 
15:09:58 Creating Bot Object - Memory Alloc 
15:09:58 Creating Bot Object - Constructor 
15:09:59 Finding Methods 
15:09:59 [onStart] found in StarcraftBotProxy class 
15:09:59 [onEnd] found in StarcraftBotProxy class 
15:09:59 [onFrame] found in StarcraftBotProxy class 
15:09:59 [onSendText] found in StarcraftBotProxy class 
15:09:59 [onReceiveText] found in StarcraftBotProxy class 
15:09:59 [onPlayerLeft] found in StarcraftBotProxy class 
15:09:59 [onNukeDetect] found in StarcraftBotProxy class 
15:09:59 [onUnitDiscover] found in StarcraftBotProxy class 
15:09:59 [onUnitEvade] found in StarcraftBotProxy class 
15:09:59 [onUnitShow] found in StarcraftBotProxy class 
15:09:59 [onUnitHide] found in StarcraftBotProxy class 
15:09:59 [onUnitCreate] found in StarcraftBotProxy class 
15:09:59 [onUnitDestroy] found in StarcraftBotProxy class 
15:09:59 [onUnitMorph] found in StarcraftBotProxy class 
15:09:59 [onUnitRenegade] found in StarcraftBotProxy class 
15:09:59 [onSaveGame] found in StarcraftBotProxy class 
15:09:59 Mono Init Complete 
15:10:38 Error in .Net
Argument is out of range.

Parameter name: index 
15:10:38 Error in .Net
Argument is out of range.

Parameter name: index 

Original comment by twsandb...@gmail.com on 28 Oct 2010 at 1:12

GoogleCodeExporter commented 9 years ago
I'll have to look into the other crashes, but the bot needs mono to run because 
it is not possible to embed the .net framework into the starcraft process in a 
way which would be useful. If you want to use .net use the bwapi-clr-bridge.

Original comment by dpershouse@gmail.com on 28 Oct 2010 at 11:32

GoogleCodeExporter commented 9 years ago
Would it be possible to get a copy of your starcraft bot and which map caused 
this problem (the argument is out of range problem)

Original comment by dpershouse@gmail.com on 28 Oct 2010 at 11:43

GoogleCodeExporter commented 9 years ago

Original comment by dpershouse@gmail.com on 28 Oct 2010 at 11:43

GoogleCodeExporter commented 9 years ago
Here you have my Bot. In most cases it looks like the crash happens when one of 
my unit dies (see for instance the map file GoliathsZerglings.scm)
But in the other map file it crashes a lot faster.
It worked in the 2.6.1 version. But I must handle the unitdeath wrong, because 
it seems like my bot tries to use units that are already dead.

Hope you can help me finding out what is wrong.

Original comment by twsandb...@gmail.com on 29 Oct 2010 at 10:49

Attachments:

GoogleCodeExporter commented 9 years ago
found it.

 UnitAgent bestUnitAgent = squad[0];

inside mymath.cs findbestleadercandidate

You should check the bounds of the squad list to ensure it contains at least 
one unit. When the last golaith dies, this gets called before the game ends, 
and the size of the squad list is 0, so squad[0] throws and index out of range 
error (which is what you were getting in your log file for the embedded bot.

To get better error descriptions, run your bot through the monoaimoduleloader 
but from a cmd window (run cmd.exe as administrator and then from there run 
monoaimoduleloader.exe) when the bot gets an unhandled exception (like index 
out of range) it will do a stack trace and exit. Running your bot from the 
command line will allow you to see the trace before the window closes (which is 
default if you just double click on the executable.)

I will add a logfile and a readline to the next version of monoaimoduleloader 
so that these exceptions are easier to see.

Original comment by dpershouse@gmail.com on 29 Oct 2010 at 1:58

GoogleCodeExporter commented 9 years ago

Original comment by dpershouse@gmail.com on 29 Oct 2010 at 1:58

GoogleCodeExporter commented 9 years ago
Thanks for your answer, but there is only a monoaimoduleloader in the CLR 
Client and not in the embedded MonoBridgeAI bot, as I see it. So is there a way 
for the embedded bot to get these unhandled exeptions?

Original comment by twsandb...@gmail.com on 1 Nov 2010 at 10:10

GoogleCodeExporter commented 9 years ago
It seems like it crashes if I try to select different units with the mouse in 
game, to check there health. Is there a new Mouse event handler, that maybe has 
an error in the new 3.2B, because I could do that without any crash in 2.6.1?

I'm not sure about when OnUnitHide and OnUnitDestroy is called, I try to clean 
up my own Unit Lists when these events are called, but I think one of my 
problems maybe is here too, even when it worked in 2.6.1.

I have checked an change the code in findbestleadercandidate, but I don't think 
that was the problem.

Original comment by twsandb...@gmail.com on 1 Nov 2010 at 11:06

GoogleCodeExporter commented 9 years ago
Now I have tried to outcommend so much so my units should only try to move to 
the corner, but it still crashes after some time. Very weird, because there is 
no lists that should have been changed, so it can't be because i'm trying to do 
an action with a unit that is dead.

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

Attachments:

GoogleCodeExporter commented 9 years ago
the monoaimoduleloader works with your bot
(it will work with any bot using the IStarcraftBot interface) just put it in 
the same folder as bwapi-native.dll and bwapi-clr.dll and monoaimoduleloader.exe

Run the loader, run starcraft, wait for error.

Original comment by dpershouse@gmail.com on 1 Nov 2010 at 12:46

GoogleCodeExporter commented 9 years ago
I just ran your latest bot. (using monoaimoduleloader.exe) and it worked fine. 
They all died and I lost the game.

Original comment by dpershouse@gmail.com on 1 Nov 2010 at 12:52

GoogleCodeExporter commented 9 years ago

Original comment by dpershouse@gmail.com on 1 Nov 2010 at 12:53

GoogleCodeExporter commented 9 years ago
Maybe it is only with the embedded bot

Original comment by dpershouse@gmail.com on 1 Nov 2010 at 12:54

GoogleCodeExporter commented 9 years ago
How do you run the embedded bot with monoaimoduleloader.exe from CMD?
Can you call the MonoBridge.dll as a command to the monoaimoduleloader.exe?

I have attached the AI folder from the bwapi-data\AI.

Original comment by twsandb...@gmail.com on 1 Nov 2010 at 1:08

Attachments:

GoogleCodeExporter commented 9 years ago
If I put the monoaimoduleloader.exe into the AI\Bot folder where my 
StarCraftBot.dll is placed it says the same error: no Types implement 
IStarcraftBot

Original comment by twsandb...@gmail.com on 1 Nov 2010 at 1:15

GoogleCodeExporter commented 9 years ago
This map with some marines Crashes each time after short time. Hope you get the 
same crash as I do.

Original comment by twsandb...@gmail.com on 1 Nov 2010 at 1:36

Attachments:

GoogleCodeExporter commented 9 years ago
To run with the loader, copy monoaimoduleloader.exe, 
monoaimoduleloader.app.config,  bwapi-native.dll, bwapi-clr.dll and your bot 
(starcraftbot.dll) to the bwapi\ai folder.

Start a cmd.exe window by typing cmd into the search box on your start menu and 
then selecting cmd.exe when it comes up.

navigate to your starcraft bwapi-data\ai folder, type monoaimoduleloader.exe 
and it should check the monoaimoduleloader.app.config file for the name of the 
bot dll and load the bot (with some warning about it replacing 
monobridge-interop.dll with bwapi-clr.dll)

Original comment by dpershouse@gmail.com on 1 Nov 2010 at 9:16

GoogleCodeExporter commented 9 years ago
Ok, now it works and I can now see what was wrong before. The 
monobridgeai-interop.dll cannot be in the same folder as monoaimoduleloader, 
because then it throws an error, saying that "No types implement 
IStarCraftBot". If I remove it, it gives the warning you told me and runs.

At the same time my Bot runs without crashing. That is very weird, because if I 
run it as Embedded it crashes all the time. So there must be something wrong 
with the embedded version.

I think I will move my Embedded StarCraftBot project into the CLR Client 
version instead.

Again, thanks for your help.

Original comment by twsandb...@gmail.com on 2 Nov 2010 at 8:14

GoogleCodeExporter commented 9 years ago
Could you tell me what exceptions your code caught with the new exception 
handler in the embedded bot, (to help me fix the embedded bot)

Original comment by dpershouse@gmail.com on 2 Nov 2010 at 8:35

GoogleCodeExporter commented 9 years ago
I implemented the exception handler for the CLR client version, not in the 
Embedded version. So I didn't get any exeptions, StarCraft just crashed some 
times.

Now I get no errors after using the monoaimoduleloader.exe to load the same AI, 
that crashed when running as embedded.

If you will try to reproduce the error, it should be possible if you run the 
StarCraftBot_mono(01-11-2010)CRASH.rar with the map MarineZerglings.scm as 
Embedded, and without the loader. Just with adding the MonoBridge.dll to the 
bwapi.ini like ai_dll     = bwapi-data\AI\MonoBridge.dll.

Original comment by twsandb...@gmail.com on 3 Nov 2010 at 8:17

GoogleCodeExporter commented 9 years ago
Managed to reproduce the problem. Adding an unhandledExceptionhandler to 
monobridgeAI.dll seemed to fix the problem!? even if the handler is completely 
blank. (it doesn't seem to ever get called), I'll chalk this up as either a 
horrible race condition, or a bug in mono/swig. I'll leave the 
unhandledexception handler in the code to help future people.

Original comment by dpershouse@gmail.com on 3 Nov 2010 at 11:26

GoogleCodeExporter commented 9 years ago

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