Page 16 of 23
Re: Interface Redesign
Posted: 05 Oct 2008, 13:44
by hoijui
ahh.. this helps, thanks!
of course, a stupid error of mine, sorry. am fixing.
Re: Interface Redesign
Posted: 05 Oct 2008, 16:41
by AF
Im sorry lately I've been ill the last week and Ill have work once Im better so Im not in the best position to compile and test right now
Re: Interface Redesign
Posted: 05 Oct 2008, 22:37
by imbaczek
hoijui: you should merge the trunk into your branch every now and then, stdafx.h has changed a lot e.g.
Re: Interface Redesign
Posted: 07 Oct 2008, 23:44
by hoijui
i did it!! (reintegrate trunk into the C AI branch)
was not so fun, but well.. it had to be done. to some extend, the changes are good: the new files Exceptions.h and Util.h, and StdAfx.h used less. but i saw that GlobalStuff is used more often instead, which i think is not so good, but it is ok (i #ifdefed some things in it, so its not compiled for AIs and iInterface libraries)
soo.. it works here, i hope i included everything in the commit that is needed. test pls, if you have time.
design question
Posted: 08 Oct 2008, 11:27
by hoijui
a design question:
logging
the way LogOutput works now, is incompatible with AIs. Meaning, they can not use it. some questions that arise:
- should AIs be able to log to infolog.txt directly?
- should we pass a simple C function pointer for logging to AIs?
something like:
Code: Select all
void (*log)(const char* logMessage);
- should each AI use its own logging mechanism?
- should AIs ever use the errorhandler?
- should they use only SendTextMessage() in the AI callback (which ends up in infolog.txt)?
- ... if so, how should they log more basic stuff, not related to an AI instance?
i personally like the log function pointer way, because it is simple and C compatible (and therefore will work with all compilers and other languages).
Re: Interface Redesign
Posted: 08 Oct 2008, 12:15
by AF
As far as I can see NTai OTAI and AAI all have their own logging systems and only use the command line for stuff like debug messages when debug mod is enabled or for commandline commands like the NTai .aicheat
Re: Interface Redesign
Posted: 08 Oct 2008, 13:51
by hoijui
scenario:
user plays spring, spring crashes, user sends infolog.txt to forum or bugtracker. if the game crashed because of an AI, and the AI did log to infolog.txt, thne the AI dev could have lots of info why it happend, or even better, the user already saw the problem and fixed it himself (if it is not code related).
also, if AIs were able to log to infolog, this does not mean they have to do it. whether they do it or not, they can still use their own logging system.
.aicheat is a message from the user to the AI, right?
i want to discuss: AI --logging-to--> engine/infolog.txt
Re: Interface Redesign
Posted: 08 Oct 2008, 14:05
by AF
Anything outputted to the console is outputted to infolog.txt that is the purpose of infolog.txt. The only exceptions really are when data is put to the console but the console cannot be viewed such as prior tot he game start during loading ro when the engine has crashed.
We already log data to external files and that is arguably safer as infolog.txt is erased and rewritten very game but our AI logs have timestamps in the file names
Re: Interface Redesign
Posted: 08 Oct 2008, 14:48
by hoijui
ah.. you mean.. stdout is redirected to infolog, so when i do this in my AI:
it ends up in infolog.txt?
Re: Interface Redesign
Posted: 08 Oct 2008, 15:34
by AF
no
See ingame theres a little console box? And when you chat or enter commands they appear in that box? That's what I mean by console. (although std::cout is routed to infolog.txt and the message console in the engine (but only in the engine not the AIs and external modules!)).
Whatever appears in the chatbox appears in infolog.txt, that is the purpose of infolog.txt, to log the contents of the chat console .
Re: Interface Redesign
Posted: 08 Oct 2008, 16:45
by hoijui
AHHHH.. now i get it...
why didn't you say that in the beginning?
i guess we keep it like this:
when an error happens realy early, during initialization of the AI, before it is possible to send messages to the Spring game console, we currently have two options:
- do logging through AI specific log system
- return a number != 0 from the init() function (which the engine writes to infolog)
and as soon as we have the AI callback available, we have these two options:
- do logging through AI specific log system
- send log messages through the AI callback (SendChatMessage() or something like that)
that is what is possible at the moment. guess it is enough.
Re: Interface Redesign
Posted: 08 Oct 2008, 16:51
by AF
Yes keep it so we can log to the chat console with the same behavior as the old interface and we'll just carry on as we always have.
Re: Interface Redesign
Posted: 08 Oct 2008, 16:52
by imbaczek
+1 for providing a spring_console_log (or whatever) API entry that routes text to the infolog.
Re: Interface Redesign
Posted: 08 Oct 2008, 18:21
by hoijui
yeahh.. the thing that always worked already works like this... its just that it is AI instance specific.. but nearly eveyrthing is instance specific, or can be logged by an instance, and the rest. can be reported to spring through function return values (as in "int init()") or to AI specific log files.
soo.. this issue is done for me.
I have updated the Wiki:
- deprecated JAI
- added a section for AI interface libraries
- added a page for the C Interface library
- added a page for the upcomming Java Interface library
- added a page for each NullAI & NullLegacyCppAI
http://spring.clan-sy.com/wiki/AIs
Re: Interface Redesign
Posted: 08 Oct 2008, 18:29
by AF
There are quite a few 'return to main page' links, can you clean them up to lead to the correct place if you come across them?
Re: Interface Redesign
Posted: 08 Oct 2008, 19:29
by hoijui
yeah there are two. links to two AIs that dont exist yet. i have to do one of them first (will be in Java, when the Java interface is ready), and the other one should be done by someone else (maybe zenzike?). it will be a Null/Test C++ AI that uses a new - event and command based - way to interface with the engine (through the C interface). in contrast to the current two test AIs of which one uses the legacy C++ wrapper and one is pure C.
We have quite some links that go to no pages on the main AI Wiki site now.. though i will leave them with no page as long as therr is nothing i can put there. If you want, put an empty page there, i would not.
Re: Interface Redesign
Posted: 08 Oct 2008, 22:19
by AF
Links to no page are better than links to incorrect pages
Re: Interface Redesign
Posted: 10 Oct 2008, 17:17
by hoijui
@AF
yeah, i think so too. so i leave it till i can put something real on that pages.
Loading AI Libraries
i am a bit confused right now (maybe becuase i slept too little). where exactly should AI libraries be loaded from?
so far, we used the {current working directory}/AI/Bot-libs/. with the new interface, the subfolder will change, but i am thinking about the first part (cwd). should it rather be the data directories? or the library directory? and if we have multiple data-dirs, should i look for AIInfo.lua files in all of them? and if so... should i look for the shared library spoecified by an AIInfo.lua in all data directories or only in the one where the AIInfo.lua resides?
Re: Interface Redesign
Posted: 10 Oct 2008, 23:25
by AF
gah now Im confused, I think I tried to outline this earlier in the thread so refer back
Re: Interface Redesign
Posted: 11 Oct 2008, 09:17
by hoijui
AF, could you give me some more hints to find the post(s) you refer to? (no mood to search through the whole 16 pages by eye).
what i found with the search option (though not in this thread):
for those who do not know (like me, 3 days ago): Spring does a chdir to the only writable data directory. so currently AIs are loaded (only) from there.
An old post of Tobi vaguely related to the subject:
viewtopic.php?f=15&t=6736&p=115699&hilit=current+working+directory#p115699