bot-evolution-simulation

This program is a terrarium of little bots who undergo ruthless evolution in a 2D world with it's own rules.
Log | Files | Refs | README | LICENSE

bots.pixi (770B)


      1 fn bot_life_status($bot) {
      2     // if bot died of hunger or dehydration
      3     if (BOTS[$bot].energy == 0) || (BOTS[$bot].thirst == 0) {
      4         // pronounce bot deceased
      5         BOTS[$bot].is_alive = 0
      6         
      7         // change cell type to empty (0)
      8         CELLS[BOTS[$bot].cell].type = 0
      9         
     10         // erase bot from it's current position
     11         fbox(BOTS[$bot].x_coord, BOTS[$bot].y_coord, CELL_SIZE - 1, CELL_SIZE - 1, COL_BOT_DEAD)
     12         //print("X", BOTS[$bot].x_coord + (CELL_SIZE / 2), BOTS[$bot].y_coord + (CELL_SIZE / 2), BLACK)
     13     }
     14 }
     15 
     16 fn num_bots_alive() {
     17     $count = 0
     18     $i = 0
     19     while ($i < BOTS_QTY) {
     20         if (BOTS[$i].is_alive == 1) {
     21             $count = $count + 1
     22         }
     23         
     24         $i = $i + 1
     25     }
     26     
     27     ret($count)
     28 }