.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   koraXs XML/INI/CFG parser for your bot (http://forums.bots-united.com/showthread.php?t=2382)

koraX 29-07-2004 18:36

koraXs XML/INI/CFG parser for your bot
 
Well I made some nice program which I will use in my bot for CS, so why not to share it with you :)

koraXs parser is program which enables you to work with XML, INI and CFG files, easily retrieve and edit parameters, add new ones and export them to XML, CFG or INI

note : If it's not obvious, this is for bot coders, not players :)

Supporting INI files like ones in Unreal tournament, CFG files like ones in Half-life, and XML 1.0 specification. Both import and export ;)
  • free. Licensed under GNU/GPL
  • you will only need ANSI C++ compliant compiler (tested under GCC, MSVC 6.0, MSVC .NET)
  • detailed online documentation

Features :
  • Import/Export from/to XML, INI or CFG
  • Powerful query search
  • Woking quickly in bot (tested in CS), has no problem with big xml files (over megabyte)
  • Creating new elements and attributes
  • Deleting elements and attributes
  • Changing elements/attributes properties : name, value and comment
  • Special fuctions : Copying, moving and swaping elements/attributes
  • WYSIWYG editor included, supporting most features of koraXs parser

Very easy usage :

Imagine we have following XML file :

Code:

<?xml version="1.0"?>
<kxbot version="1.0" date="07.21.2004">
        <!-- first bot, very ghey -->
        <bot>
                <name>Frodo</name>
                <mod>CS</mod>
                <skill>
                        <easy>10</easy>
                        <medium>20</medium>
                        <hard>30</hard>
                </skill>
                <skin>
                        5
                        <T>1</T>
                        <CT>2</CT>
                </skin>
                <meta version="1.3" date="12.02.1995"/>
        </bot>
        <!-- this bot is slow -->
        <bot>
                <name>Sam</name>
                <mod>CS</mod>
                <skill>
                        <easy>20</easy>
                        <medium>20</medium>
                        <hard>60</hard>
                </skill>
                <skin>
                        5
                        <T>3</T>
                        <CT>3</CT>
                </skin>
                <meta version="1.0" date="12.03.1995"/>
        </bot>
        <game version="1.5"/>
</kxbot>

Just load 2 source files into your project and you can fully use koraXs parser. Example of simple program using koraXs parser :

PHP Code:

#include "params.h"

using namespace std;

