s_Units = units;
-
+/*
for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++)
{
cerr << s_Units[(*i).first].Name() << "\t\t"
-/* << s_Units[(*i).first].race() <<"\t"
+ << s_Units[(*i).first].race() <<"\t"
<< s_Units[(*i).first].unitClass() << "\t"
<< s_Units[(*i).first].target(0) << "\t"
<< s_Units[(*i).first].target(1) << "\t"
<< s_Units[(*i).first].EMP() << "\t"
<< s_Units[(*i).first].totRes() << "\t"
<< s_Units[(*i).first].fuel() << "\t"
- << s_Units[(*i).first].ETA() << "\t"*/
+ << s_Units[(*i).first].ETA() << "\t"
<< s_Units[(*i).first].type() << endl;
}
+ */
}
//////////////////////////////////////////////////////////////////////////
{
int fl1 = (*j)->fleet(unittype, tick - 1);
float part = float(fl1) / fleet(unittype, 0) ;
- int lost = totallost * part;
+ int lost = int(totallost * part);
(*j)->setFleet(unittype, (*j)->fleet(unittype, tick - 1) + lost, tick);
cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;
- lost = part * blockedFleet(unittype, 0);
+ lost = int(part * blockedFleet(unittype, 0));
cerr << (*j)->name() << " got " << lost << " blocked " << unittype << ", the total number of blocked ships was: " << blockedFleet(unittype, 0) << endl;
//////////////////////////////////////////////////////////////////////////
//
-std::vector<Fleet*> Fleet::calculateSide(std::vector<Fleet*> fleets, int stays, int tick)
+std::vector<Fleet*> Fleet::calculateSide(std::vector<Fleet*> fleets, int tick)
{
vector<Fleet*> fl;
for (vector<Fleet*>::iterator i = fleets.begin(); i != fleets.end(); ++i)
if (guns == 0)
return;
- cerr << number << " " << unittype << ": with " << guns << " guns\n";
+ //cerr << number << " " << unittype << ": with " << guns << " guns\n";
float gunsleft = guns;
for (int count = 0; count < 3; ++count)//vector<string>::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i)
{
string ta = s_Units[unittype].target(count);
- cerr << "Shooting at target class: " << ta << endl;
+ //cerr << "Shooting at target class: " << ta << endl;
while (gunsleft > 0)
{
}
- cerr << hitunits[j->first] << " units of type: " << j->first << "killed\n";
+ //cerr << hitunits[j->first] << " units of type: " << j->first << "killed\n";
if (k <= 0)
gunsleft -= maxguns;
else
if (guns == 0)
return;
- cerr << unittype << ": with " << guns << " guns\n";
+ //cerr << unittype << ": with " << guns << " guns\n";
float gunsleft = guns;
for (int count = 0; count < 3; ++count)//vector<string>::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i)
{
string ta = s_Units[unittype].target(count);
- cerr << "Shooting at target class: " << ta << endl;
+ //cerr << "Shooting at target class: " << ta << endl;
while (gunsleft > 0)
{
for (map<string, int*>::iterator j = targets.begin(); j != targets.end(); ++j)
{
float maxguns = float((*j->second))/total * guns;
- cerr << "Now shooting at target: " << j->first << endl;
+ //cerr << "Now shooting at target: " << j->first << endl;
double k = maxguns;
k -= float(100)/(100-eres);
hits++;
+ hitunits[j->first]++;
blockFleet(j->first, 1);
}
- cerr << hits << " units of type: " << j->first << " blocked\n";
+ //cerr << hits << " units of type: " << j->first << " blocked\n";
if (k <= 0)
gunsleft -= maxguns;
else
{
unsigned fl1 = (*j)->score(tick - 1);
float part = float(fl1) / score(0) ;
- int lost = totcapped * part;
+ int lost = int(totcapped * part);
cerr << (*j)->name() << " gaining " << lost << " " << res << " since it's " << part * 100 << "% of the whole score, and it had : " << fl1 << " score last tick.. compared to fleet total of: " << score(0) << endl;
int stealscore = 0;
for (map<string, int>::iterator i = stolen.begin(); i != stolen.end(); ++i)
{
- stealscore += stolen[i->first] * (s_Units[i->first].totRes() / 10.0);
+ stealscore += int(stolen[i->first] * (s_Units[i->first].totRes() / 10.0));
}
- int lost = stealscore / (s_Units[unittype].totRes() / 10.0);
+ int lost = int(stealscore / (s_Units[unittype].totRes() / 10.0));
cerr << "Lost " << lost << " " << unittype << " due to stealing ships worth: " << stealscore << endl;
killFleet(unittype, lost, tick);
{
for (vector<Fleet*>::iterator k = fleets.begin(); k != fleets.end(); ++k)
{
- int stolen = float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second;
+ int stolen = int(float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second);
(*k)->addFleet(j->first, stolen, tick);
}
}
continue;
cerr << "(" << tick << ":" << fleet(i->first, tick) << ") ";
for (map<string, int>::iterator k = res.begin(); k != res.end(); ++k)
- addResource(k->first, lostunits * k->second * 0.25, tick);
+ addResource(k->first, int(lostunits * k->second * 0.25), tick);
}
}
}