Description: MonoAIInterface provides the possibility to write and use CLI*1 compatible AIs. A list*2 of possible languages is available at the mono homepage.
MonoInterface(80%)-needs testing, docs, minor tweaks
C# wrapper code(90%) - needs testing
CMake integration (50%) - C# related files are missing
CMake mono module (70%) - Works only under Linux
MonoNullAI (100%) - works
MSAI (MonoSampleAI) (25%)
Wiki pages (~20%)
Documentation (~15%)
Tutorials (0%)
Folder structure: AI/Interfaces/MonoInterface/ -->Provides an AI interface for CLI AIs AI/Wrappers/CSharp/ -->Wrapper code written in C#, AI developer who want to program there AIs in a CLI*2 compatible language should use this code.
Extra software required for using and developing CLI AIs: Mono >2.0.1 (2.0 should work, too but it has some bugs) GLib2 (Mono dependency) Extra software required for building: Mono-devel >2.0.1 (2.0 should work, too but it has some bugs) GLib2-devel (Mono dependency)
The MonoInterface can now load the MonoNullAI without any Problem. (MonoNullAI is a CLI AI which implements handleEvent and returns 0. It is similar to the NullAI)
Code from MonoNullAI:
Code:
using System;
static class MonoNullAI { public static int handleEvent (int teamId, int topic, object data) { return 0; } }
Windoz support will be a bit difficult. For Windoz I need to adjust the FINDMono.cmake file to find mono. GLib2 needs to be installed. And for the mono.dll a mono.lib needs to be generated.
I have no working Windoz currently due new hardware. I will install a new Windoz after openSUSE 11.1 is released because I want to clean my computer.
Next step is to get SAICallback working means I need to create a list of runtime function registration with AWK.
Due problems with native to managed pointers I was rewriting half of the code. While I did this I found out (with the help of hoijui) that it is impossible to use C++ pointer for C pointer. So I had to rewrite the complete handling of native to managed functions in C. Due to this I decided to move from C++ to C because C is faster and Mono expects char*'s not std::string's and the conversion from (const) char*/std::string was to much for me.
At the end I rewrite the complete MonoInterface in C. Half of it is done. Error/warning/info handling is missing and native to managed calling.
I worked on the C part of the Interface until I faced a problem yet unknown. Calling Mono api functions in the init event of SAILibrary crashes spring. But if I call it in the init or loadSAILibrary function of the interface it works. The init where the crash happens is past to the SAILibrary struct in loadSAILibrary as a function pointer. I don't know if it happens because of a thread issue (dead locked resources, but I call a mono function "mono_thread_attach" which should fix it if it is a thread issue) or due the possibility that mono can not be used in function pointers. Where are 6 threads running at the time of the crash. 2 SDL threads doing nanosleep(); 2 MonoVM threads, one doing a *_wait() and one poll() 1 OpenAL I think nanosleep(); 1 Spring thread where the error happens. Maybe someone has an idea :S I will try some tactics to figure out what is wrong. - Writing a program which loads the MonoVM through a function pointer - And a test program for testing the thread issue possibility.
At the moment my PC is not working because I installed and uninstalled various packages which caused some trouble to the GUI :S. I wanted to setup my PC new anyway. Until it is setup I will write some awk script to generate a C# wrapper....
And the windows support needs to wait until the Linux version works basically. The windows support will also be more difficulty.
After long time I finally finished the basics of the MonoAIInterface.
At the moment it should load any CLI compiled .dll with a runtime version 1.0 or 2.0.
I have a problem with handleEvent which is called more than 30 times a second which I think triggers this exceptions after a few seconds: SIGPWR (Power fail/restart) and then SIGXCPU (CPU time limit exceeded) repeats again after a few seconds. But it does not crash spring. I can press okay and continue.
On the managed side I run this command: Console.WriteLine("TeamID: " + teamId + " Topic: " + topic); This will be written to the console on each handleEvent call. Means more than 30 times per second.
From the mono project side: "SIGPWR, SIGXCPU: these are used internally by the GC and pthreads."
Maybe someone can help with this problem.
Edit: wikipedia: On some operating systems, the Boehm garbage collector uses SIGXCPU and SIGPWR to synchronise cross-thread garbage collection.
Can't find something like this in the documentation. And in an article it says:
Quote:
Currently Mono does not provide a mechanism for signal chaining, but one might be available in the future, see Bug #75990 (http://bugzilla.ximian.com/show_bug.cgi?id=75990) for information on the current status of this feature.
As I understand this mono does not support handling signals and I did a quick look at the source and it has a internal function which handles signals but not the two I mentioned.
I have written a CLIWrapperCodeGenerator in C#. The wrapper can produce C#, VisualBasic and JScript code and works with AISEvents.h at the moment.
Edit: Also Boo language support added.
Edit02: Added IronPython support. Looks kinda silly Example
Code:
# # This AI event is sent once per game frame, which is about 30 times per second # by default. # class SUpdateEvent(object): """type(frame) == System.Int32""" __slots__ = ['frame']
The MonoAIInterface is nearly finished thanks to very much help from hoijui and some people from #monodev on gimpnet. What is left: Documentation, optimize (free memory/ better algorithm) and some more options in the lua file. And of course some testing...
At the moment I'm searching for a good license which does not bite GPL and has a copyleft. So far LGPL seems the best... But feel free to suggest a better license.
Regarding SIGPWR and SIGXCPU - I run into yet unresolved problems with mono GC in spring downloader tracker. GC was freezing whole program and was spamming those signals. It was more likely with many threads and asynchronous IO operations. Other large scale mono projects suffer from it too - for example for hosting ASP.NET aplication under mono, its recommended to restart apache module every few hours :)
If you use gdb you can disable them in the gdb config file. The two signals mean that a cross (platform) thread actions happens (something like this), wikipedia has the answer. You can ignore them.
Btw. I lost two month of work due a hard drive hardware problem. I will maybe restart this after the summer.
offtopic: i don't know how many times i've seen this "hard drive problem lost ages of work". always always always make backups of important stuff!
I did, that is the reason why I lost "only" two months.
I blame Auswaschbar for this, he did not allow me to commit my stuff (joking, I should have uploaded it to github, by myself) But I wanted to rewrite it anyway, it was hacked together.
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum