亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? demo12_7.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
               ants[index].counter_2 = RAND_RANGE(10, 100);

               // start animation
               Set_Animation_BOB(&ants[index], ants[index].varsI[ANT_INDEX_DIRECTION]);

               } break;

          case ANT_EATING:         // at a mnm eating it
               {
               // set state to eating
               ants[index].varsI[ANT_INDEX_AI_STATE] = ANT_EATING;

               // start eating the mnm indexed by var1 
               ants[index].varsI[ANT_INDEX_MNM_BEING_DEVOURED] = var1;

               // counters not used in this state

               } break;          

          case ANT_RESTING:        // sleeping :)
               {
               // set the ai state of ant
               ants[index].varsI[ANT_INDEX_AI_STATE] = ANT_RESTING;

               // set how long to rest
               ants[index].counter_1 = RAND_RANGE(50, 200);
              

               } break;

          case ANT_SEARCH_FOOD:    // hungry and searching for food
               {
               // set state to search for food
               ants[index].varsI[ANT_INDEX_AI_STATE]    = ANT_SEARCH_FOOD;

               // start off by scanning for food
               ants[index].varsI[ANT_INDEX_AI_SUBSTATE] = ANT_SEARCH_FOOD_S1_SCAN;

               // initialize targets tp 0
               ants[index].varsI[ANT_INDEX_FOOD_TARGET_X] = 0;
               ants[index].varsI[ANT_INDEX_FOOD_TARGET_Y] = 0;


               } break;

          case ANT_COMMUNICATING:  // talking to another ant  
               {

               // set the ai state of ant
               ants[index].varsI[ANT_INDEX_AI_STATE] = ANT_COMMUNICATING;

               // set how long to communicate
               ants[index].counter_1 = RAND_RANGE(60, 90);

               // when counter 2 hits 5 then exchange memory
               // thus about 5-10% of the memories will be exchanged
               ants[index].counter_2 = 0;

               } break;

          case ANT_DEAD:           // this guy is dead, got too hungry
               {
               // set the ai state of ant
               ants[index].varsI[ANT_INDEX_AI_STATE] = ANT_DEAD;

               // set direction
               ants[index].varsI[ANT_INDEX_DIRECTION] = ANT_ANIM_DEAD;
    
               // start animation
               Set_Animation_BOB(&ants[index], ants[index].varsI[ANT_INDEX_DIRECTION]);
 
               } break;

          default: break;

          } // end switch             

} // end Set_New_State


//////////////////////////////////////////////////////////////////////

