|Chapter 6||To index||
Haski the Robot
Perhaps, if you have some ideas of your own or, for instance, are a teacher preparing a basic course at school, you want to design and use your own working areas for Haski. These definitions are stored in the .map-files inside the subfolder maps within the Haski-directory, which are plain text files, i.e. they can be edited and created with any text editor.
In order to define which things are to be put where on the working area Haski uses a simple system for numbering the fields: The top left field is assigned number 0, the field to the right is number 1 and so on. After completion of a line (20 fields) the counting continues at the beginning of the next line. To clarify things here is a little picture of the top left corner of the working area:
Now, how are these numbers actually used? It's quite simple, for every element on the working area (robots, walls, items) you put one entry into the file:
A robot can be added with the entry
where p, n and f are integers and have the following meaning:
p is the field the robot will start at, 'encoded'
as described above
n is the number of items the robot will be equipped with initially
f is the direction the robot will be facing, where 0=up, 1=right, 2=down, 3=left
When you define several robots in you mapfile, the order in which they are defined is used for assigning the programs from the command line argument when starting Haski.
A stack of items can be put on a specific field with the entry
Again p and n are integers:
p is the field where the items will be placed
n is the number of items on that field
If you want a wall between the two fields p and q just put the following into your map file:
It should be clear that the difference between p and q has to be either 1 (if it's a vertical wall) or 20 (if it's a horizontal one).
Putting it all together
The map file parser doesn't care about spaces and newlines, so you are free to arrange things as you like. Additionally you can seperate the individual entries with a comma, but it's not needed.
If your map definitions grow a little bigger and you want to keep track of which entries correspond to what, you can add comments to your file by typing two hyphens ("--"), everything that comes after those (until the end of the current line) will be ignored on parsing.
If you want some examples you can have a look at the map files that were included with Haski.
Back to the index
|by Lars Otten, 2004|