Commit a98e0519 authored by Boris Mühmer's avatar Boris Mühmer
Browse files

splitted klingon

parent efae474c
Loading
Loading
Loading
Loading
+2 −217
Original line number Diff line number Diff line
#include "conquest.h"

klingon(pla)
int pla;
  {
@@ -251,220 +253,3 @@ int pla;
    if(do_command(pla,&c)==-1) break;
    }
  }
fi_star(pla,sta)
int pla;
int sta;
  {
  int st,b_sta,b_dist;
  b_sta=-1;
  b_dist=1000;
  for(st=0;st<STARNO;st++)
    if(distance(st,sta)<=b_dist && fi_need(pla,st)>fi_send(pla,st))
    {
    b_sta=st;
    b_dist=distance(st,sta);
    }
  return(b_sta);
  }
tr_star(pla,sta)
int pla;
int sta;
  {
  int st,b_sta,b_dist;
  b_sta=-1;
  b_dist=1000;
  for(st=0;st<STARNO;st++)
    if(distance(st,sta)<=b_dist && tr_need(pla,st)>tr_send(pla,st))
    {
    b_sta=st;
    b_dist=distance(st,sta);
    }
  return(b_sta);
  }
fi_need(pla,sta)
int pla;
int sta;
  {
  int p,pl,need;
  need=1;
  if(!knowstar(pla,sta)) return(need);
  for(p=0;p<PLANETNO;p++)
    {
    need+=(star[sta].planet[p].mineable+1)*star[sta].planet[p].size/10;
    need+=star[sta].planet[p].population/10;
    need+=star[sta].planet[p].industrie/10;
    }
  need *= general.techlevel[pla]/100;
  need += CommData[pla].star[sta].danger;
  return(need);
  }
fi_send(pla,sta)
int pla;
int sta;
  {
  int send;
  int tas,shi;
  send=0;
  for(tas=0;tas<TASKNO;tas++) if(task[pla][tas].headed==sta)
    for(shi=0;shi<SHIPNO;shi++) send+=task[pla][tas].ship_free[shi]*fi_value(shi);
  return(send);
  }
best_fi(pla,sta)
int pla;
int sta;
  {
  int b_shi,b_val,shi,dis;
  dis=distance(sta,nearstar(sta));
  b_shi=-1;b_val=0;
  for(shi=0;shi<SHIPNO;shi++)
    if(ship[shi].hyprange>=dis && ship[shi].techlevel<=general.techlevel[pla]
       && (20*fi_value(shi))/ship[shi].techcost>b_val)
      {
      b_shi=shi;
      b_val=20*fi_value(shi)/ship[shi].techcost;
      }
  return(b_shi);
  }
tr_need(pla,sta)
int pla;
int sta;
  {
  int shi,tas,p,pl,need,dis;
  need=0;
  dis=distance(sta,nearstar(sta));
  if(!knowstar(pla,sta)) return(0);
  for(tas=0;tas<TASKNO;tas++) if(ATSTAR(pla,tas,sta))
    for(shi=0;shi<SHIPNO;shi++) if(ship[shi].hyprange<dis)
       need += ship[shi].size*task[pla][tas].ship_free[shi];
  return(need);
  }
tr_pres(pla,sta)
int pla;
int sta;
  {
  int pres,tas;
  pres=0;
  for(tas=0;tas<TASKNO;tas++) if(ATSTAR(pla,tas,sta)) pres += task_capa(pla,tas);
  return(pres);
  }
tr_send(pla,sta)
int pla;
int sta;
  {
  int send,tas;
  send=0;
  for(tas=0;tas<TASKNO;tas++) if(task[pla][tas].headed==sta) send += task_capa(pla,tas);
  return(send);
  }
tr_value(shi)
int shi;
  {
  return(ship[shi].hypspeed*ship[shi].capacity);
  }
best_tr(pla,sta)
int pla;
int sta;
  {
  int b_shi,b_val,shi,dis;
  dis=distance(sta,tr_star(pla,sta));
  b_shi=RESEARCHING;b_val=0;
  for(shi=0;shi<SHIPNO;shi++)
    if(ship[shi].hyprange>=dis && ship[shi].techlevel<=general.techlevel[pla]
       && (20*tr_value(shi))/ship[shi].techcost>b_val)
      {
      b_shi=shi;
      b_val=20*tr_value(shi)/ship[shi].techcost;
      }
  return(b_shi);
  }
pop_pres(pla,sta)
int pla;
int sta;
  {
  int pres,tas;
  pres=0;
  for(tas=0;tas<TASKNO;tas++) if(ATSTAR(pla,tas,sta))
    pres += task[pla][tas].ship_free[POPUNIT]+task[pla][tas].ship_load[POPUNIT];
  return(pres);
  }
pop_need(pla,sta)
int pla;
int sta;
  {
  int need,p;
  need=0;
  for(p=0;p<PLANETNO;p++) if((star[sta].planet[p].ruler==pla && star[sta].planet[p].poptype==pla)
                             || star[sta].planet[p].ruler==PLAYERNO)
    need += star[sta].planet[p].size-star[sta].planet[p].population;
  return(need);
  }
pop_send(pla,sta)
int pla;
int sta;
  {
  int send,tas;
  send=0;
  for(tas=0;tas<TASKNO;tas++) if(task[pla][tas].headed==sta)
    send += task[pla][tas].ship_load[POPUNIT]+task[pla][tas].ship_free[POPUNIT];
  return(send);
  }
pop_star(pla,sta)
int pla;
int sta;
  {
  int st,b_sta,b_dist;
  b_sta=-1;
  b_dist=1000;
  for(st=0;st<STARNO;st++)
    if(distance(st,sta)<=b_dist && pop_need(pla,st)>pop_send(pla,st))
    {
    b_sta=st;
    b_dist=distance(st,sta);
    }
  return(b_sta);
  }
ore_pres(pla,sta)
int pla;
int sta;
  {
  int pres,tas;
  pres=0;
  for(tas=0;tas<TASKNO;tas++) if(ATSTAR(pla,tas,sta))
    pres += task[pla][tas].ship_free[OREUNIT]+task[pla][tas].ship_load[OREUNIT];
  return(pres);
  }
ore_need(pla,sta)
int pla;
int sta;
  {
  int need,p;
  need=0;
  for(p=0;p<PLANETNO;p++) if(star[sta].planet[p].ruler==pla)
    need += star[sta].planet[p].population-star[sta].planet[p].industrie;
  return(need);
  }
ore_send(pla,sta)
int pla;
int sta;
  {
  int send,tas;
  send=0;
  for(tas=0;tas<TASKNO;tas++) if(task[pla][tas].headed==sta)
    send += task[pla][tas].ship_free[OREUNIT]+task[pla][tas].ship_load[OREUNIT];
  return(send);
  }
ore_star(pla,sta)
int pla;
int sta;
  {
  int st,b_sta,b_dist;
  b_sta=-1;
  b_dist=1000;
  for(st=0;st<STARNO;st++)
    if(distance(st,sta)<=b_dist && ore_need(pla,st)>ore_send(pla,st))
    {
    b_sta=st;
    b_dist=distance(st,sta);
    }
  return(b_sta);
  }
+18 −0
Original line number Diff line number Diff line
#include "conquest.h"

best_fi(pla,sta)
int pla;
int sta;
  {
  int b_shi,b_val,shi,dis;
  dis=distance(sta,nearstar(sta));
  b_shi=-1;b_val=0;
  for(shi=0;shi<SHIPNO;shi++)
    if(ship[shi].hyprange>=dis && ship[shi].techlevel<=general.techlevel[pla]
       && (20*fi_value(shi))/ship[shi].techcost>b_val)
      {
      b_shi=shi;
      b_val=20*fi_value(shi)/ship[shi].techcost;
      }
  return(b_shi);
  }
+18 −0
Original line number Diff line number Diff line
#include "conquest.h"

best_tr(pla,sta)
int pla;
int sta;
  {
  int b_shi,b_val,shi,dis;
  dis=distance(sta,tr_star(pla,sta));
  b_shi=RESEARCHING;b_val=0;
  for(shi=0;shi<SHIPNO;shi++)
    if(ship[shi].hyprange>=dis && ship[shi].techlevel<=general.techlevel[pla]
       && (20*tr_value(shi))/ship[shi].techcost>b_val)
      {
      b_shi=shi;
      b_val=20*tr_value(shi)/ship[shi].techcost;
      }
  return(b_shi);
  }
+19 −0
Original line number Diff line number Diff line
#include "conquest.h"

fi_need(pla,sta)
int pla;
int sta;
  {
  int p,pl,need;
  need=1;
  if(!knowstar(pla,sta)) return(need);
  for(p=0;p<PLANETNO;p++)
    {
    need+=(star[sta].planet[p].mineable+1)*star[sta].planet[p].size/10;
    need+=star[sta].planet[p].population/10;
    need+=star[sta].planet[p].industrie/10;
    }
  need *= general.techlevel[pla]/100;
  need += CommData[pla].star[sta].danger;
  return(need);
  }
+13 −0
Original line number Diff line number Diff line
#include "conquest.h"

fi_send(pla,sta)
int pla;
int sta;
  {
  int send;
  int tas,shi;
  send=0;
  for(tas=0;tas<TASKNO;tas++) if(task[pla][tas].headed==sta)
    for(shi=0;shi<SHIPNO;shi++) send+=task[pla][tas].ship_free[shi]*fi_value(shi);
  return(send);
  }
Loading