Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - apanx

Pages: 1 [2]
21
Modifications / Robot Arena 2 - What goes on behind the GUI
« on: July 25, 2009, 03:22:13 PM »
Long post with lots of text. It is not guaranteed to be all comprehensive or correct.
 
When the Robot Arena 2 executable is loaded. The first thing it does that is related to Python is to load the Main.py found in the Scripts folder. The Main.py starts by importing all the C++ commands that is avaliable in Python form, the plus library. It also reroutes all console output from Python scripts to the Debug box, which makes this an excellent place to add a file output to.
Code: [Select]
class giScript_stdout:
    def write(self, s):
        giScript.debug_stdout(s)
        output = file("debug.txt", "a")
        output.write(str(s))
   
class giScript_stderr:
    def __init__(self):
        self.count = 0
    def write(self, s):
        self.count += 1
        output = file("debug.txt", "a")
        output.write(str(s))
        giScript.debug_stderr(s)
    def flush(self):
        pass

It then initiates the loading of Arenas followed by AI. The Arena and AI folder is interpreted by Python, which starts by reading __init__.py. The Practice arena is the first to be loaded. After that, the loading of all avaliable AI begins which continues by creating a list containing all bindings, which is what bindings.py does. In order to draw up all the GUI portions, the game queries the gib files found under the UI folder. These contain instructions on how to draw up all the elements on the screen.
In order to populate the Player and the AI teams, the game queries the Teams.txt and fills up the slots accordingly. Unfortunately it does not create the folders (Team1, Team2... and so on) if they are missing, leading to problems with creating new teams in-game since the data cannot be saved in a nonexisting path. All components and textures are also loaded at this stage.
 
When a match is started, the Arena chosen is created by the game. Which gets its basic properties from the SuperArena in __init__.py. The resulting Arena is a combination of the python code for the Arena and the SuperArena takes care of the sections that are not defined in the current Arenas own python code.
 
This is followed by a cleaning up of the AI stack which disables all running AI by emptying the running_ai global variable. The game then reads the name of the AI bot and queries the Binding list created earlier for the AI script to be loaded.
 
Every AI gets the Invert and Unstuck tactics assigned to themselves by the __init__.py, or SuperAI. All AIs are additions to the SuperAI, which provides basic functionality to the AI. The code in the SuperAI can be overridden by adding the same section in your own AI.
 
The Arena and AI are activated and the code under the Activate section is run. During the match the code under the Tick section for both the Arena and the AI is run. Usually the time between each tick is 250ms for an Arena and 125ms for an AI. This continues until Winners are declared, or the game quit by user.

22
Modifications / How is such a thing possible?
« on: July 24, 2009, 12:18:25 PM »

 

 
How is such a thing possible?

23
Modifications / How is such a thing possible:o
« on: July 24, 2009, 12:14:52 PM »

 
How is such a thing possible:o

24
Other Tutorials / Get more than nine buttons on the controller
« on: June 15, 2009, 03:54:05 PM »
Pesky nine button limit ruining your dreams of a AI controlled Machine-gun tank?
All the cool kids have more than nine buttons on their controllers so why should you not?
You only need to take up the dark art of bot file editing for it to work.

1. Wire up nine slots.
2. Realise you need more
3. Open bot file using text editor capable of interpreting linefeed(0x10) only as newline, that means Notepad++ or TextPad (or vi or EMACS)
4. Hax :P. Find the section describing your controllers.

Looks like this

Name: Forward
2 0 1
2
1 0 3 0
1 0 2 0

or this:

Name: 1
0 0 4
1
0 0 8 0

or like this:

Name: Spin
2 0 2
1
0 0 57 0

Now the first row is the name, the second row is the one we are interested in. You see, the standard uncool controller only gives us positions X= 0-2, Y=0-2. By moving already defined controls out to lets say X=3,Y=4. We can free up space from the part the uncool kidds can play with. It is also possible to stack controllers on each other, just be sure you do not want to change them, cause that is going to be annoying.
(X,Y,Type of control 1=analog, 2=switch, 4=button)
The third row is just the number of keys that are bound to the control. 1 for swtiches and buttons, 2 for analog.
The fourth row is some cryptic keycodes. Dont mess with these unless you have a cheat sheet tucked away somewhere.

5. If you need even more keys, Goto 1 else end.

GL HF


You too can have a nice controller. Do not touch it(edit anything in botlab), or it will break.

Pages: 1 [2]