Hosted by:
|
|
The AI motor
The AI main file is "darwin_sim.c".
1) Creating the world :
Entities walk in a linked list with 4 pointers:
North, south, east, west.
The "map" is so a grid, using this type of structure is faster than using an array.
typedef struct _list { //cellule
struct _lieu lieu;
struct _list *fg;
struct _list *fd;
struct _list *fh;
struct _list *fb;
} _list;
The first function call in the program is:
map = amng_terrain(generation_terrain());
generation_terrain() is the function who creates the map.
Ths function calls gener_cell(map,NULL), who creates the grid.
As you can see, the structure contains another structure called struct _lieu.
This structure contains informations about the cell:
struct _lieu {
int terrain; //forest, desert,...
int nombre_pnj; //how many people here ??
int *Id; //array containnig pointers to the present entities
int pos_v; //latitude
int pos_h; //longitude
};
At first, a simple list is created, containing MAX_V per MAX_H cells.
After that, we call align_cell(map) and broke_lnk(map) who will create or destroy some links...
We have here our basic grid.
We uses now the function amng_terrain, who creates some forests in the map.
And that's all for now...
We would here add loch, mountains,etc. in future release.
- Previous - Next -
|