diff --git a/Odpalarka/Odpalarka.vcxproj b/Odpalarka/Odpalarka.vcxproj
index b52275a18..6c380dafa 100644
--- a/Odpalarka/Odpalarka.vcxproj
+++ b/Odpalarka/Odpalarka.vcxproj
@@ -68,7 +68,8 @@
$(SolutionDir)
$(Configuration)\
- $(SolutionDir);$(LibraryPath)
+ $(SolutionDir);$(LibraryPath);G:\boost\FANN-2.2.0-Source\bin
+ G:\boost\FANN-2.2.0-Source\src\include;$(IncludePath)
$(SolutionDir)
@@ -77,7 +78,8 @@
$(SolutionDir)$(Configuration)\bin\
$(Configuration)\
- $(SolutionDir)$(SolutionDir)..\libs;\$(PlatformShortName);$(LibraryPath)
+ $(SolutionDir)$(SolutionDir)..\libs;\$(PlatformShortName);$(LibraryPath);G:\boost\FANN-2.2.0-Source\bin
+ G:\boost\FANN-2.2.0-Source\src\include;$(IncludePath)
$(SolutionDir)$(Configuration)\bin\
@@ -92,7 +94,7 @@
true
- VCMI_lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ VCMI_lib.lib;fannfloat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
@@ -120,7 +122,7 @@
true
true
true
- VCMI_lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ VCMI_lib.lib;fannfloat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
diff --git a/Odpalarka/main.cpp b/Odpalarka/main.cpp
index d343bf79f..0de8b0ca4 100644
--- a/Odpalarka/main.cpp
+++ b/Odpalarka/main.cpp
@@ -3,6 +3,11 @@
#include "../lib/VCMI_Lib.h"
namespace po = boost::program_options;
+
+//FANN
+#include
+#include
+
std::string leftAI, rightAI, battle, results, logsDir;
bool withVisualization = false;
std::string servername;
@@ -70,8 +75,37 @@ double playBattle(const DuelParameters &dp)
return code / 1000000.0;
}
-void SSNRun()
+typedef std::map TArtSet;
+
+double cmpArtSets(TArtSet setL, TArtSet setR)
{
+ DuelParameters dp;
+ dp.bfieldType = 1;
+ dp.terType = 1;
+
+ for(int i = 0; i < 2 ; i++)
+ {
+ auto &side = dp.sides[i];
+ side.heroId = i;
+ side.heroPrimSkills.resize(4,0);
+ side.stacks[0] = DuelParameters::SideSettings::StackSettings(10+i, 40+i);
+ }
+
+ //lewa strona z art 0.9
+ //bez artefaktow -0.41
+ //prawa strona z art. -0.926
+
+ dp.sides[0].artifacts = setL;
+ dp.sides[1].artifacts = setR;
+
+ auto battleOutcome = playBattle(dp);
+ return battleOutcome;
+}
+
+std::vector genArts()
+{
+ std::vector ret;
+
CArtifact *nowy = new CArtifact();
nowy->description = "Cudowny miecz Towa gwarantuje zwyciestwo";
nowy->name = "Cudowny miecz";
@@ -85,35 +119,81 @@ void SSNRun()
artinst->addNewBonus(new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::ARTIFACT_INSTANCE, +25, nowy->id, PrimarySkill::ATTACK));
artinst->addNewBonus(new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::ARTIFACT_INSTANCE, +25, nowy->id, PrimarySkill::DEFENSE));
- DuelParameters dp;
- dp.bfieldType = 1;
- dp.terType = 1;
-
- for(int i = 0; i < 2 ; i++)
- {
- auto &side = dp.sides[i];
- side.heroId = i;
- side.heroPrimSkills.resize(4,0);
- side.stacks[0] = DuelParameters::SideSettings::StackSettings(10+i, 40+i);
- }
-
auto bonuses = artinst->getBonuses([](const Bonus *){ return true; });
BOOST_FOREACH(Bonus *b, *bonuses)
{
std::cout << format("%s (%d) value:%d, description: %s\n") % bonusTypeToString(b->type) % b->subtype % b->val % b->Description();
}
-
+ return ret;
+}
- //lewa strona z art 0.9
- //bez artefaktow -0.41
- //prawa strona z art. -0.926
+//returns how good the artifact is for the neural network
+double runSSN(FANN::neural_net & net, CArtifactInstance * inst)
+{
- dp.sides[0].artifacts[Arts::LEFT_HAND] = artinst;
+ return 0.0;
+}
- auto battleOutcome = playBattle(dp);
- int g = 4;
+void initNet(FANN::neural_net & ret)
+{
+ const float learning_rate = 0.7f;
+ const unsigned int num_layers = 3;
+ const unsigned int num_input = 2;
+ const unsigned int num_hidden = 3;
+ const unsigned int num_output = 1;
+ const float desired_error = 0.001f;
+ const unsigned int max_iterations = 300000;
+ const unsigned int iterations_between_reports = 1000;
+
+ ret.create_standard(num_layers, num_input, num_hidden, num_output);
+
+ ret.set_learning_rate(learning_rate);
+
+ ret.set_activation_steepness_hidden(1.0);
+ ret.set_activation_steepness_output(1.0);
+
+ ret.set_activation_function_hidden(FANN::SIGMOID_SYMMETRIC_STEPWISE);
+ ret.set_activation_function_output(FANN::SIGMOID_SYMMETRIC_STEPWISE);
+
+ ret.randomize_weights(0.0, 1.0);
+}
+
+void SSNRun()
+{
+ auto availableArts = genArts();
+ std::vector > artNotes;
+
+ TArtSet setL, setR;
+
+ FANN::neural_net network;
+ initNet(network);
+
+ for(int i=0; i & a1, const std::pair & a2)
+ {return a1.second > a2.second;});
+
+ //pick best arts into setL
+ BOOST_FOREACH(auto & ap, artNotes)
+ {
+ auto art = ap.first;
+ BOOST_FOREACH(auto slot, art->artType->possibleSlots)
+ {
+ if(setL.find(slot) != setL.end())
+ {
+ setL[slot] = art;
+ break;
+ }
+ }
+ }
+
+ //evaluate
+ double result = cmpArtSets(setL, setR);
}
int main(int argc, char **argv)