Browse Source

[programming challenge, SSN]
* preliminary bonus generation
* calculation of certain army statisticks for ANN.

mateuszb 13 years ago
parent
commit
2f7ba07050
1 changed files with 43 additions and 5 deletions
  1. 43 5
      Odpalarka/main.cpp

+ 43 - 5
Odpalarka/main.cpp

@@ -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;
-}
+}