int main() 
{
    
Par::CParams par;

    
// load XML file into the memory
    
if(par.loadXML("xml-example-1.xml")==false)
    return -
1;

    
// This will return name of the first bot in list
    
cout << par.getval("bot/name") << endl// Frodo

    
return 0;



C friendly :

You don't know C++ well ? No problem, you can easily use koraXs parser with your C skills. The previous example in C friendly way :

PHP Code:

#include "params.h"

int main() 
{
    
Par::CParams par;

    
// load XML file into the memory
    
if(!par.loadXML("xml-example-1.xml"))
    return -
1;

    
// This will return name of the first bot in list
    
printf("%s\n",par.getval("bot/name").c_str()); // Frodo

    // NOTE if you are not using STL, you can retrieve 
    // simple char * strings by .c_str() function like shown above

    
return 0;



Load file on begining of session or when bot spawns (if you have separate configuration files for each bot), and then you can easily access contents of this file with get() functions. No need to create your own variables for each parameter. All content of file is already in memory.


Powerful search :

You want to search in xml file for name of bot, who has skill 10 and does not have skin 3 or 5 ? You can do it in one function :
PHP Code:

// C
char name[1000];
strcpy(name,par.getval("bot/skill/easy='10'^^skin/CT!='3'|'5'^^name").c_str());

// or nicer in C++
string name=par("bot/skill/easy='10'^^skin/CT!='3'|'5'^^name"); 

You can learn more about query searching in online documentation, where you can also find complete reference, examples an much more :)

Info and download :

Right here (900kB)



If you have any questions, ask here, on my forum or e-mail me

Pierre-Marie Baty 29-07-2004 19:58

Re: koraXs XML/INI/CFG parser for your bot
 
WOW

I will DEFINITELY have a look at this... and MOST PROBABLY include it in my bot (with proper credit of course :P)

thanks man!!

Whistler 30-07-2004 09:56

Re: koraXs XML/INI/CFG parser for your bot
 
@Jozef: Perhaps you had better add an "exception" comment, otherwise (in theory) anyone except you who use it in an HL bot will be actually in violation of GPL...

Quote:

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
Valve's Half-Life SDK is Valve's proprietary program whose license surely has "further restrictions" so linking your code against Valve's SDK and release the result binary file is forbidden by GPL.

The "exception" comment is like this one: (taken from the Metamod source)
Code:

*    In addition, as a special exception, the author gives permission to
 *    link the code of this program with the Half-Life Game Engine ("HL
 *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
 *    L.L.C ("Valve").  You must obey the GNU General Public License in all
 *    respects for all of the code used other than the HL Engine and MODs
 *    from Valve.  If you modify this file, you may extend this exception
 *    to your version of the file, but you are not obligated to do so.  If
 *    you do not wish to do so, delete this exception statement from your
 *    version.


koraX 30-07-2004 11:06

Re: koraXs XML/INI/CFG parser for your bot
 
koraXs parser stays under GNU/GPL, mainly because it is not only for bots. It can be used in lots of other projects where you need to store some parameters in files.


Quote:

Originally Posted by Whistler
Valve's Half-Life SDK is Valve's proprietary program whose license surely has "further restrictions" so linking your code against Valve's SDK and release the result binary file is forbidden by GPL.

I can't see a problem here. If bot is released under GNU/GPL, I don't see any violation of Valves SDK. Valves SDK does not have to be included within bots source code.


If someone would have a problem including my program in his bot, I could give him koraXs parser in other license, or in GPL with sime exceptions. But of course it will be for concrete person for concrete bot. This GPL release of koraXs parser is for public.

Pierre-Marie Baty 30-07-2004 15:10

Re: koraXs XML/INI/CFG parser for your bot
 
ah :(

it's GPL... :(

well I'm not sure I'll use it then... the GPL license is not a really free one... and it's contaminative
switch to the BSD license, people, this one is TOTALLY free and enables everybody to do whatever he wants with the source (even include it in a commercial project without disclosing it). I don't like using licenses that contaminate my software. Even if I always release the source code anyway, it's a matter of principle. I do it because I feel like so, I NEVER WILL because some license forces me to.

my bot will stay under the BSD license dot period.

koraX 30-07-2004 16:06

Re: koraXs XML/INI/CFG parser for your bot
 
ah, first time I licenced my program and look what happened :)
Well I'm gonna look at that BSD licence ...

koraX 30-07-2004 22:13

Re: koraXs XML/INI/CFG parser for your bot
 
Quote:

Originally Posted by Whistler
@Jozef: Perhaps you had better add an "exception" comment, otherwise (in theory) anyone except you who use it in an HL bot will be actually in violation of GPL...

Well you are right, I was wrong :)

Took me far too long to find it but at the end ... http://www.gnu.org/licenses/gpl-faq....compatibleLibs

And about BSD licence, it is non-copyleft licence, so someone can just take your code, do with it what he wants, make a profit from it and not even mention you. Well but PM you are right that if you would like to use program licensed under GPL, it would force you to release your program under GPL ...

Whistler 31-07-2004 03:47

Re: koraXs XML/INI/CFG parser for your bot
 
about the "BSD Licenses" (plural):
http://www.gnu.org/philosophy/bsd.html

And actually you don't have to GPL all your code if you used parts of GPL code as long as you're using a GPL compatiable license (the BSD License without the advertising clause is among one of them). But you have to state clearly that which part if GPL code (i.e., leave all the "this is free software blahblah..." comments as it was) and include a copy of GPL in it. That means when the software is distributed as a whole it's GPL, but I can just strip all the GPL code and it will be only under BSD License.

take a look at this one:
Quote:

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
<snipped>
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
please note that the original author isn't the only one who is able to do that. As long as you're not "make further restrictions" to the GPL program, it's okay :)

(and I think PM is already in this place due to MegaHAL and Metamod)

Also I don't think anyone is "forcing" anyone to release the source code since we can always not use GPL code. If I use GPL code that means I would like to release the source :)

And here's what I think about simple permissive licenses like BSD, X11, etc: It's totally free, and even give you freedom to make it non-free :D

[back to topic]
That's good thing :) But I don't think I need all the CFG, XML and INI parsing code. Only one format is enough I think.

koraX 31-07-2004 09:07

Re: koraXs XML/INI/CFG parser for your bot
 
Quote:

Originally Posted by Whistler
(and I think PM is already in this place due to MegaHAL and Metamod)

Yes I was thinking the same. If metamod is under GPL and PM is linking to metamod, his program must be under GPL too.

Quote:

Originally Posted by Whistler
That's good thing :) But I don't think I need all the CFG, XML and INI parsing code. Only one format is enough I think.

Only CFG special function is loadCFG and save CFG. Same for INI and XML. All other functions are same for all filetypes. the data from CFG/XML/INI fileas are represented in memory same, so for example you may load from CFG and save to XML (but it is not recommended)

Pierre-Marie Baty 31-07-2004 20:10

Re: koraXs XML/INI/CFG parser for your bot
 
Quote:

Yes I was thinking the same. If metamod is under GPL and PM is linking to metamod, his program must be under GPL too.
Heh. Both of you already bitched me some day about this, and be certain that I am aware of it. I've always been anyway. The metamod issue will be solved as soon as I have split all my code between what's portable between game engines (most of it) and the HL game driver (a few function calls). And the MegaHAL issue will certainly be delt with soon too. I used MegaHAL because I find it interesting, but I will without any regret scrap it completely from my bot code if ANY person wants me to release my bot under the GPL. My bot will NEVER be GPL'ed. EVER. The GPL is not a free license. Under the excuse of granting the end users back the right to use the source code it takes away from the developers the right to disclose or not this source code - which is THEIRS.

stefanhendriks 31-07-2004 20:32

Re: koraXs XML/INI/CFG parser for your bot
 
make ur own license! :D

Whistler 01-08-2004 06:14

Re: koraXs XML/INI/CFG parser for your bot
 
I've already said that you don't need to GPL all the bot code, you just need to use a GPL compatiable license (i.e., don't make "further restrictions". I think you've already done that) and include a copy of GPL in the distribution. Make sure you have stated clearly which part is GPL code and which part is not. Then I'll be able to strip all the GPL code and use the rest in my proprietary software.

I'm also not saying BSD license is absolutely bad although I would prefer GPL. I'm also using BSD license for some of my programs.

Also please note that some parts of the codes in RACC are NOT YOURS. AT LEAST NOT FULLY YOURS. EVER. They are botman's and Jason Hutchens's (well, if botman doesn't care your doing this with his BSP Tools, then it will be no problem). The original authors don't want it to be used in proprietary program. You are actually allowing proprietary software developers use those codes which are NOT yours. I don't think anyone has freedom to do this. It's the original author's freedom to decide whether the code can be used in any way or not. I also don't think that's quite different from releasing some company's proprietary source code under a free software license without permission in some way.

I'm not going to continue on this topic anyway, because it's nothing to do with the topic of this thread. (well, sorry but perhaps I should take the first post to the private message or Jozef's own forum, [excuse]that's not completely offtopic anyway[/excuse]).

sfx1999 01-08-2004 07:05

Re: koraXs XML/INI/CFG parser for your bot
 
The BSD lisense is not GPL compatible. Damn.

Anyway, there IS a work around for linking GPL programs. I think PMB may be able to figure this out.

Quote:

If a program released under the GPL uses plug-ins, what are the requirements for the licenses of a plug-in.

It depends on how the program invokes its plug-ins. If the program uses fork and exec to invoke plug-ins, then the plug-ins are separate programs, so the license for the main program makes no requirements for them.

If the program dynamically links plug-ins, and they make function calls to each other and share data structures, we believe they form a single program, so plug-ins must be treated as extensions to the main program. This means they must be released under the GPL or a GPL-compatible free software license, and that the terms of the GPL must be followed when those plug-ins are distributed.

If the program dynamically links plug-ins, but the communication between them is limited to invoking the `main' function of the plug-in with some options and waiting for it to return, that is a borderline case.
http://www.gnu.org/licenses/gpl-faq....CGPLAndPlugins

Whistler 01-08-2004 16:50

Re: koraXs XML/INI/CFG parser for your bot
 
"The BSD lisense is not GPL compatible. Damn."
The *old* BSD License is not GPL compatiable. The one after 1999, which is without the advertising clause, IS GPL compatiable.
I think PM's BSD License is without the advertising clause so it's no problem.

Pierre-Marie Baty 01-08-2004 22:48

Re: koraXs XML/INI/CFG parser for your bot
 
Quote:

Originally Posted by Whistler
Also please note that some parts of the codes in RACC are NOT YOURS. AT LEAST NOT FULLY YOURS. EVER. They are botman's and Jason Hutchens's (well, if botman doesn't care your doing this with his BSP Tools, then it will be no problem).

Wrong, the only bit of code which is not mine here is Jason Hutchen's MegaHAL implementation. There is no more code from botman in RACC - at all. The bot has been completely rewritten from *scratch* (which is quite different than taking another fresh HPB_template and starting modifying it again). Even the BSP related functions are different from botman's : I used the BSP tools to understand how the BSP files were arranged but I wrote the BSP reader myself. Only in the navmesh tutorial I published, I refer to the BSP_tools code directly, but that's just for clarity and simplicity. My own code is NOT based on the BSP_tools source code (although similar, because in these matters there are not two ways of doing things right).

I would be VERY upset if someone were to tell me that this bot I am banging my head on for years now is not fully mine!!! >:(

sfx1999 02-08-2004 07:25

Re: koraXs XML/INI/CFG parser for your bot
 
So PMB can you figure out that fork() and exec() thing?


All times are GMT +2. The time now is 20:18.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.