1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

[programming challenge, SSN]

* preliminary bonus generation
* calculation of certain army statisticks for ANN.
This commit is contained in:
mateuszb 2012-05-16 20:26:34 +00:00
parent 927d6a8e36
commit 2f7ba07050

View File

@ -145,11 +145,28 @@ double * genSSNinput(const DuelParameters & dp, CArtifactInstance * art)
*(cur++) = side.heroId;
for(int k=0; k<4; ++k)
*(cur++) = side.heroPrimSkills[k];
for(int i=0; i<7; ++i)
//weighted average of statistics
auto avg = [&](std::function<int(CCreature *)> getter) -> double
{
*(cur++) = side.stacks[i].type;
*(cur++) = side.stacks[i].count;
}
double ret;
int div = 0;
for(int i=0; i<7; ++i)
{
auto & cstack = side.stacks[i];
if(cstack.count > 0)
{
ret += getter(VLC->creh->creatures[cstack.type]) * cstack.count;
div+=cstack.count;
}
}
return ret/div;
};
*(cur++) = avg([](CCreature * c){return c->attack;});
*(cur++) = avg([](CCreature * c){return c->defence;});
*(cur++) = avg([](CCreature * c){return c->speed;});
*(cur++) = avg([](CCreature * c){return c->hitPoints;});
}
//bonus description
@ -236,6 +253,27 @@ void SSNRun()
dp.sides[1].heroId = 1;
}
std::vector<Bonus> btt; //bonuses to test on
for(int i=0; i<5; ++i)
{
Bonus b;
b.type = Bonus::PRIMARY_SKILL;
b.subtype = PrimarySkill::ATTACK;
b.val = 5 * i + 1;
btt.push_back(b);
b.subtype = PrimarySkill::DEFENSE;
btt.push_back(b);
b.type = Bonus::STACKS_SPEED;
b.subtype = 0;
btt.push_back(b);
b.type = Bonus::STACK_HEALTH;
btt.push_back(b);
}
//evaluate
for(int i=0; i<dps.size(); ++i)
{
@ -322,4 +360,4 @@ int main(int argc, char **argv)
SSNRun();
return EXIT_SUCCESS;
}
}