void Move_Ants(void)
{
// this function moves all the ants and processes the ai

// up, right, down, left
static int ant_movements_x[4] = { 0,2,0,-2};
static int ant_movements_y[4] = {-2,0,2, 0};

static int clear_ilayer = 0; // tracks when to clear the input memory layer

int index;
int select_new_state = -1;

for (index=0; index < NUM_ANTS; index++)
    {
    // reset new state selector
    select_new_state = -1;

    // what state is ant in?
    switch(ants[index].varsI[ANT_INDEX_AI_STATE])
          {
           case ANT_WANDERING:      // moving around randomly
               {
               // in this state the ant selects random directions and then
               // walks for some period in that direction, if during the ants
               // walk, it stumbles across some food, then it will remember
               // the rough position of the food in int memory
               // burns 1 unit per cycle 

               // move the ant
               ants[index].x+=ant_movements_x[ants[index].varsI[ANT_INDEX_DIRECTION]];
               ants[index].y+=ant_movements_y[ants[index].varsI[ANT_INDEX_DIRECTION]];

               // test if ant is done with direction and needs a new one
               if (--ants[index].counter_2 < 0)
                  {
                  // set direction
                  ants[index].varsI[ANT_INDEX_DIRECTION] = RAND_RANGE(ANT_ANIM_UP, ANT_ANIM_LEFT);
    
                  // time in this new direction
                  ants[index].counter_2 = RAND_RANGE(10, 100);

                  // start animation
                  Set_Animation_BOB(&ants[index], ants[index].varsI[ANT_INDEX_DIRECTION]);

                  } // end if new direction

               // burn food
               ants[index].varsI[ANT_INDEX_HUNGER_LEVEL]++;

               // update memory with presence of food
               int ant_cell_x = ants[index].x / 30;
               int ant_cell_y = ants[index].y / 30;

               // this updates the i,jth memory cell in ant with info about food
               ants_mem[index].cell[ant_cell_x][ant_cell_y] =
                   ANT_MEMORY_RESIDUAL_RATE*ants_mem[index].cell[ant_cell_x][ant_cell_y] + 
                   (1-ANT_MEMORY_RESIDUAL_RATE)*Food_Near_Ant(ant_cell_x, ant_cell_y);

               // test if we are done with this state and need a new one?
               if (--ants[index].counter_1 < 0)                                        
                  {
                  // select either rest or wander, search will pre-empt with logic following
                  // if hungry, state, probability of state, must sum to 100
                  select_new_state = Select_State_Rand(ANT_WANDERING,     70,            
                                                       ANT_EATING,        0,                
                                                       ANT_RESTING,       30,              
                                                       ANT_SEARCH_FOOD,   0,           
                                                       ANT_COMMUNICATING, 0,         
                                                       ANT_DEAD,          0);                    
                   } // end if

   
               // test for pre-empt into communication mode
               for (int dialog_ant = 0; dialog_ant < NUM_ANTS; dialog_ant++)
                   {

                   // try and talk if this isn't the same ant just talked to and this ant
                   // is either resting or wandering
                   if ( ( (dialog_ant!=index) && (ants[index].varsI[ANT_INDEX_LAST_TALKED_WITH] != dialog_ant) ) &&
                        ((ants[dialog_ant].varsI[ANT_INDEX_AI_STATE] == ANT_RESTING) ||
                         (ants[dialog_ant].varsI[ANT_INDEX_AI_STATE] == ANT_WANDERING)) )
                        {
                        // are they close enough to talk?
                        if ((abs(ants[index].x - ants[dialog_ant].x) < 8)  &&
                            (abs(ants[index].y - ants[dialog_ant].y) < 8) )
                            {
                            // set both ants to communicate mode
                            Set_New_State(ANT_COMMUNICATING,index);              
                            Set_New_State(ANT_COMMUNICATING,dialog_ant);
                      
                            // set communicate partners for chat
                            ants[index].varsI[ANT_INDEX_LAST_TALKED_WITH]      = dialog_ant;
                            ants[dialog_ant].varsI[ANT_INDEX_LAST_TALKED_WITH] = index;

                            break;
                            } // end if
                              
                        } // end if

                   } // end for dialog_ant
 

               // test for pre-empt into search mode if hunger is 75% tolerance
               if (ants[index].varsI[ANT_INDEX_HUNGER_LEVEL] > (0.75*ants[index].varsI[ANT_INDEX_HUNGER_TOLERANCE]) )
                  {
                  select_new_state = ANT_SEARCH_FOOD;
                  } // end if                   

        

               } break;

          case ANT_EATING:         // at a mnm eating it
               {
               // in this state the ant is eating and at rest, the ant will
               // eat from a single mnm until it puts itself to 50% of its hunger tolerance
               // and then stop or if the food runs out it will stop
               // ants eat at a rate of 5 energy units per cycle 
               // burns 1 unit per cycle
         
               // eat the mnm up until its gone or the hunger level drops to 50%
                     
               // decrease food supply
               food[ants[index].varsI[ANT_INDEX_MNM_BEING_DEVOURED]].energy-=BITE_SIZE;

               // transfer to ant and decrease hunger level BITE_SIZE units 
               ants[index].varsI[ANT_INDEX_HUNGER_LEVEL]-=BITE_SIZE;

               // is food supply depleted?
               if (food[ants[index].varsI[ANT_INDEX_MNM_BEING_DEVOURED]].energy < 0)
                  {
                  food[ants[index].varsI[ANT_INDEX_MNM_BEING_DEVOURED]].energy = 0;

                  // transfer to search state or rest a sec
                  select_new_state = Select_State_Rand(ANT_WANDERING,     0,            
                                                       ANT_EATING,        0,                
                                                       ANT_RESTING,       30,              
                                                       ANT_SEARCH_FOOD,   70,           
                                                       ANT_COMMUNICATING, 0,         
                                                       ANT_DEAD,          0);  

                                
                  } // end if

               // test if done eating?, i.e. hunger < 50% tolerance
               else
               if (ants[index].varsI[ANT_INDEX_HUNGER_LEVEL] < 
                   (0.50*ants[index].varsI[ANT_INDEX_HUNGER_TOLERANCE]) )
                  {
                  // switch to another state
                  select_new_state = Select_State_Rand(ANT_WANDERING,     50,            
                                                       ANT_EATING,        0,                
                                                       ANT_RESTING,       30,              
                                                       ANT_SEARCH_FOOD,   20,           
                                                       ANT_COMMUNICATING, 0,         
                                                       ANT_DEAD,          0);    


                  } // end if

               } break;          

          case ANT_RESTING:        // sleeping :)
               {
               // ant is simply resting and burns 1 unit per cycle                 

               // test if we are done with this state and need a new one?
               if (--ants[index].counter_1 < 0)                                        
                  {
                  // select either rest or wander, search will pre-empt with logic following
                  // if hungry, state, probability of state, must sum to 100
                  select_new_state = Select_State_Rand(ANT_WANDERING,     90,            
                                                       ANT_EATING,        0,                
                                                       ANT_RESTING,       10,              
                                                       ANT_SEARCH_FOOD,   0,           
                                                       ANT_COMMUNICATING, 0,         
                                                       ANT_DEAD,          0);                    
                 } // end if

               // burn food
               ants[index].varsI[ANT_INDEX_HUNGER_LEVEL]++;


               // test for pre-empt into search mode if hunger is 50% tolerance
               if (ants[index].varsI[ANT_INDEX_HUNGER_LEVEL] > (ants[index].varsI[ANT_INDEX_HUNGER_TOLERANCE] >> 1) )
                  {
                  select_new_state = ANT_SEARCH_FOOD;
                  } // end if    



               } break;

          case ANT_SEARCH_FOOD:    // hungry and searching for food
               {
               // in this state the ant is looking for food based on its memory
               // if the memory is blank then random walks
               // if the ant gets to a location and cant find any food where its
               // memory found some then the memory for that food location is degraded by 1
               // searching takes 2 units of energy per cycle

#if 0
               ants[index].varsI[ANT_INDEX_AI_STATE]    = ANT_SEARCH_FOOD;

               // start off by scanning for food
               ants[index].varsI[ANT_INDEX_AI_SUBSTATE] = ANT_SEARCH_FOOD_S1_SCAN;

               // initialize targets tp 0
               ants[index].varsI[ANT_INDEX_FOOD_TARGET_X] = 0;
               ants[index].varsI[ANT_INDEX_FOOD_TARGET_Y] = 0;

#endif

               // test substate
               switch(ants[index].varsI[ANT_INDEX_AI_SUBSTATE])
                     {     

                     case ANT_SEARCH_FOOD_S1_SCAN:
                          {
                          // this state is transient and doesn't persist, so
                          // no energy expended by it

                          // scan for a "hot" cell
                          float max_energy = 0;
                          int cell_x = 0, cell_y = 0;
                        
                          for (int index_x = 0; index_x < 16; index_x++)
                              for (int index_y = 0; index_y < 16; index_y++)
                                  // does this cell have more food?
                                  if (ants_mem[index].cell[index_x][index_y] > max_energy)
                                     {
                                     // update new max
                                     max_energy = ants_mem[index].cell[index_x][index_y]; 
                                     cell_x = index_x; cell_y = index_y;

                                     } // end if

                          // test max and see if we have a winner?
                          if (max_energy > 0)
                             {
                             // vector to this cell
                            ants[index].varsI[ANT_INDEX_AI_SUBSTATE] = ANT_SEARCH_FOOD_S3_VECTOR_2CELL;

                            // send to cell center
                            ants[index].varsI[ANT_INDEX_FOOD_TARGET_X] = 30*cell_x+15;
                            ants[index].varsI[ANT_INDEX_FOOD_TARGET_Y] = 30*cell_y+15;                              

                            // set counters to 0
                            ants[index].counter_1 = ants[index].counter_2 = 0;                           

                             } // end if
                           else
                              { 
                              // go into wander mode, no knowledge of food
                              // vector to this cell
                              ants[index].varsI[ANT_INDEX_AI_SUBSTATE] = ANT_SEARCH_FOOD_S2_WANDER;

                              // set counters 
                              ants[index].counter_1 = RAND_RANGE(100,150);
                              ants[index].counter_2 = 0;  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩免费看的电影| 夜夜嗨av一区二区三区| 最新欧美精品一区二区三区| 亚洲国产精品视频| 国产69精品久久99不卡| 欧美日韩在线观看一区二区 | 国产精品视频观看| 水蜜桃久久夜色精品一区的特点| 久久99日本精品| 在线免费精品视频| 国产精品久久久久久久裸模| 六月丁香婷婷色狠狠久久| 一本色道a无线码一区v| 国产婷婷一区二区| 久久成人av少妇免费| 欧美日韩一区二区欧美激情| 亚洲私人黄色宅男| 不卡的电影网站| 国产亚洲福利社区一区| 韩国女主播成人在线| 91精品国模一区二区三区| 一区二区在线观看av| 福利视频网站一区二区三区| 欧美日韩高清一区二区| 亚洲国产综合色| 欧美又粗又大又爽| 亚洲靠逼com| 色综合视频一区二区三区高清| 国产精品私人影院| 国产成人福利片| 欧美日韩和欧美的一区二区| 欧美在线免费播放| 日韩一级片在线观看| 亚洲午夜在线观看视频在线| 色综合久久66| 亚洲综合区在线| 欧美日韩中文国产| 亚洲电影你懂得| 欧美人成免费网站| 日韩国产在线观看| 91精品国产高清一区二区三区| 亚洲国产毛片aaaaa无费看 | 欧美日韩免费电影| 五月婷婷综合激情| 日韩欧美视频一区| 激情综合色播五月| 国产亚洲精品bt天堂精选| 成人aaaa免费全部观看| 亚洲区小说区图片区qvod| 欧美亚洲图片小说| 蜜桃久久久久久久| 国产日本亚洲高清| 一本久久综合亚洲鲁鲁五月天 | 国产精品免费视频观看| 91在线观看成人| 亚洲电影第三页| 精品国产乱子伦一区| 国产成人免费高清| 一区二区三区在线视频观看58| 日本二三区不卡| 五月激情六月综合| 日本一区二区在线不卡| 欧美自拍偷拍午夜视频| 美女看a上一区| 国产欧美精品一区二区色综合朱莉 | 国产成人精品亚洲午夜麻豆| 亚洲欧美自拍偷拍色图| 欧美乱熟臀69xxxxxx| 国产一区在线不卡| 亚洲美女屁股眼交3| 91精品国产免费| 粉嫩一区二区三区性色av| 一区二区三区成人在线视频| 精品奇米国产一区二区三区| av影院午夜一区| 免费成人小视频| 综合久久一区二区三区| 91精品国产欧美日韩| 91天堂素人约啪| 国产乱人伦精品一区二区在线观看 | 91一区二区在线| 奇米精品一区二区三区在线观看| 亚洲国产精品传媒在线观看| 337p亚洲精品色噜噜| 成人激情av网| 久久99精品久久久久久久久久久久| 中文字幕综合网| 久久久综合九色合综国产精品| 精品视频色一区| 成人国产亚洲欧美成人综合网| 日韩在线播放一区二区| 亚洲色欲色欲www| 国产亚洲美州欧州综合国| 欧美一区二区三区四区视频| 欧美专区在线观看一区| 91免费国产在线| 成人中文字幕合集| 国产精品一区一区| 美腿丝袜亚洲综合| 亚洲成人免费影院| 亚洲综合免费观看高清完整版在线| 欧美激情在线免费观看| 久久网站最新地址| 欧美高清性hdvideosex| 欧美三级日本三级少妇99| 色噜噜狠狠成人中文综合| av在线综合网| 成人激情图片网| 成人av在线电影| 成人网在线播放| 国产成人高清视频| 高清beeg欧美| 粉嫩av一区二区三区在线播放| 极品少妇xxxx精品少妇| 青青草国产精品97视觉盛宴| 午夜a成v人精品| 日韩av电影免费观看高清完整版 | 欧美一级免费大片| 欧美色视频一区| 欧美日韩在线播放三区| 欧美三级午夜理伦三级中视频| 色婷婷激情综合| 欧美日韩在线直播| 91精品一区二区三区久久久久久 | 欧美日韩精品一区二区三区蜜桃| 91麻豆国产福利精品| 欧日韩精品视频| 欧美日韩一区二区三区在线| 在线播放中文字幕一区| 正在播放亚洲一区| 精品剧情在线观看| 国产视频在线观看一区二区三区| 国产欧美在线观看一区| 亚洲欧洲韩国日本视频| 亚洲综合一区在线| 欧美aaaaa成人免费观看视频| 麻豆一区二区三区| 国产成人av电影在线观看| 成人性色生活片免费看爆迷你毛片| 国产sm精品调教视频网站| 成人视屏免费看| 欧美在线视频你懂得| 欧美一区二区三区色| 国产视频在线观看一区二区三区| 国产精品美女久久久久aⅴ| 亚洲麻豆国产自偷在线| 日本强好片久久久久久aaa| 国产一区二区主播在线| 色综合久久88色综合天天6| 在线电影一区二区三区| 久久精品网站免费观看| 一二三区精品福利视频| 久久国产福利国产秒拍| 91老司机福利 在线| 欧美一区二区在线免费观看| 国产日韩欧美一区二区三区乱码| 一区二区免费在线播放| 国产一区中文字幕| 色婷婷综合久久久久中文 | 国产精品电影院| 男人的天堂久久精品| 成人一区二区视频| 91精品在线免费观看| 亚洲欧洲av在线| 韩国成人福利片在线播放| 色av综合在线| 中文字幕精品综合| 日本午夜精品一区二区三区电影| 波多野结衣中文字幕一区二区三区 | 免费一级片91| 91美女在线看| 久久精品这里都是精品| 日本系列欧美系列| 91麻豆精品在线观看| 久久亚洲欧美国产精品乐播 | 日韩欧美中文字幕精品| 亚洲精品中文在线观看| 国产精品99久久久久久有的能看| 欧美性大战xxxxx久久久| 国产精品麻豆久久久| 国产美女精品人人做人人爽| 欧美日本一道本| 亚洲一区二区三区精品在线| 91亚洲国产成人精品一区二区三| 久久亚洲精品国产精品紫薇| 日韩和欧美一区二区三区| 91视频www| 中文字幕日本不卡| 成人美女在线视频| 国产日韩欧美高清在线| 激情图区综合网| 日韩欧美成人激情| 免费高清成人在线| 日韩区在线观看| 日本aⅴ亚洲精品中文乱码| 欧美午夜精品久久久久久超碰 | 国产精品欧美精品| 国产一区二区三区不卡在线观看| 日韩欧美第一区| 国产一区二区三区|