aimast.c

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 Michael K. McCarty & Fritz Bronner
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 // Interplay's BUZZ ALDRIN's RACE into SPACE
00019 //
00020 // Formerly -=> LiftOff : Race to the Moon :: IBM version MCGA
00021 // Copyright 1991 by Strategic Visions, Inc.
00022 // Designed by Fritz Bronner
00023 // Programmed by Michael K McCarty and Morgan Roarty
00024 //
00025 /** \file aimast.c AI Master Routines
00026  */
00027 
00028 #include "Buzz_inc.h"
00029 #include "externs.h"
00030 
00031 extern char Month[12][11];
00032 extern char AI[2];
00033 char G[3];
00034 char Level_Check;
00035 extern char Nums[30][7];
00036 enum Opponent_Status Cur_Status;
00037 
00038 // Track[0] - orbital satellite
00039 // Track[1] - end stage location holder
00040 // Track[2] - holds lunar module
00041 // Track[3] - strategy 0=none 1=one 2=two
00042 // Track[4] - beginning game status
00043 // Track[5] - larger rocket (3-stage)
00044 // AILunar  - way to the moon
00045 // AIPrim   - primary program
00046 // AISec    - secondary program
00047 
00048 void AIMaster(char plr)
00049 {
00050  int val,i,P_total=0,O_total=0;
00051  char prg[2];
00052  if (plr==0) Level_Check=(Data->Def.Lev1==0) ? 0 : 1;
00053   else  if (plr==1) Level_Check=(Data->Def.Lev2==0) ? 0 : 1;
00054 //select strategy
00055  P_total=random(100);
00056  if (Data->P[plr].Track[3]==0)
00057   {
00058    if (P_total<33) Data->P[plr].Track[3]=1;
00059     else if (P_total<66) Data->P[plr].Track[3]=2;
00060      else Data->P[plr].Track[3]=3;
00061   }
00062  Cur_Status=Equal;
00063 // *** check status ***
00064   for (i=0;i<Data->P[plr].PastMis;i++)
00065      P_total+=Data->P[plr].History[i].Prestige;
00066   for (i=0;i<Data->P[other(plr)].PastMis;i++)
00067      O_total+=Data->P[other(plr)].History[i].Prestige;
00068   if (P_total>O_total) Cur_Status=Ahead;
00069    else if (P_total==O_total) Cur_Status=Equal;
00070     else if (P_total<O_total) Cur_Status=Behind;
00071   if (Data->Year==59 && Data->Season==1) Data->P[plr].Track[4]=0;
00072   if (Data->P[plr].AstroDelay<=0) AIAstroPur(plr);
00073   if (Data->P[plr].AIStat==1)
00074      if (Data->Prestige[0].Place==plr || Data->Prestige[0].mPlace==plr) Data->P[plr].AIStat=2;
00075   if (Data->P[plr].AIStat==1 && PreChe(plr,1)==0 && Cur_Status==Behind) Data->P[plr].AIStat=2;
00076   if (Data->P[plr].AIStat==2 && Data->Year>=61 && Data->Season==0) Data->P[plr].AIStat=3;
00077   if (Data->P[plr].AIStat<=2)
00078   {
00079      if (GenPur(plr,0,0)) RDafford(plr,0,0);
00080      else RDafford(plr,0,0);
00081      if (GenPur(plr,1,0)) RDafford(plr,1,0);
00082      else RDafford(plr,1,0);
00083      Data->P[plr].Buy[0][0]=0;Data->P[plr].Buy[1][0]=0;
00084      Data->P[plr].Buy[2][0]=0;
00085      if (Data->Year<=59)
00086      {
00087         Data->P[plr].Probe[0].Num++;
00088         Data->P[plr].Rocket[0].Num++;
00089         AIFuture(plr,1,0,0);
00090      }
00091   KeepRD(plr,5);
00092   Data->P[plr].Buy[0][0]=0;Data->P[plr].Buy[1][0]=0;
00093   Data->P[plr].Buy[2][0]=0;
00094   RDafford(plr,2,0);RDafford(plr,1,0);
00095   if (Data->P[plr].AIStat<2) AIPur(plr);
00096   prg[0]=1;
00097   if (NoFail(plr)==0)
00098    {
00099     if ((Data->Year==59 && Data->Season==1) || Data->Year>=60)
00100      {
00101       switch(Data->P[plr].Track[4])
00102        {
00103         case 0:if (Data->P[plr].Misc[3].Safety>Data->P[plr].Misc[3].MaxRD-20)
00104                 AIFuture(plr,6,0,(char *)&prg); else AIFuture(plr,2,0,(char *)&prg);
00105                Data->P[plr].Manned[0].Safety+=10;Data->P[plr].Misc[3].Safety+=10;
00106                ++Data->P[plr].Track[4];
00107                break;
00108         case 1:if (PreChe(plr,27)==0 && PreChe(other(plr),27)==0)  // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00109                 AIFuture(plr,2,0,(char *)&prg);
00110                  else if (PreChe(plr,18)==0 && PreChe(other(plr),18)==0)  // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00111                   AIFuture(plr,4,0,(char *)&prg);
00112                    else if (PreChe(plr,27)==0 && PreChe(other(plr),27)==1) // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00113                   AIFuture(plr,4,0,(char *)&prg);
00114                  else if (PreChe(plr,18)==0 && PreChe(other(plr),18)==1) // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00115                 AIFuture(plr,2,0,(char *)&prg);
00116                ++Data->P[plr].Track[4];
00117                break;
00118         case 2:if (PreChe(plr,27)==0 && PreChe(other(plr),27)==0)  // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00119                 AIFuture(plr,2,0,(char *)&prg);
00120                  else if (PreChe(plr,18)==0 && PreChe(other(plr),18)==0)  // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00121                   AIFuture(plr,4,0,(char *)&prg);
00122                    else if (PreChe(plr,27)==0 && PreChe(other(plr),27)==1) // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00123                   AIFuture(plr,4,0,(char *)&prg);
00124                  else if (PreChe(plr,18)==0 && PreChe(other(plr),18)==1) // && Data->P[plr].Manned[1].Safety>Data->P[plr].Manned[1].MaxRD-25)
00125                 AIFuture(plr,6,0,(char *)&prg); //2
00126                else Data->P[plr].AIStat=3;
00127                ++Data->P[plr].Track[4];
00128                break;
00129         default:break;
00130       }
00131      if (Data->P[plr].Manned[0].Num>=2 && Data->P[plr].Rocket[0].Num>=2)
00132       {
00133        if (Data->P[plr].Future[0].MissionCode==2) AIFuture(plr,4,1,(char *)&prg);
00134         else if (Data->P[plr].Future[0].MissionCode==4) AIFuture(plr,2,1,(char *)&prg);
00135          else if (Data->P[plr].Future[0].MissionCode==6) AIFuture(plr,4,1,(char *)&prg); 
00136       };
00137    };
00138   };
00139   AILaunch(plr);
00140  }
00141  if (GenPur(plr,3,3)) RDafford(plr,3,3);
00142   else RDafford(plr,3,3);
00143  Data->P[plr].Buy[3][3]=0;RDafford(plr,3,3);
00144  if (Data->P[plr].AIStat>=2)
00145   {
00146    CheckVoting(plr); // gets AIPrim,AISec,AILunar
00147    if (Data->P[plr].AIPrim==0) ProgramVoting(plr);
00148   }
00149  // primary/secondary programs
00150  if (Data->P[plr].AIPrim==8) {Data->P[plr].AIPrim=6;Data->P[plr].AISec=8;}
00151  if (Data->P[plr].AIPrim==6) Data->P[plr].AISec=8;
00152  if (Data->P[plr].AIPrim==9) {Data->P[plr].AIPrim=6;Data->P[plr].AISec=9;}
00153 
00154  if (Data->P[plr].AILunar==4)
00155    {
00156     Data->P[plr].AIPrim=6;
00157    Data->P[plr].AISec= (Data->P[plr].Manned[1].Safety>=Data->P[plr].Manned[4].Safety) ? 6 : 10;
00158    }
00159 
00160  // boosters
00161  if (Data->P[plr].AIStat>=2)
00162   {
00163    if (GenPur(plr,1,4)) RDafford(plr,1,4);
00164     else RDafford(plr,1,4);
00165   }
00166 
00167   if (CheckSafety(plr,Data->P[plr].AIPrim) >= CheckSafety(plr,Data->P[plr].AISec))
00168      KeepRD(plr,Data->P[plr].AIPrim); else KeepRD(plr,Data->P[plr].AISec);
00169 
00170 // larger rocket klugge
00171   if (Data->P[plr].Track[5]==1)
00172   {
00173   if (Level_Check!=0) Data->P[plr].Cash+=25; // temporary
00174   if (Data->P[plr].AILunar<4)
00175    {
00176     if (GenPur(plr,1,2)) RDafford(plr,1,2);
00177      else RDafford(plr,1,2);
00178     Data->P[plr].Buy[1][2]=0;RDafford(plr,1,2);
00179    }
00180   else
00181    {
00182     if (Level_Check!=0) Data->P[plr].Cash+=25;
00183     if (GenPur(plr,1,3)) RDafford(plr,1,3);
00184      else RDafford(plr,1,3);
00185     Data->P[plr].Buy[1][3]=0;RDafford(plr,1,3);
00186    }
00187  }
00188 
00189 if (Data->Year>=62)
00190  if (Data->P[plr].Track[2]<5) PickModule(plr);
00191 
00192    if (Data->P[plr].AILunar>0 && Data->P[plr].AILunar<4)
00193     {
00194       if (Data->P[plr].Track[2]>0)
00195        {
00196         if (GenPur(plr,2,Data->P[plr].Track[2])) 
00197          RDafford(plr,2,Data->P[plr].Track[2]);
00198           else RDafford(plr,2,Data->P[plr].Track[2]);
00199        Data->P[plr].Buy[2][Data->P[plr].Track[2]]=0;
00200          RDafford(plr,2,Data->P[plr].Track[2]);
00201        }
00202    }
00203 
00204  for (i=0;i<3;i++)
00205   if (Data->P[plr].LaunchFacility[i]>1)
00206    if (Data->P[plr].LaunchFacility[i]<=Data->P[plr].Cash)
00207      {
00208       Data->P[plr].Cash-=Data->P[plr].LaunchFacility[i];
00209       Data->P[plr].LaunchFacility[i]=1;
00210    }   
00211  Data->P[plr].LaunchFacility[0]=1;
00212  Data->P[plr].LaunchFacility[1]=1;
00213  Data->P[plr].LaunchFacility[2]=1;
00214  if (Data->P[plr].AIStat==3) {
00215  switch(Data->P[plr].AILunar)
00216   {
00217     case 1:MoonProgram(plr,1);break;
00218     case 2:MoonProgram(plr,2);break;
00219     case 3:MoonProgram(plr,3);break;
00220     case 4:MoonProgram(plr,4);
00221           if (GenPur(plr,1,3)) RDafford(plr,1,3);
00222               RDafford(plr,1,3);
00223              break;
00224       default:break;
00225   }
00226  }
00227  if (Data->P[plr].AIStat>=2 && Data->Year>=61 && Data->P[plr].Track[1]>=2)
00228  {
00229   if ((Data->P[plr].Probe[0].Safety>=Data->P[plr].Probe[0].MaxRD-20) || Data->P[plr].Probe[1].Num>=0)
00230    {
00231     Data->P[plr].Cash+=Data->P[plr].Probe[1].InitCost+30;
00232     if (Data->P[plr].Probe[1].Num<=0) {
00233       if (GenPur(plr,0,1)) RDafford(plr,0,1);
00234        else RDafford(plr,0,1);
00235     }
00236     Data->P[plr].Buy[0][1]=0;RDafford(plr,0,1);
00237    }
00238   if ((Data->P[plr].Probe[1].Safety>=Data->P[plr].Probe[1].MaxRD-20) || Data->P[plr].Probe[2].Num>=0)
00239    {
00240     Data->P[plr].Cash+=Data->P[plr].Probe[2].InitCost+30;
00241     if (Data->P[plr].Probe[2].Num<=0) {
00242       if (GenPur(plr,0,2)) RDafford(plr,0,2);
00243         else RDafford(plr,0,2);
00244     }
00245     Data->P[plr].Buy[0][2]=0;RDafford(plr,0,2);
00246    }
00247    if (GenPur(plr,1,1)) RDafford(plr,1,1);
00248      else RDafford(plr,1,1);
00249   }
00250  if (PreChe(plr,27) || PreChe(plr,18)) Data->P[plr].AIStat=3;
00251 
00252 // **** end stages ***
00253  if (Data->P[plr].AIStat==3)
00254  {
00255   if (Data->P[plr].AILunar<4)
00256    {
00257     if (CheckSafety(plr,Data->P[plr].AIPrim)>CheckSafety(plr,Data->P[plr].AISec))
00258       val=Data->P[plr].AIPrim; else val=Data->P[plr].AISec;
00259     if (val<7) val=val-4;
00260      else val=val-5;
00261     if (Data->P[plr].Manned[val-1].Safety>=Data->P[plr].Manned[val-1].MaxRD-15)
00262      NewAI(plr,val);
00263    }
00264   else if (Data->P[plr].AILunar==4)
00265    {
00266     if (Data->P[plr].Manned[4].Safety>=Data->P[plr].Manned[4].MaxRD-10)
00267       Data->P[plr].AISec=10; else Data->P[plr].AISec=6;
00268 
00269     if (CheckSafety(plr,Data->P[plr].AIPrim)>CheckSafety(plr,Data->P[plr].AISec))
00270       val=Data->P[plr].AIPrim; else val=Data->P[plr].AISec;
00271     if (val<7) val=val-4;
00272      else val=val-5;
00273     if (Data->P[plr].Manned[val-1].Safety>=Data->P[plr].Manned[val-1].MaxRD-15)
00274      NewAI(plr,val);
00275       else {
00276           Data->P[plr].Probe[0].Num+=2;
00277           Data->P[plr].Rocket[0].Num+=2;
00278           AIFuture(plr,1,0,0);
00279           AIFuture(plr,1,1,0);
00280           AIFuture(plr,1,2,0);
00281          }
00282    }
00283 
00284   if (CheckSafety(plr,Data->P[plr].AIPrim)>CheckSafety(plr,Data->P[plr].AISec))
00285    {
00286     val=Data->P[plr].AIPrim;
00287     if (val<7) val=val-4;
00288      else val=val-5;
00289     if (CheckSafety(plr,Data->P[plr].AIPrim)>Data->P[plr].Manned[val-1].MaxRD-10)
00290      if (Data->P[plr].Manned[val-1].Num>=1) KeepRD(plr,Data->P[plr].AISec);
00291    }
00292   else
00293    {
00294     val=Data->P[plr].AISec;
00295     if (val<7) val=val-4;
00296      else val=val-5;
00297     if (CheckSafety(plr,Data->P[plr].AISec)>Data->P[plr].Manned[val-1].MaxRD-10)
00298      if (Data->P[plr].Manned[val-1].Num>=1) KeepRD(plr,Data->P[plr].AIPrim);
00299    }
00300  } 
00301  RDPrograms(plr);
00302  return;
00303 }
00304 
00305 
00306 char NoFail(char plr)
00307 {
00308  char RT_value=0,i;
00309  for (i=0;i<Data->P[plr].PastMis;i++)
00310    if ((Data->P[plr].History[i].MissionCode==4 || Data->P[plr].History[i].MissionCode==2) && Data->P[plr].History[i].spResult>=3000)
00311      ++RT_value;
00312  if (RT_value>=2) {
00313     RT_value=1;Data->P[plr].AIStat=3;
00314    }
00315  return(RT_value);
00316 }
00317 
00318 
00319 void RDPrograms(char plr)
00320 {
00321  int i;
00322  for (i=0;i<7;i++)
00323   {
00324    if (Data->P[plr].Manned[i].Num>=0)
00325      RDafford(plr,2,i);
00326    Data->P[plr].Manned[i].Damage=0;
00327    Data->P[plr].Manned[i].DCost=0;
00328   };
00329  for (i=0;i<5;i++)
00330   {
00331    if (Data->P[plr].Rocket[i].Num>=0)
00332     RDafford(plr,1,i);
00333    Data->P[plr].Rocket[i].Damage=0;
00334    Data->P[plr].Rocket[i].DCost=0;
00335   };
00336  for (i=0;i<4;i++)
00337   {
00338    if (Data->P[plr].Misc[i].Num>=0)
00339      RDafford(plr,3,i);
00340    Data->P[plr].Misc[i].Damage=0;
00341    Data->P[plr].Misc[i].DCost=0;
00342   };
00343  for (i=0;i<3;i++)
00344   {
00345    if (Data->P[plr].Probe[i].Num>=0)
00346      RDafford(plr,0,i);
00347    Data->P[plr].Probe[i].Damage=0;
00348    Data->P[plr].Probe[i].DCost=0;
00349   };
00350  return;
00351 }
00352 
00353 void CheckVoting(char plr)
00354 {
00355  int st;
00356  if (Data->P[plr].AILunar==0) MoonVoting(plr);
00357    else
00358     if (Data->P[plr].AILunar==4)
00359       {
00360        st= GenPur(plr,2,4);
00361        if (st==1)
00362          {
00363           RDafford(plr,2,4);
00364           Data->P[plr].AILunar=4; // lunar landing set
00365          }
00366       }
00367  return;
00368 }
00369 
00370 void KeepRD(char plr,int m)
00371 {
00372  //reassing player level
00373  if (plr==0) Level_Check=(Data->Def.Lev1==0) ? 0 : 1;
00374   else  if (plr==1) Level_Check=(Data->Def.Lev2==0) ? 0 : 1;
00375  if (m < 4) return; // hasn't voted yet
00376   switch(m)
00377      {
00378       case 5:if (Data->P[plr].Rocket[0].Num<=Data->P[plr].Manned[0].Num)
00379                {
00380                 if (GenPur(plr,1,0)) RDafford(plr,1,0);
00381                 if (GenPur(plr,2,0)) RDafford(plr,2,0);
00382                 RDafford(plr,2,0);
00383                 RDafford(plr,1,0);
00384                }
00385               else
00386                {
00387                 if (GenPur(plr,2,0)) RDafford(plr,2,0);
00388                 if (GenPur(plr,1,0)) RDafford(plr,1,0);
00389                 RDafford(plr,1,0);
00390                 RDafford(plr,2,0);
00391 
00392                }
00393              break;
00394       case 6:if (Data->P[plr].Rocket[1].Num<=Data->P[plr].Manned[1].Num)
00395                {
00396                  if (GenPur(plr,1,1)) RDafford(plr,1,1);
00397                else RDafford(plr,1,1);
00398                  if (GenPur(plr,2,1)) RDafford(plr,2,1);
00399                else RDafford(plr,2,1);
00400              if (Level_Check!=0) {
00401              Data->P[plr].Buy[1][1]=0;Data->P[plr].Buy[2][1]=0;
00402                  RDafford(plr,2,1);RDafford(plr,1,1);}
00403                }
00404              else
00405                {
00406                  if (GenPur(plr,2,1)) RDafford(plr,2,1);
00407               else RDafford(plr,2,1);
00408                  if (GenPur(plr,1,1)) RDafford(plr,1,1);
00409               else RDafford(plr,1,1);
00410              if (Level_Check!=0) {
00411              Data->P[plr].Buy[1][1]=0;Data->P[plr].Buy[2][1]=0;
00412                  RDafford(plr,1,1);RDafford(plr,2,1);}
00413                }
00414              break;
00415       case 8:if (Data->P[plr].Rocket[2].Num<=Data->P[plr].Manned[2].Num)
00416                {
00417                  if (GenPur(plr,1,2)) RDafford(plr,1,2);
00418               else RDafford(plr,1,2);
00419                  if (GenPur(plr,2,2)) RDafford(plr,2,2);
00420               else RDafford(plr,2,2);
00421              if (Level_Check!=0) {
00422              Data->P[plr].Buy[1][2]=0;Data->P[plr].Buy[2][2]=0;
00423                  RDafford(plr,2,2);RDafford(plr,1,2);}
00424                }
00425              else
00426                {
00427                 if (GenPur(plr,2,2)) RDafford(plr,2,2);
00428              else RDafford(plr,2,2);
00429                 if (GenPur(plr,1,2)) RDafford(plr,1,2);
00430              else RDafford(plr,1,2);
00431             if (Level_Check!=0) {
00432             Data->P[plr].Buy[1][2]=0;Data->P[plr].Buy[2][2]=0;
00433                 RDafford(plr,1,2);RDafford(plr,2,2);}
00434                }
00435           break;
00436       case 9:if (Data->P[plr].Rocket[3].Num<=Data->P[plr].Manned[3].Num)
00437                {
00438                 if (GenPur(plr,1,3)) RDafford(plr,1,3);
00439              else RDafford(plr,1,3);
00440                 if (GenPur(plr,2,3)) RDafford(plr,2,3);
00441              else RDafford(plr,2,3);
00442             if (Level_Check!=0) {
00443             Data->P[plr].Buy[1][3]=0;Data->P[plr].Buy[2][3]=0;
00444                 RDafford(plr,2,3);RDafford(plr,1,3);}
00445                }
00446               else
00447                {
00448                 if (GenPur(plr,2,3)) RDafford(plr,2,3);
00449              else RDafford(plr,2,3);
00450                 if (GenPur(plr,1,3)) RDafford(plr,1,3);
00451              else RDafford(plr,1,3);
00452             if (Level_Check!=0) {
00453             Data->P[plr].Buy[1][3]=0;Data->P[plr].Buy[2][3]=0;
00454                 RDafford(plr,1,3);RDafford(plr,2,3);}
00455                }
00456          break;
00457       case 10:if (Data->P[plr].Rocket[3].Num<=Data->P[plr].Manned[4].Num)
00458                {
00459                 if (GenPur(plr,1,3)) RDafford(plr,1,3);
00460              else RDafford(plr,1,3);
00461                 if (GenPur(plr,2,4)) RDafford(plr,2,4);
00462              else RDafford(plr,2,4);
00463             Data->P[plr].Buy[1][3]=0;Data->P[plr].Buy[2][4]=0;
00464                 RDafford(plr,2,4);RDafford(plr,1,3);
00465                }
00466               else
00467                {
00468                 if (GenPur(plr,2,4)) RDafford(plr,2,4);
00469              else RDafford(plr,2,4);
00470                 if (GenPur(plr,1,3)) RDafford(plr,1,3);
00471              else RDafford(plr,1,3);
00472             Data->P[plr].Buy[1][3]=0;Data->P[plr].Buy[2][4]=0;
00473                 RDafford(plr,1,3);RDafford(plr,2,4);
00474                }
00475               break;
00476       default:break;
00477      }
00478  return;
00479 }
00480 
00481 void PickModule(char plr)
00482 {
00483  Data->P[plr].Track[2]=6; 
00484  if (GenPur(plr,2,6)) RDafford(plr,2,6);
00485    RDafford(plr,2,6);
00486  return;
00487 }
00488 
00489 int FindNext(int x)
00490 {
00491  int i,k=1;
00492  for (i=0;i<4;i++)
00493   if (G[i]!=-1 && k==x)
00494     return(G[i]);
00495      else if (G[i]!=-1 && k<x) k=k+1;
00496  return(G[i]);
00497 }
00498                                
00499 void MoonVoting(char plr)
00500 {
00501  int high=-1,val;
00502 val=random(100)+1;
00503 if (val<70) high=0;
00504  else if (val<78) high=1;
00505   else if (val<92) high=2;
00506    else high=3;
00507  if (high!=-1)
00508    {
00509     switch (high)
00510      {
00511       case 0: Data->P[plr].AILunar=1;
00512           PickModule(plr);
00513           MoonProgram(plr,1);
00514           break;
00515       case 1: Data->P[plr].AILunar=2;
00516           PickModule(plr);
00517           MoonProgram(plr,2);
00518           break;
00519       case 2: Data->P[plr].AILunar=3;
00520           PickModule(plr);
00521           MoonProgram(plr,3);
00522           break;
00523       case 3: Data->P[plr].AILunar=4;
00524           MoonProgram(plr,4);
00525           break;
00526       default:break;
00527      }
00528    }
00529  return;
00530 }
00531 
00532 int CheckLimit(char plr,char m)
00533 {
00534  switch(m)
00535      {
00536       case 5: return(Data->P[plr].Manned[0].Num);
00537       case 6: return(Data->P[plr].Manned[1].Num);
00538       case 8: return(Data->P[plr].Manned[2].Num);
00539       case 9: return(Data->P[plr].Manned[3].Num);
00540      case 10: return(Data->P[plr].Manned[4].Num);
00541       default:break;
00542      }
00543  return 0;
00544 }
00545 
00546 int CheckSafety(char plr,char m)
00547 {
00548  switch(m)
00549    {
00550     case 5: return(Data->P[plr].Manned[0].Safety);
00551     case 6: return(Data->P[plr].Manned[1].Safety);
00552     case 8: return(Data->P[plr].Manned[2].Safety);
00553     case 9: return(Data->P[plr].Manned[3].Safety);
00554    case 10: return(Data->P[plr].Manned[4].Safety);
00555     default:break;
00556    }
00557  return 0;
00558 }
00559 
00560 void MoonProgram(char plr,char m)
00561 {
00562  switch(m)
00563   {
00564    case 1:if (GenPur(plr,3,1)) RDafford(plr,3,1);
00565                RDafford(plr,3,1);
00566           Data->P[plr].Buy[3][1]=0;RDafford(plr,3,1);
00567             break;
00568    case 2:if (GenPur(plr,3,1)) RDafford(plr,3,1);
00569                RDafford(plr,3,1);
00570           Data->P[plr].Buy[3][1]=0;RDafford(plr,3,1);
00571             break;
00572    case 3:if (GenPur(plr,3,0)) RDafford(plr,3,0);
00573                RDafford(plr,3,0);
00574             Data->P[plr].Buy[3][0]=0;RDafford(plr,3,0);
00575             break;
00576    case 4:if (GenPur(plr,2,4)) RDafford(plr,2,4);
00577                RDafford(plr,2,4);
00578             if (GenPur(plr,3,1)) RDafford(plr,3,1);
00579                RDafford(plr,3,1);
00580          Data->P[plr].Buy[3][1]=0;RDafford(plr,3,1);
00581            break;
00582    default:break;
00583   }
00584  return;
00585 }
00586 
00587 void ProgramVoting(char plr)
00588 {
00589  int i=0;
00590  i=random(100);
00591  if (i<65) Data->P[plr].AIPrim=8;
00592   else Data->P[plr].AIPrim=9;
00593  return;
00594 }
00595 
00596 /* EOF */
00597 
00598 
00599 

Generated on Fri Sep 28 00:35:44 2007 for raceintospace by  doxygen 1.5.3