Hosted by:
|
|
The AI motor
5.3) Births and Deaths:
The functions kill_pnj and gener_pnj are quite similar.
kill_pnj begin with removing the entity from the cell: clear_pos(numero)
So we have to reorganize our pnj_tab, because we don't wank some blank spaces with dead people.
pnj_tab[numero]=pnj_tab[nombre_pnj-1]; :a new young entity takes the place of the dead man.
pnj_tab[numero]->id = numero; the young guy has a new Id.
Then:
nombre_pnj--; :one less.
pnj_tab = (struct _perso **) realloc(pnj_tab,nombre_pnj*sizeof(struct _perso*)); :pnj_tab is smaller.
gener_pnj begin with quite classic stuff.
We create a new entity, with a name, a sex,...
Here are som interesting things:
- to know the species of the baby, we compare the father and mother species:
if ((mere->pere->espece)!=(mere->espece))
mere->pere gives you the father's structure, so mere->pere->espece gives you the father's species.
If the two parent comes from the same specie, the baby has the same.
If not, the baby is a "chimere".(species n°5)
- the sociability is defined by the mother characteristics:
If the mother was living in a colony, we can admit that the baby will grouw in the colony, and become more sociable than his mother.
If not, the entity will be afraid by too many people.
- Previous - Next -
|