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

Deleted GeniusAI.

This commit is contained in:
Michał W. Urbańczyk 2012-03-01 16:32:14 +00:00
parent 2bea93f43f
commit 672468a738
21 changed files with 0 additions and 4922 deletions

View File

@ -1,251 +0,0 @@
#include "StdInc.h"
#include "AIPriorities.h"
// TODO: No using namespace!!
using namespace geniusai;
Network::Network()
{}
Network::Network(vector<ui32> whichFeatures)// random network
: whichFeatures(whichFeatures),
net(whichFeatures.size(),
whichFeatures.size() * 0.601 + 2,
whichFeatures.size() * 0.251 + 2,
1)
{
}
Network::Network(istream & input)
{
// vector<int> whichFeatures;
int feature;
string line;
getline(input,line);
stringstream lineIn(line);
while(lineIn>>feature)
whichFeatures.push_back(feature);
getline(input, line);//get R
net = neuralNetwork(whichFeatures.size(),
whichFeatures.size() * 0.601 + 2,
whichFeatures.size() * 0.251 + 2,
1);
}
double Network::feedForward(const vector<double> & stateFeatures)
{
// TODO: Should comment/rewrite it...
return (rand() % 1000) / 800.0;
double * input = new double[whichFeatures.size()];
for (int i = 0; i < whichFeatures.size(); i++)
input[i] = stateFeatures[whichFeatures[i]];
double ans = net.feedForwardPattern(input)[0];
delete input;
return ans;
}
Priorities::Priorities(const string & filename) //read brain from file
:numSpecialFeatures(8)
{
ifstream infile(filename.c_str());
// object_num [list of features]
// brain data or "R" for random brain
objectNetworks.resize(255);
buildingNetworks.resize(9);
char type;
int object_num;
int town_num;
int building_num;
while(infile>>type)
{
switch(type)
{
case 'o'://map object
infile >> object_num;
objectNetworks[object_num].push_back(Network(infile));
break;
case 't'://town building
infile >> town_num >> building_num;
buildingNetworks[town_num][building_num]=Network(infile);
break;
}
}
}
void Priorities::fillFeatures(const CGeniusAI::HypotheticalGameState & hgs)
{
stateFeatures.clear();
stateFeatures.resize(50);
for(int i = 0; i < stateFeatures.size(); i++)
stateFeatures[i]=0;
for(int i = 0; i < hgs.resourceAmounts.size();i++) //features 0-7 are resources
stateFeatures[i]=hgs.resourceAmounts[i];
//TODO: //features 8-15 are incomes
specialFeaturesStart = 16; //features 16-23 are special features (filled in by get functions before ANN)
stateFeatures[24] = hgs.AI->m_cb->getDate();
stateFeatures[25] = 1;
}
double Priorities::getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay)
{
if(!resourceCosts.size())return -1;
//TODO: replace with ann
double cost = resourceCosts[0]/4.0+resourceCosts[1]/2.0+resourceCosts[2]/4.0+resourceCosts[3]/2.0+resourceCosts[4]/2.0+resourceCosts[5]/2.0+resourceCosts[6]/3000.0;
if(moved) //TODO: multiply by importance of hero
cost+=distOutOfTheWay/10000.0;
return cost;
}
double Priorities::getValue(const CGeniusAI::AIObjective & obj)
{ //resource
vector<int> resourceAmounts(8,0);
int amount;
if(obj.type==CGeniusAI::AIObjective::finishTurn) //TODO: replace with value of visiting that object divided by days till completed
return .0001; //small nonzero
double a;
if(obj.type==CGeniusAI::AIObjective::attack)
return 100;
if(dynamic_cast<const CGeniusAI::HeroObjective* >(&obj))
{
const CGeniusAI::HeroObjective* hobj = dynamic_cast<const CGeniusAI::HeroObjective* >(&obj);
stateFeatures[16] = hobj->whoCanAchieve.front()->h->getTotalStrength();
if(dynamic_cast<const CArmedInstance*>(hobj->object))
stateFeatures[17] = dynamic_cast<const CArmedInstance*>(hobj->object)->getArmyStrength();
switch(hobj->object->ID)
{
case 5: //artifact //TODO: return value of each artifact
return 0;
case 79://resources on the ground
switch(hobj->object->subID)
{
case 6:
amount = 800;
break;
case 0: case 2:
amount = 9.5; //will be rounded, sad
break;
default:
amount = 4;
break;
}
resourceAmounts[hobj->object->subID]=amount;
return getCost(resourceAmounts,NULL,0);
break;
case 55://mystical garden
resourceAmounts[6]=500;
a=getCost(resourceAmounts,NULL,0);
resourceAmounts[6]=0;
resourceAmounts[5]=5;
return (a+getCost(resourceAmounts,NULL,0))*.5;
case 109:
resourceAmounts[6]=1000;
return getCost(resourceAmounts,NULL,0);
case 12://campfire
resourceAmounts[6]=500;
for(int i = 0; i < 6;i++)
resourceAmounts[i]=1;
return getCost(resourceAmounts,NULL,0);
case 112://windmill
for(int i = 1; i < 6;i++)//no wood
resourceAmounts[i]=1;
return getCost(resourceAmounts,NULL,0);
break;
case 49://magic well
//TODO: add features for hero's spell points
break;
case 34: //hero
if(dynamic_cast<const CGHeroInstance*>(hobj->object)->getOwner()==obj.AI->m_cb->getMyColor())//friendly hero
{
stateFeatures[17] = dynamic_cast<const CGHeroInstance*>(hobj->object)->getTotalStrength();
return objectNetworks[34][0].feedForward(stateFeatures);
}
else
{
stateFeatures[17] = dynamic_cast<const CGHeroInstance*>(hobj->object)->getTotalStrength();
return objectNetworks[34][1].feedForward(stateFeatures);
}
break;
case 98:
if(dynamic_cast<const CGTownInstance*>(hobj->object)->getOwner()==obj.AI->m_cb->getMyColor())//friendly town
{
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return 0; // objectNetworks[98][0].feedForward(stateFeatures);
}
else
{
stateFeatures[17] = dynamic_cast<const CGTownInstance*>(hobj->object)->getArmyStrength();
return 0; //objectNetworks[98][1].feedForward(stateFeatures);
}
break;
case 88:
//TODO: average value of unknown level 1 spell, or value of known spell
case 89:
//TODO: average value of unknown level 2 spell, or value of known spell
case 90:
//TODO: average value of unknown level 3 spell, or value of known spell
return 0;
break;
case 215://quest guard
return 0;
case 53: //various mines
return 0; //out of range crash
//objectNetworks[53][hobj->object->subID].feedForward(stateFeatures);
case 113://TODO: replace with value of skill for the hero
return 0;
case 103: case 58://TODO: replace with value of seeing x number of new tiles
return 0;
default:
if (objectNetworks[hobj->object->ID].size())
return objectNetworks[hobj->object->ID][0].feedForward(stateFeatures);
tlog6 << "don't know the value of ";
switch(obj.type)
{
case CGeniusAI::AIObjective::visit:
tlog6 << "visiting " << hobj->object->ID;
break;
tlog6 << "attacking " << hobj->object->ID;
break;
case CGeniusAI::AIObjective::finishTurn:
obj.print();
break;
}
tlog6 << endl;
}
}
else //town objective
{
if(obj.type == CGeniusAI::AIObjective::buildBuilding)
{
const CGeniusAI::TownObjective* tnObj = dynamic_cast<const CGeniusAI::TownObjective* >(&obj);
if(buildingNetworks[tnObj->whichTown->t->subID].find(tnObj->which)!=buildingNetworks[tnObj->whichTown->t->subID].end())
return buildingNetworks[tnObj->whichTown->t->subID][tnObj->which].feedForward(stateFeatures);
else
{
tlog6 << "don't know the value of ";
obj.print();
tlog6 << endl;
}
}
}
return 0;
}

View File

@ -1,36 +0,0 @@
#pragma once
#include "CGeniusAI.h"
#include "neuralNetwork.h"
namespace geniusai {
class Network
{
public:
Network();
Network(vector<ui32> whichFeatures);// random network
Network(istream & input);
vector<ui32> whichFeatures;
double feedForward(const vector<double> & stateFeatures);
neuralNetwork net; //a network with whichFeatures.size() inputs, and 1 output
};
class Priorities
{
public:
Priorities(const string & filename); //read brain from file
vector<double> stateFeatures;
int specialFeaturesStart;
int numSpecialFeatures;
void fillFeatures(const CGeniusAI::HypotheticalGameState & AI);
double getValue(const CGeniusAI::AIObjective & obj);
double getCost(vector<int> &resourceCosts,const CGHeroInstance * moved,int distOutOfTheWay);
vector<vector<Network> > objectNetworks;
vector<map<int,Network> > buildingNetworks;
};
}

View File

@ -1,186 +0,0 @@
#include "StdInc.h"
#include "BattleHelper.h"
using namespace geniusai::BattleAI;
using namespace std;
CBattleHelper::CBattleHelper():
InfiniteDistance(0xffff),
BattlefieldWidth(GameConstants::BFIELD_WIDTH-2),
BattlefieldHeight(GameConstants::BFIELD_HEIGHT),
m_voteForMaxDamage(10),
m_voteForMinDamage(10),
m_voteForMaxSpeed(10),
m_voteForDistance(10),
m_voteForDistanceFromShooters(20),
m_voteForHitPoints(10)
{
// loads votes
std::fstream f;
f.open("AI\\CBattleHelper.txt", std::ios::in);
if (f)
{
//char c_line[512];
std::string line;
while (std::getline(f, line, '\n'))
{
//f.getline(c_line, sizeof(c_line), '\n');
//std::string line(c_line);
//std::getline(f, line);
std::vector<std::string> parts;
boost::algorithm::split(parts, line, boost::algorithm::is_any_of("="));
if (parts.size() >= 2)
{
boost::algorithm::trim(parts[0]);
boost::algorithm::trim(parts[1]);
if (parts[0].compare("m_voteForDistance") == 0)
{
try
{
m_voteForDistance = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
else if (parts[0].compare("m_voteForDistanceFromShooters") == 0)
{
try
{
m_voteForDistanceFromShooters = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
else if (parts[0].compare("m_voteForHitPoints") == 0)
{
try
{
m_voteForHitPoints = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
else if (parts[0].compare("m_voteForMaxDamage") == 0)
{
try
{
m_voteForMaxDamage = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
else if (parts[0].compare("m_voteForMaxSpeed") == 0)
{
try
{
m_voteForMaxSpeed = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
else if (parts[0].compare("m_voteForMinDamage") == 0)
{
try
{
m_voteForMinDamage = boost::lexical_cast<int>(parts[1]);
}
catch (boost::bad_lexical_cast &)
{}
}
}
}
f.close();
}
}
CBattleHelper::~CBattleHelper()
{}
int CBattleHelper::GetBattleFieldPosition(int x, int y)
{
return x + GameConstants::BFIELD_WIDTH * (y - 1);
}
int CBattleHelper::DecodeXPosition(int battleFieldPosition)
{
int x = battleFieldPosition%GameConstants::BFIELD_WIDTH;
assert( x > 0 && x < GameConstants::BFIELD_WIDTH-1 );
return x;
}
int CBattleHelper::DecodeYPosition(int battleFieldPosition)
{
int y=battleFieldPosition/GameConstants::BFIELD_WIDTH +1;
assert( y > 0 && y <= GameConstants::BFIELD_HEIGHT);
return y;
}
int CBattleHelper::StepRight(int pos){
return pos+1;
}
int CBattleHelper::StepLeft(int pos){
return pos-1;
}
int CBattleHelper::StepUpleft(int pos){
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
return pos-GameConstants::BFIELD_WIDTH;
}else{
return pos-GameConstants::BFIELD_WIDTH-1;
}
}
int CBattleHelper::StepUpright(int pos){
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
return pos-GameConstants::BFIELD_WIDTH+1;
}else{
return pos-GameConstants::BFIELD_WIDTH;
}
}
int CBattleHelper::StepDownleft(int pos){
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
return pos+GameConstants::BFIELD_WIDTH;
}else{
return pos+GameConstants::BFIELD_WIDTH-1;
}
}
int CBattleHelper::StepDownright(int pos){
if((pos/GameConstants::BFIELD_WIDTH)%2==0){
return pos+GameConstants::BFIELD_WIDTH+1;
}else{
return pos+GameConstants::BFIELD_WIDTH;
}
}
int CBattleHelper::GetShortestDistance(int pointA, int pointB)
{
int x1 = DecodeXPosition(pointA);
int y1 = DecodeYPosition(pointA);
int x2 = DecodeXPosition(pointB);
int y2 = DecodeYPosition(pointB);
int dx = abs(x1 - x2);
int dy = abs(y1 - y2);
if( dy%2==1 ){
if( y1%2==1 ){
if( x2<=x1 ){dx++;}
}else{
if( x2>=x1 ){dx++;}
}
}
max(dy,dx+dy/2);
return 0;
}
int CBattleHelper::GetDistanceWithObstacles(int pointA, int pointB)
{
// TODO - implement this!
return GetShortestDistance(pointA, pointB);
}

View File

@ -1,49 +0,0 @@
#pragma once
#include "Common.h"
namespace geniusai { namespace BattleAI {
class CBattleHelper
{
public:
CBattleHelper();
~CBattleHelper();
int GetBattleFieldPosition(int x, int y);
int DecodeXPosition(int battleFieldPosition);
int DecodeYPosition(int battleFieldPosition);
int StepDownright(int pos);
int StepUpright(int pos);
int StepDownleft(int pos);
int StepUpleft(int pos);
int StepRight(int pos);
int StepLeft(int pos);
int GetShortestDistance(int pointA, int pointB);
int GetDistanceWithObstacles(int pointA, int pointB);
int GetVoteForMaxDamage() const { return m_voteForMaxDamage; }
int GetVoteForMinDamage() const { return m_voteForMinDamage; }
int GetVoteForMaxSpeed() const { return m_voteForMaxSpeed; }
int GetVoteForDistance() const { return m_voteForDistance; }
int GetVoteForDistanceFromShooters() const { return m_voteForDistanceFromShooters; }
int GetVoteForHitPoints() const { return m_voteForHitPoints; }
const int InfiniteDistance;
const int BattlefieldWidth;
const int BattlefieldHeight;
private:
int m_voteForMaxDamage;
int m_voteForMinDamage;
int m_voteForMaxSpeed;
int m_voteForDistance;
int m_voteForDistanceFromShooters;
int m_voteForHitPoints;
CBattleHelper(const CBattleHelper &);
CBattleHelper &operator=(const CBattleHelper &);
};
}}

View File

@ -1,781 +0,0 @@
#include "StdInc.h"
#include "BattleLogic.h"
#include "../../lib/BattleState.h"
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/if.hpp>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing
#include <windows.h>
HANDLE handleIn;
HANDLE handleOut;
#endif
using namespace geniusai::BattleAI;
using namespace boost::lambda;
using namespace std;
#if _MSC_VER >= 1600
#define bind boost::lambda::bind
#endif
/*
ui8 side; //who made this action: false - left, true - right player
ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
ui8 actionType; //
0 = Cancel BattleAction
1 = Hero cast a spell
2 = Walk
3 = Defend
4 = Retreat from the battle
5 = Surrender
6 = Walk and Attack
7 = Shoot
8 = Wait
9 = Catapult
10 = Monster casts a spell (i.e. Faerie Dragons)
ui16 destinationTile;
si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
*/
/**
* Implementation of CBattleLogic class.
*/
CBattleLogic::CBattleLogic(CCallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) :
m_iCurrentTurn(-2),
m_bIsAttacker(!side),
m_cb(cb),
m_army1(army1),
m_army2(army2),
m_tile(tile),
m_hero1(hero1),
m_hero2(hero2),
m_side(side)
{
const int max_enemy_creatures = 12;
m_statMaxDamage.reserve(max_enemy_creatures);
m_statMinDamage.reserve(max_enemy_creatures);
m_statMaxSpeed.reserve(max_enemy_creatures);
m_statDistance.reserve(max_enemy_creatures);
m_statDistanceFromShooters.reserve(max_enemy_creatures);
m_statHitPoints.reserve(max_enemy_creatures);
}
CBattleLogic::~CBattleLogic()
{}
void CBattleLogic::SetCurrentTurn(int turn)
{
m_iCurrentTurn = turn;
}
void CBattleLogic::MakeStatistics(int currentCreatureId)
{
typedef std::vector<const CStack*> vector_stacks;
vector_stacks allStacks = m_cb->battleGetStacks();
const CStack *currentStack = m_cb->battleGetStackByID(currentCreatureId);
if(currentStack->position < 0) //turret
{
return;
}
/*
// find all creatures belong to the enemy
std::for_each(allStacks.begin(), allStacks.end(),
if_(bind<ui8>(&CStack::attackerOwned, bind<CStack>(&map_stacks::value_type::second, _1)) == m_bIsAttacker)
[
var(enemy)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
ret<CStack>(bind<CStack>(&map_stacks::value_type::second, _1))
]
);
// fill other containers
// max damage
std::for_each(enemy.begin(), enemy.end(),
var(m_statMaxDamage)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
bind<CStack>(&map_stacks::value_type::second, _1))))
);
// min damage
std::for_each(enemy.begin(), enemy.end(),
var(m_statMinDamage)[ret<int>(bind<int>(&map_stacks::value_type::first, _1))] =
ret<int>(bind<int>(&CCreature::damageMax, bind<CCreature*>(&CStack::creature,
bind<CStack>(&map_stacks::value_type::second, _1))))
);
*/
m_statMaxDamage.clear();
m_statMinDamage.clear();
m_statHitPoints.clear();
m_statMaxSpeed.clear();
m_statDistanceFromShooters.clear();
m_statDistance.clear();
m_statDistance.clear();
m_statCasualties.clear();
int totalEnemyDamage = 0;
int totalEnemyHitPoints = 0;
int totalDamage = 0;
int totalHitPoints = 0;
BOOST_FOREACH(const CStack *st, allStacks)
{
const int stackHP = st->valOfBonuses(Bonus::STACK_HEALTH);
if ((st->attackerOwned != 0) != m_bIsAttacker)
{
int id = st->ID;
if (st->count < 1)
{
continue;
}
// make stats
int hitPoints = st->count * stackHP - (stackHP - st->firstHPleft);
m_statMaxDamage.push_back(std::pair<int, int>(id, st->getMaxDamage() * st->count));
m_statMinDamage.push_back(std::pair<int, int>(id, st->getMinDamage() * st->count));
m_statHitPoints.push_back(std::pair<int, int>(id, hitPoints));
m_statMaxSpeed.push_back(std::pair<int, int>(id, stackHP));
totalEnemyDamage += (st->getCreature()->damageMax + st->getCreature()->damageMin) * st->count / 2;
totalEnemyHitPoints += hitPoints;
// calculate casualties
SCreatureCasualties cs;
// hp * amount - damage * ( (att - def)>=0 )
// hit poionts
assert(hitPoints >= 0 && "CGeniusAI - creature cannot have hit points less than zero");
//CGHeroInstance *attackerHero = (m_side)? m_hero1 : m_hero2;
//CGHeroInstance *defendingHero = (m_side)? m_hero2 : m_hero1;
int attackDefenseBonus = currentStack->Attack() - st->Defense();
double damageFactor = 1.0;
if(attackDefenseBonus < 0) //decreasing dmg
{
if(0.02 * (-attackDefenseBonus) > 0.3)
{
damageFactor += -0.3;
}
else
{
damageFactor += 0.02 * attackDefenseBonus;
}
}
else //increasing dmg
{
if(0.05 * attackDefenseBonus > 4.0)
{
damageFactor += 4.0;
}
else
{
damageFactor += 0.05 * attackDefenseBonus;
}
}
cs.damage_max = (int)(currentStack->getMaxDamage() * currentStack->count * damageFactor);
if (cs.damage_max > hitPoints)
{
cs.damage_max = hitPoints;
}
cs.damage_min = (int)(currentStack->getMinDamage() * currentStack->count * damageFactor);
if (cs.damage_min > hitPoints)
{
cs.damage_min = hitPoints;
}
cs.amount_max = cs.damage_max / stackHP;
cs.amount_min = cs.damage_min / stackHP;
cs.leftHitPoints_for_max = (hitPoints - cs.damage_max) % stackHP;
cs.leftHitPoint_for_min = (hitPoints - cs.damage_min) % stackHP;
m_statCasualties.push_back(std::pair<int, SCreatureCasualties>(id, cs));
if (st->getCreature()->isShooting() && st->shots > 0)
{
m_statDistanceFromShooters.push_back(std::pair<int, int>(id, m_battleHelper.GetShortestDistance(currentStack->position, st->position)));
}
if (currentStack->hasBonusOfType(Bonus::FLYING) || (currentStack->getCreature()->isShooting() && currentStack->shots > 0))
{
m_statDistance.push_back(std::pair<int, int>(id, m_battleHelper.GetShortestDistance(currentStack->position, st->position)));
}
else
{
m_statDistance.push_back(std::pair<int, int>(id, m_battleHelper.GetDistanceWithObstacles(currentStack->position, st->position)));
}
}
else
{
if (st->count < 1)
{
continue;
}
int hitPoints = st->count * stackHP - (stackHP - st->firstHPleft);
totalDamage += (st->getMaxDamage() + st->getMinDamage()) * st->count / 2;
totalHitPoints += hitPoints;
}
}
if (totalDamage / static_cast<double>(totalEnemyDamage) < 0.5 &&
totalHitPoints / static_cast<double>(totalEnemyHitPoints) < 0.5)
{
m_bEnemyDominates = true;
DbgBox("** EnemyDominates!");
}
else
{
m_bEnemyDominates = false;
}
//boost compile hack
typedef int const std::pair<int, int>::* IntPtr;
typedef int const SCreatureCasualties::* CreaPtr;
typedef SCreatureCasualties const std::pair<int, SCreatureCasualties>::* CreaPairPtr;
// sort max damage
std::sort(m_statMaxDamage.begin(), m_statMaxDamage.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort min damage
std::sort(m_statMinDamage.begin(), m_statMinDamage.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort max speed
std::sort(m_statMaxSpeed.begin(), m_statMaxSpeed.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort distance
std::sort(m_statDistance.begin(), m_statDistance.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort distance from shooters
std::sort(m_statDistanceFromShooters.begin(), m_statDistanceFromShooters.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) < bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort hit points
std::sort(m_statHitPoints.begin(), m_statHitPoints.end(),
bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_1) > bind((IntPtr)&creature_stat::value_type::second, boost::lambda::_2));
// sort casualties
std::sort(m_statCasualties.begin(), m_statCasualties.end(),
bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max,
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_1))
>
bind((CreaPtr)&creature_stat_casualties::value_type::second_type::damage_max,
bind((CreaPairPtr)&creature_stat_casualties::value_type::second, boost::lambda::_2)));
}
BattleAction CBattleLogic::MakeDecision(int stackID)
{
const CStack *currentStack = m_cb->battleGetStackByID(stackID);
if(currentStack->position < 0 || currentStack->getCreature()->idNumber == 147) //turret or first aid kit
{
return BattleAction::makeDefend(currentStack);
}
MakeStatistics(stackID);
list<int> creatures;
int additionalInfo = 0; //?
if (m_bEnemyDominates)
{
creatures = PerformBerserkAttack(stackID, additionalInfo);
}
else
{
creatures = PerformDefaultAction(stackID, additionalInfo);
}
/*std::string message("Creature will be attacked - ");
message += boost::lexical_cast<std::string>(creature_to_attack);
DbgBox(message.c_str());*/
if (additionalInfo == -1 || creatures.empty())
{
// defend
return BattleAction::makeDefend(currentStack);
}
else if (additionalInfo == -2)
{
return BattleAction::makeWait(currentStack);
}
list<int>::iterator it, eit;
eit = creatures.end();
for (it = creatures.begin(); it != eit; ++it)
{
BattleAction ba = MakeAttack(stackID, *it);
if (ba.actionType != action_walk_and_attack)
{
continue;
}
else
{
#if defined PRINT_DEBUG
PrintBattleAction(ba);
#endif
return ba;
}
}
BattleAction ba = MakeAttack(stackID, *creatures.begin());
return ba;
}
std::vector<int> CBattleLogic::GetAvailableHexesForAttacker(const CStack *defender, const CStack *attacker)
{
int x = m_battleHelper.DecodeXPosition(defender->position);
int y = m_battleHelper.DecodeYPosition(defender->position);
bool defenderIsDW = defender->doubleWide();
bool attackerIsDW = attacker->doubleWide();
// TOTO: should be std::vector<int> but for debug purpose std::pair is used
typedef std::pair<int, int> hexPoint;
std::list<hexPoint> candidates;
std::vector<int> fields;
if (defenderIsDW)
{
if (defender->attackerOwned)
{
// from left side
if (!(y % 2))
{
// up
candidates.push_back(hexPoint(x - 2, y - 1));
candidates.push_back(hexPoint(x - 1, y - 1));
candidates.push_back(hexPoint(x, y - 1));
// down
candidates.push_back(hexPoint(x - 2, y + 1));
candidates.push_back(hexPoint(x - 1, y + 1));
candidates.push_back(hexPoint(x, y + 1));
}
else
{
// up
candidates.push_back(hexPoint(x - 1, y - 1));
candidates.push_back(hexPoint(x, y - 1));
candidates.push_back(hexPoint(x + 1, y - 1));
// down
candidates.push_back(hexPoint(x - 1, y + 1));
candidates.push_back(hexPoint(x, y + 1));
candidates.push_back(hexPoint(x + 1, y + 1));
}
candidates.push_back(hexPoint(x - 2, y));
candidates.push_back(hexPoint(x + 1, y));
}
else
{
// from right
if (!(y % 2))
{
// up
candidates.push_back(hexPoint(x - 1, y - 1));
candidates.push_back(hexPoint(x, y - 1));
candidates.push_back(hexPoint(x + 1, y - 1));
// down
candidates.push_back(hexPoint(x - 1, y + 1));
candidates.push_back(hexPoint(x, y + 1));
candidates.push_back(hexPoint(x + 1, y + 1));
}
else
{
// up
candidates.push_back(hexPoint(x, y - 1));
candidates.push_back(hexPoint(x + 1, y - 1));
candidates.push_back(hexPoint(x + 2, y - 1));
// down
candidates.push_back(hexPoint(x, y + 1));
candidates.push_back(hexPoint(x + 1, y + 1));
candidates.push_back(hexPoint(x + 2, y + 1));
}
candidates.push_back(hexPoint(x - 1, y));
candidates.push_back(hexPoint(x + 2, y));
}
}
else
{
if (!(y % 2)) // even line
{
// up
candidates.push_back(hexPoint(x - 1, y - 1));
candidates.push_back(hexPoint(x, y - 1));
// down
candidates.push_back(hexPoint(x - 1, y + 1));
candidates.push_back(hexPoint(x, y + 1));
}
else // odd line
{
// up
candidates.push_back(hexPoint(x, y - 1));
candidates.push_back(hexPoint(x + 1, y - 1));
// down
candidates.push_back(hexPoint(x, y + 1));
candidates.push_back(hexPoint(x + 1, y + 1));
}
candidates.push_back(hexPoint(x + 1, y));
candidates.push_back(hexPoint(x - 1, y));
}
// remove fields which are out of bounds or obstacles
for (std::list<hexPoint>::iterator it = candidates.begin(); it != candidates.end(); ++it)
{
if (it->first < 1 || it->first > m_battleHelper.BattlefieldWidth ||
it->second < 1 || it->second > m_battleHelper.BattlefieldHeight)
{
// field is out of bounds
//it = candidates.erase(it);
continue;
}
int new_pos = m_battleHelper.GetBattleFieldPosition(it->first, it->second);
const CStack *st = m_cb->battleGetStackByPos(new_pos);
if (st == NULL || st->count < 1)
{
if (attackerIsDW)
{
int tail_pos = -1;
if (attacker->attackerOwned) // left side
{
int tail_pos_x = it->first - 1;
if (tail_pos_x < 1)
{
continue;
}
tail_pos = m_battleHelper.GetBattleFieldPosition(it->first, it->second);
}
else // right side
{
int tail_pos_x = it->first + 1;
if (tail_pos_x > m_battleHelper.BattlefieldWidth)
{
continue;
}
tail_pos = m_battleHelper.GetBattleFieldPosition(it->first, it->second);
}
assert(tail_pos >= 0 && "Error during calculation position of double wide creature");
//CStack *tailStack = m_cb->battleGetStackByPos(tail_pos);
if (st != NULL && st->count >= 1)
{
continue;
}
}
fields.push_back(new_pos);
}
else if (attacker)
{
if (attacker->ID == st->ID)
{
fields.push_back(new_pos);
}
}
//
//++it;
}
return fields;
}
BattleAction CBattleLogic::MakeAttack(int attackerID, int destinationID)
{
const CStack *attackerStack = m_cb->battleGetStackByID(attackerID),
*destinationStack = m_cb->battleGetStackByID(destinationID);
assert(attackerStack && destinationStack);
//don't attack ourselves
if(destinationStack->attackerOwned == !m_side)
{
return BattleAction::makeDefend(attackerStack);
}
if (m_cb->battleCanShoot(attackerStack, destinationStack->position)) // shoot
{
return BattleAction::makeShotAttack(attackerStack, destinationStack);
}
else
{
// go or go&attack
int dest_tile = -1;
std::vector<int> av_tiles = GetAvailableHexesForAttacker(m_cb->battleGetStackByID(destinationID), m_cb->battleGetStackByID(attackerID));
if (av_tiles.size() < 1)
{
return BattleAction::makeDefend(attackerStack);
}
// get the best tile - now the nearest
int prev_distance = m_battleHelper.InfiniteDistance;
int currentPos = m_cb->battleGetPos(attackerID);
for (std::vector<int>::iterator it = av_tiles.begin(); it != av_tiles.end(); ++it)
{
int dist = m_battleHelper.GetDistanceWithObstacles(*it, m_cb->battleGetPos(attackerID));
if (dist < prev_distance)
{
prev_distance = dist;
dest_tile = *it;
}
if (*it == currentPos)
{
dest_tile = currentPos;
break;
}
}
std::vector<BattleHex> fields = m_cb->battleGetAvailableHexes(m_cb->battleGetStackByID(attackerID), false);
if(fields.size() == 0)
{
return BattleAction::makeDefend(attackerStack);
}
BattleAction ba;
ba.side = m_side;
//ba.actionType = 6; // go and attack
ba.stackNumber = attackerID;
ba.destinationTile = static_cast<ui16>(dest_tile);
//simplified checking for possibility of attack (previous was too simplified)
int destStackPos = m_cb->battleGetPos(destinationID);
if(BattleHex::mutualPosition(dest_tile, destStackPos) != -1)
ba.additionalInfo = destStackPos;
else if(BattleHex::mutualPosition(dest_tile, destStackPos+1) != -1)
ba.additionalInfo = destStackPos+1;
else if(BattleHex::mutualPosition(dest_tile, destStackPos-1) != -1)
ba.additionalInfo = destStackPos-1;
else
return BattleAction::makeDefend(attackerStack);
int nearest_dist = m_battleHelper.InfiniteDistance;
int nearest_pos = -1;
// if double wide calculate tail
int tail_pos = -1;
if (attackerStack->doubleWide())
{
int x_pos = m_battleHelper.DecodeXPosition(attackerStack->position);
int y_pos = m_battleHelper.DecodeYPosition(attackerStack->position);
if (attackerStack->attackerOwned)
{
x_pos -= 1;
}
else
{
x_pos += 1;
}
// if creature can perform attack without movement - do it!
tail_pos = m_battleHelper.GetBattleFieldPosition(x_pos, y_pos);
if (dest_tile == tail_pos)
{
ba.additionalInfo = dest_tile;
ba.actionType = action_walk_and_attack;
#if defined PRINT_DEBUG
PrintBattleAction(ba);
#endif
assert(m_cb->battleGetStackByPos(ba.additionalInfo, false)); //if action is action_walk_and_attack additional info must point on enemy stack
assert(m_cb->battleGetStackByPos(ba.additionalInfo, false) != attackerStack); //don't attack ourselve
return ba;
}
}
for (std::vector<BattleHex>::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
if (*it == dest_tile)
{
// attack!
ba.actionType = action_walk_and_attack;
#if defined PRINT_DEBUG
PrintBattleAction(ba);
#endif
assert(m_cb->battleGetStackByPos(ba.additionalInfo)); //if action is action_walk_and_attack additional info must point on enemy stack
assert(m_cb->battleGetStackByPos(ba.additionalInfo) != attackerStack); //don't attack ourselve
return ba;
}
int d = m_battleHelper.GetDistanceWithObstacles(dest_tile, *it);
if (d < nearest_dist)
{
nearest_dist = d;
nearest_pos = *it;
}
}
string message;
message = "Attacker position X=";
message += boost::lexical_cast<std::string>(m_battleHelper.DecodeXPosition(nearest_pos)) + ", Y=";
message += boost::lexical_cast<std::string>(m_battleHelper.DecodeYPosition(nearest_pos));
DbgBox(message.c_str());
ba.actionType = action_walk;
ba.destinationTile = (ui16)nearest_pos;
ba.additionalInfo = -1;
#if defined PRINT_DEBUG
PrintBattleAction(ba);
#endif
return ba;
}
}
/**
* The main idea is to perform maximum casualties.
*/
list<int> CBattleLogic::PerformBerserkAttack(int stackID, int &additionalInfo)
{
const CStack * c = m_cb->battleGetStackByID(stackID);
// attack to make biggest damage
list<int> creatures;
if (!m_statCasualties.empty())
{
//creature_to_attack = m_statCasualties.begin()->first;
creature_stat_casualties::iterator it = m_statCasualties.begin();
for (; it != m_statCasualties.end(); ++it)
{
if (it->second.amount_min <= 0)
{
creatures.push_back(it->first);
continue;
}
for (creature_stat::const_iterator it2 = m_statDistance.begin(); it2 != m_statDistance.end(); ++it2)
{
if (it2->first == it->first && it2->second - 1 <= c->getCreature()->valOfBonuses(Bonus::STACKS_SPEED))
{
creatures.push_front(it->first);
}
}
}
creatures.push_back(m_statCasualties.begin()->first);
}
return creatures;
}
list<int> CBattleLogic::PerformDefaultAction(int stackID, int &additionalInfo)
{
// first approach based on the statistics and weights
// if this solution was fine we would develop this idea
//
std::map<int, int> votes;
for (creature_stat::iterator it = m_statMaxDamage.begin(); it != m_statMaxDamage.end(); ++it)
{
votes[it->first] = 0;
}
votes[m_statMaxDamage.begin()->first] += m_battleHelper.GetVoteForMaxDamage();
votes[m_statMinDamage.begin()->first] += m_battleHelper.GetVoteForMinDamage();
if (m_statDistanceFromShooters.size())
{
votes[m_statDistanceFromShooters.begin()->first] += m_battleHelper.GetVoteForDistanceFromShooters();
}
votes[m_statDistance.begin()->first] += m_battleHelper.GetVoteForDistance();
votes[m_statHitPoints.begin()->first] += m_battleHelper.GetVoteForHitPoints();
votes[m_statMaxSpeed.begin()->first] += m_battleHelper.GetVoteForMaxSpeed();
// get creature to attack
int max_vote = 0;
list<int> creatures;
for (std::map<int, int>::iterator it = votes.begin(); it != votes.end(); ++it)
{
if (bool(m_cb->battleGetStackByID(it->first)->attackerOwned) == m_side //it's hostile stack
&& it->second > max_vote)
{
max_vote = it->second;
creatures.push_front(it->first);
}
}
additionalInfo = 0; // list contains creatures which shoud be attacked
return creatures;
}
void CBattleLogic::PrintBattleAction(const BattleAction &action) // for debug purpose
{
std::string message("Battle action \n");
message += "\taction type - ";
switch (action.actionType)
{
case 0:
message += "Cancel BattleAction\n";
break;
case 1:
message += "Hero cast a spell\n";
break;
case 2:
message += "Walk\n";
break;
case 3:
message += "Defend\n";
break;
case 4:
message += "Retreat from the battle\n";
break;
case 5:
message += "Surrender\n";
break;
case 6:
message += "Walk and Attack\n";
break;
case 7:
message += "Shoot\n";
break;
case 8:
message += "Wait\n";
break;
case 9:
message += "Catapult\n";
break;
case 10:
message += "Monster casts a spell\n";
break;
}
message += "\tDestination tile: X = ";
message += boost::lexical_cast<std::string>(m_battleHelper.DecodeXPosition(action.destinationTile));
message += ", Y = " + boost::lexical_cast<std::string>(m_battleHelper.DecodeYPosition(action.destinationTile));
message += "\nAdditional info: ";
if (action.actionType == 6)// || action.actionType == 7)
{
message += "stack - " + boost::lexical_cast<std::string>(m_battleHelper.DecodeXPosition(action.additionalInfo));
message += ", " + boost::lexical_cast<std::string>(m_battleHelper.DecodeYPosition(action.additionalInfo));
message += ", creature - ";
const CStack *c = m_cb->battleGetStackByPos(action.additionalInfo);
if (c && c->getCreature())
{
message += c->getCreature()->nameRef;
}
else
{
message += "NULL";
}
}
else
{
message += boost::lexical_cast<std::string>(action.additionalInfo);
}
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
#else
std::string color;
color = "\x1b[1;40;32m";
std::cout << color;
#endif
std::cout << message.c_str() << std::endl;
#ifdef _WIN32
SetConsoleTextAttribute(hConsole, csbi.wAttributes);
#else
color = "\x1b[0m";
std::cout << color;
#endif
}

View File

@ -1,131 +0,0 @@
#pragma once
#include "Common.h"
#include "BattleHelper.h"
#pragma warning (disable: 4100 4251 4245 4018 4081)
#include "../../CCallback.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CObjectHandler.h"
#pragma warning (default: 4100 4251 4245 4018 4081)
#pragma warning (disable: 4100)
using namespace std;
namespace geniusai { namespace BattleAI {
/**
* Class is responsible for making decision during the battle.
*/
class CBattleLogic
{
private:
enum EMainStrategyType
{
strategy_super_aggresive,
strategy_aggresive,
strategy_neutral,
strategy_defensive,
strategy_super_defensive,
strategy_berserk_attack /** cause max damage, usually when creatures fight against overwhelming army*/
};
enum ECreatureRoleInBattle
{
creature_role_shooter,
creature_role_defenser,
creature_role_fast_attacker,
creature_role_attacker
};
enum EActionType
{
action_cancel = 0, // Cancel BattleAction
action_cast_spell = 1, // Hero cast a spell
action_walk = 2, // Walk
action_defend = 3, // Defend
action_retreat = 4, // Retreat from the battle
action_surrender = 5, // Surrender
action_walk_and_attack = 6, // Walk and Attack
action_shoot = 7, // Shoot
action_wait = 8, // Wait
action_catapult = 9, // Catapult
action_monster_casts_spell = 10 // Monster casts a spell (i.e. Faerie Dragons)
};
struct SCreatureCasualties
{
int amount_max; // amount of creatures that will be dead
int amount_min;
int damage_max; // number of hit points that creature will lost
int damage_min;
int leftHitPoints_for_max; // number of hit points that will remain (for last unity)
int leftHitPoint_for_min; // scenario
};
public:
CBattleLogic(CCallback *cb, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side);
~CBattleLogic();
void SetCurrentTurn(int turn);
/**
* Get the final decision.
*/
BattleAction MakeDecision(int stackID);
private:
CBattleHelper m_battleHelper;
//BattleInfo m_battleInfo;
int m_iCurrentTurn;
bool m_bIsAttacker;
CCallback *m_cb;
const CCreatureSet *m_army1;
const CCreatureSet *m_army2;
int3 m_tile;
const CGHeroInstance *m_hero1;
const CGHeroInstance *m_hero2;
bool m_side;
// statistics
typedef std::vector<std::pair<int, int> > creature_stat; // first - creature id, second - value
creature_stat m_statMaxDamage;
creature_stat m_statMinDamage;
//
creature_stat m_statMaxSpeed;
creature_stat m_statDistance;
creature_stat m_statDistanceFromShooters;
creature_stat m_statHitPoints;
typedef std::vector<std::pair<int, SCreatureCasualties> > creature_stat_casualties;
creature_stat_casualties m_statCasualties;
bool m_bEnemyDominates;
/**
* Before decision we have to make some calculation and simulation.
*/
void MakeStatistics(int currentCreatureId);
/**
* Helper function. It's used for performing an attack action.
*/
std::vector<int> GetAvailableHexesForAttacker(const CStack *defender, const CStack *attacker = NULL);
/**
* Make an attack action if it's possible.
* If it's not possible then function returns defend action.
*/
BattleAction MakeAttack(int attackerID, int destinationID);
/**
* Berserk mode - do maximum casualties.
* Return vector wiht IDs of creatures to attack,
* additional info: -2 means wait, -1 - defend, 0 - make attack
*/
list<int> PerformBerserkAttack(int stackID, int &additionalInfo);
/**
* Normal mode - equilibrium between casualties and yields.
* Return vector wiht IDs of creatures to attack,
* additional info: -2 means wait, -1 - defend, 0 - make attack
*/
list<int> PerformDefaultAction(int stackID, int &additionalInfo);
/**
* Only for debug purpose.
*/
void PrintBattleAction(const BattleAction &action);
};
}}

File diff suppressed because it is too large Load Diff

View File

@ -1,215 +0,0 @@
#pragma once
#include "Common.h"
#include "BattleLogic.h"
#include "GeneralAI.h"
#include "../../lib/CondSh.h"
class CBuilding;
namespace geniusai {
enum BattleState
{
NO_BATTLE,
UPCOMING_BATTLE,
ONGOING_BATTLE,
ENDING_BATTLE
};
class Priorities;
class CGeniusAI : public CGlobalAI
{
private:
// TODO: cb... come back, croach busters!?
CCallback* m_cb;
geniusai::BattleAI::CBattleLogic* m_battleLogic;
geniusai::GeneralAI::CGeneralAI m_generalAI;
geniusai::Priorities* m_priorities;
CondSh<BattleState> m_state; //are we engaged into battle?
struct AIObjectContainer
{
AIObjectContainer(const CGObjectInstance * o):o(o){}
const CGObjectInstance * o;
bool operator<(const AIObjectContainer& b)const;
};
class HypotheticalGameState
{
public:
struct HeroModel
{
HeroModel(){}
HeroModel(const CGHeroInstance * h);
int3 pos;
int3 previouslyVisited_pos;
int3 interestingPos;
bool finished;
int remainingMovement;
const CGHeroInstance * h;
};
struct TownModel
{
TownModel(const CGTownInstance *t);
const CGTownInstance *t;
std::vector<std::pair<ui32, std::vector<ui32> > > creaturesToRecruit;
//CCreatureSet creaturesInGarrison; //type, num
bool hasBuilt;
};
HypotheticalGameState(){}
HypotheticalGameState(CGeniusAI & ai);
void update(CGeniusAI & ai);
CGeniusAI * AI;
std::vector<const CGHeroInstance *> AvailableHeroesToBuy;
std::vector<ui32> resourceAmounts;
std::vector<HeroModel> heroModels;
std::vector<TownModel> townModels;
std::set< AIObjectContainer > knownVisitableObjects;
};
class AIObjective
{
public:
enum Type
{
//hero objectives
visit, //done TODO: upon visit friendly hero, trade
attack, //done
//flee,
dismissUnits,
dismissYourself,
rearangeTroops,
finishTurn, //done //uses up remaining motion to get somewhere interesting.
//town objectives
recruitHero, //done
buildBuilding, //done
recruitCreatures, //done
upgradeCreatures //done
};
CGeniusAI * AI;
Type type;
virtual void fulfill(CGeniusAI &,HypotheticalGameState & hgs)=0;
virtual HypotheticalGameState pretend(const HypotheticalGameState&) =0;
virtual void print() const=0;
virtual double getValue() const=0; //how much is it worth to the AI to achieve
};
class HeroObjective: public AIObjective
{
public:
HypotheticalGameState hgs;
int3 pos;
const CGObjectInstance * object; //interactive object
mutable std::vector<HypotheticalGameState::HeroModel*> whoCanAchieve;
//HeroObjective(){}
//HeroObjective(Type t):object(NULL){type = t;}
HeroObjective(const HypotheticalGameState &hgs,
Type t,
const CGObjectInstance* object,
HypotheticalGameState::HeroModel* h,
CGeniusAI* AI);
bool operator< (const HeroObjective &other) const;
void fulfill(CGeniusAI &,HypotheticalGameState & hgs);
HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;};
double getValue() const;
void print() const;
private:
mutable double _value;
mutable double _cost;
};
//town objectives
//recruitHero
//buildBuilding
//recruitCreatures
//upgradeCreatures
class TownObjective: public AIObjective
{
public:
HypotheticalGameState hgs;
HypotheticalGameState::TownModel * whichTown;
int which; //which hero, which building, which creature,
TownObjective(const HypotheticalGameState &hgs,Type t,HypotheticalGameState::TownModel * tn,int Which,CGeniusAI * AI);
bool operator < (const TownObjective &other)const;
void fulfill(CGeniusAI &,HypotheticalGameState & hgs);
HypotheticalGameState pretend(const HypotheticalGameState &hgs){return hgs;};
double getValue() const;
void print() const;
private:
mutable double _value;
mutable double _cost;
};
class AIObjectivePtrCont
{
public:
AIObjectivePtrCont():obj(NULL){}
AIObjectivePtrCont(AIObjective * obj):obj(obj){};
AIObjective * obj;
bool operator < (const AIObjectivePtrCont & other) const{return obj->getValue()<other.obj->getValue();}
};
HypotheticalGameState trueGameState;
AIObjective * getBestObjective();
void addHeroObjectives(HypotheticalGameState::HeroModel &h, HypotheticalGameState & hgs);
void addTownObjectives(HypotheticalGameState::TownModel &h, HypotheticalGameState & hgs);
void fillObjectiveQueue(HypotheticalGameState & hgs);
void reportResources();
void startFirstTurn();
std::map<int,bool> isHeroStrong;//hero
std::set< AIObjectContainer > knownVisitableObjects;
std::set<HeroObjective> currentHeroObjectives; //can be fulfilled right now
std::set<TownObjective> currentTownObjectives;
std::vector<AIObjectivePtrCont> objectiveQueue;
public:
CGeniusAI();
virtual ~CGeniusAI();
virtual void init(CCallback * CB);
virtual void yourTurn();
virtual void heroKilled(const CGHeroInstance *);
virtual void heroCreated(const CGHeroInstance *);
virtual void heroMoved(const TryMoveHero &);
virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) {};
virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, const int soundID, bool selection, bool cancel); //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
virtual void tileRevealed(int3 pos);
virtual void tileHidden(int3 pos);
virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, boost::function<void()> &onEnd);
virtual void playerBlocked(int reason);
virtual void objectRemoved(const CGObjectInstance *obj); //eg. collected resource, picked artifact, beaten hero
virtual void newObject(const CGObjectInstance * obj); //eg. ship built in shipyard
// battle
virtual void actionFinished(const BattleAction *action);//occurs AFTER every action taken by any stack or by the hero
virtual void actionStarted(const BattleAction *action);//occurs BEFORE every action taken by any stack or by the hero
virtual void battleAttack(const BattleAttack *ba); //called when stack is performing attack
virtual void battleStacksAttacked(const std::set<BattleStackAttacked> & bsa); //called when stack receives damage (after battleAttack())
virtual void battleEnd(const BattleResult *br);
virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
virtual void battleStackMoved(int ID, std::vector<BattleHex> dest, int distance);
virtual void battleSpellCast(const BattleSpellCast *sc);
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
//
//virtual void battleStackMoved(int ID, int dest, bool startMoving, bool endMoving);
virtual void battleStackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting);
virtual BattleAction activeStack(const CStack * stack);
void battleResultsApplied();
friend class Priorities;
};
}

View File

@ -1,11 +0,0 @@
#pragma once
#ifdef __GNUC__
#define strcpy_s(a, b, c) strncpy(a, c, b)
#endif
#pragma warning (disable: 4100 4244)
#include "../../lib/AI_Base.h"
#pragma warning (default: 4100 4244)
void DbgBox(const char *msg, bool messageBox = false);

View File

@ -1,38 +0,0 @@
#include "StdInc.h"
#include "../../lib/AI_Base.h"
#include "CGeniusAI.h"
using namespace geniusai;
const char *g_cszAiName = "Genius 1.0";
extern "C" DLL_EXPORT int GetGlobalAiVersion()
{
return AI_INTERFACE_VER;
}
extern "C" DLL_EXPORT void GetAiName(char* name)
{
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
}
extern "C" DLL_EXPORT char* GetAiNameS()
{
// need to be defined
return NULL;
}
extern "C" DLL_EXPORT CGlobalAI* GetNewAI()
{
return new CGeniusAI();
}
extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI* i)
{
delete (CGeniusAI*)i;
}
extern "C" DLL_EXPORT CBattleGameInterface* GetNewBattleAI()
{
return new CGeniusAI();
}

View File

@ -1,143 +0,0 @@
#include "StdInc.h"
#include "GeneralAI.h"
#include "../../CCallback.h"
#include "ExpertSystem.h"
/*
* ExpertSystem.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
template <typename ruleType, typename facts> template <typename cond> void ExpertSystemShell<ruleType, facts>::DataDrivenReasoning(runType type)
{
std::vector<ruleType>::iterator ir;
std::list<fact>::iterator iF;
std::vector<std::pair<cond, input*>>::iterator ic;
bool factWasAdded = false; //carry it over inner loop
switch (type)
{
case ANY_GOAL: //first produced decision ends reasoning
{
int goalCounter = 0;
while(!goalCounter) //we reach goal or can't modify knowledge anymore
{
for (ir = knowledge.begin(); ir != knowledge.end(); ir++)
{
for (iF = factList.begin(); iF != factList.end(); iF++)
{
for (ic = ir->conditions.begin(); ic != ir->conditions.end(), ic++)
{
if (ic->first.object.matchesFact(iF->object)) //condition matches held object
{
(ic->second = *iF);
++(ir->conditionCounter);
}
}
if (ir->conditions.size() >= ir->conditionCounter());
{
ir->fireRule(); //all conditions matched
ir->conditionCounter = 0; //do it here or in rule itself?
if (dynamic_cast<&Goal>(*ir))
++goalCounter;
}
}
//modify set until something happens (hopefully!)
for (iF = factsToAdd.begin(); iF != factsToAdd.end(); iF++)
factList.insert(*iF);
if (factsToAdd.size())
{
factsToAdd.clear();
factWasAdded = true;
}
}
for (iF = factsToErase.begin(); iF != factsToErase.end(); iF++) //remove facts discarded in this run
factList.erase(knowledge.find(*iF));
factsToErase.clear(); //erase only after all rules had a chance to trigger
for (ir = rulesToErase.begin(); ir != rulesToErase.end(); ir++)
knowledge.erase(knowledge.find(*ir));
rulesToErase.clear();
for (ir = rulesToAdd.begin(); ir != rulesToAdd.end(); ir++)
knowledge.insert(*ir);
if (!(factWasAdded || rulesToAdd.size())) //we can't do anything more
break;
rulesToAdd.clear();
};
}
break;
}
}
void BonusRule::fireRule()
{
for (std::vector<std::pair<BonusCondition, BonusHolder*>>::iterator it = cons.begin(); it != cons.end(); it++)
{
switch (it->first.parameter)
{ //compare fact with condition
case BonusCondition::type:
if (!it->first.functor(it->second->object->type, it->first.value)) return;
break;
case BonusCondition::subtype: //probably suprfluous, Selector already handles that
if (!it->first.functor(it->second->object->subtype, it->first.value)) return;
break;
case BonusCondition::val:
if (!it->first.functor(it->second->object->val, it->first.value)) return;
break;
case BonusCondition::duration:
if (!it->first.functor(it->second->object->duration, it->first.value)) return;
break;
case BonusCondition::source: //likely to handle by selector
if (!it->first.functor(it->second->object->source, it->first.value)) return;
break;
case BonusCondition::id:
if (!it->first.functor(it->second->object->sid, it->first.value)) return;
break;
case BonusCondition::valType: //ever needed?
if (!it->first.functor(it->second->object->valType, it->first.value)) return;
break;
case BonusCondition::additionalInfo:
if (!it->first.functor(it->second->object->additionalInfo, it->first.value)) return;
break;
case BonusCondition::effectRange:
if (!it->first.functor(it->second->object->effectRange, it->first.value)) return;
break;
default: //ignore or accept?
break;
};
}
//TODO: add new fact or modify existing one
}
TLogic operator&&(const TLogic &first, const TLogic &second)
{
return LogicConjunction(first, second);
}
TLogic operator||(const TLogic &first, const TLogic &second)
{
return LogicAlternative(first, second);
}
template <typename input, typename conType> void Rule<input, conType>::refreshRule(std::vector<conType> &conditionSet)
{//replace conditions with new vector
cons.clear();
std::pair <conType,input*> para;
para.second = NULL;
for (std::vector<conType>::iterator it = conditionSet.begin(); it != conditionSet.end(); it++)
{
para.first = *it;
cons.push_back(para); //pointer to condition and null fact
}
}
template <typename input, typename conType> void Rule<input, conType>::refreshRule()
{//clear matching facts
for (std::vector<std::pair<conType, input*>>::iterator it = cons.begin(); it != cons.end(); it++)
it->second = NULL;
}
bool BonusCondition::matchesFact(Bonus &fact)
{
if (object(&fact)) //Bonus(fact) matches local Selector(object)
return true;
return false;
}

View File

@ -1,215 +0,0 @@
#include "../../CCallback.h"
#include "../../lib/HeroBonus.h"
#include <boost/bind.hpp>
#include <vector>
#include <list>
/*
* ExpertSystem.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
struct Bonus;
template <typename fact> class AIholder;
template <typename input, typename output> class Rule;
typedef Rule<Bonus, Bonus> BRule;
typedef boost::function<bool(int, si32)> TLogic;
bool greaterThan (int prop, si32 val);
enum conditionType {LESS_THAN, EQUAL, GREATER_THAN, UNEQUAL, PRESENT};
template <typename ruleType, typename fact> class ExpertSystemShell
{
enum runType {ANY_GOAL, TRESHOLD, FULL}; //Treshold - stop when received decision has high AI value
private:
ICallback* m_cb;
protected:
std::vector<ruleType> knowledge;
std::vector<ruleType*> rulesToErase;
std::vector<ruleType*> rulesToAdd;
std::vector<fact*> factsToErase;
std::vector<fact*> factsToAdd;
ui16 goalCounter; //count / evaluate achieved goals for runType
public:
ExpertSystemShell(){goalCounter = 0;};
std::list<fact> facts; //facts are AIholders with actual game objects, for eg. "my bonus is worthless"
template <typename t1> void getKnowledge(const t1 &a1){};
void getNextRule(){};
void addRule(ruleType &rule){rulesToAdd.insert(rule);};
void removeRule(ruleType &rule){rulesToErase.insert(rule);};
template <typename t2> void returnGoals(const t2 &a2){};
template <typename cond> void DataDrivenReasoning(runType type);
};
template <typename ruleType, typename fact> class Blackboard : public ExpertSystemShell <ruleType, fact>
//handle Bonus info coming from different sections of the game
{
public:
Blackboard(){this->goalCounter = 0;}; //template magic, do not touch!
std::vector<ExpertSystemShell*> experts; //modules responsible for different tasks
};
template <typename input> class condition
{//compares selected object parameter with value using functor. universal (?) logic handler
public:
input object; //what the fact is, or what it's like (CSelector)
si32 value;
ui8 parameter;
TLogic functor; //value of selected parameter, condition value
condition(){object = NULL; value = 0; parameter = 0; functor = greaterThan;};
bool matchesFact(input &fact){return false;};
};
template <typename input, typename conType> class Rule
{
friend class ExpertSystemShell <input, conType>;
public:
bool fired; //if conditions of rule were met and it produces some output
ui8 conditionCounter;
protected:
std::vector<std::pair<conType, input*>> cons; //conditions and matching facts
input decision;
virtual void canBeFired(); //if this data makes any sense for rule - type check
virtual bool checkCondition(); //if condition is true or false
virtual bool checkCondition(std::vector<input*> &feed);
virtual void fireRule(); //use paired conditions and facts by default
virtual void fireRule(ExpertSystemShell<input, conType> &system);
virtual void fireRule(std::vector<input*> &feed);
virtual void refreshRule();
virtual void refreshRule(std::vector<conType> &conditionSet); //in case conditions were erased
public:
Rule(){fired = false; conditionCounter = 0; decision = NULL;};
template <typename givenInput> bool matchesInput() //if condition and data match type
{return dynamic_cast<input*>(&givenInput);};
};
template <typename input, typename output> class Goal : public Rule <input, output>
{
protected:
boost::function<void(output)> decision(); //do something with AI eventually
public:
void fireRule(){};
};
template <typename input, typename output> class Weight : public Rule <input, output>
{
public:
double multiplier; //multiply input by value and return to output
void fireTule(){};
};
template <typename input> class AIholder
{ //stores certain condition and its temporal value
public:
si32 aiValue;
input *object;
AIholder(){object = NULL; aiValue = 0;}
AIholder(input &o){object = o; aiValue = 0;}
AIholder(input &o, si32 val){object = 0; aiValue = val;}
};
class BonusSystemExpert : public ExpertSystemShell <BRule, Bonus>
{ //TODO: less templates?
enum effectType {POSITIVE=1, NEGATIVE=2, EXCLUDING=4, ENEMY=8, ALLY=16}; //what is the influence of bonus and for who
};
class BonusCondition : public condition<CSelector> //used to test rule
{
public:
enum Parameter
{
type, subtype, val, duration, source, id, valType, additionalInfo, effectRange, limiter //?
};
bool matchesFact(Bonus &fact);
};
class BonusHolder : public AIholder<Bonus>
{
public:
BonusHolder(Bonus &bonus){object = &bonus; aiValue = bonus.val;}
BonusHolder(Bonus &bonus, si32 val){object = &bonus; aiValue = val;}
};
class BonusRule : public Rule <BonusHolder, BonusCondition>
{
protected:
void fireRule();
};
inline bool greaterThan (int prop, si32 val) //does it make any sense to keep functors inline?
{
if ((si32)prop > val)
return true;
return false;
}
inline bool lessThan (int prop, si32 val)
{
if ((si32)prop < val)
return true;
return false;
}
inline bool eqal (int prop, si32 val)
{
if ((si32)prop == val)
return true;
return false;
}
inline bool unequal (int prop, si32 val)
{
if ((si32)prop != val)
return true;
return false;
}
inline bool present (int prop, si32 val=0)
//inline bool present (int prop) //TODO: can we use function with less arguments?
{
return(prop); //unfixable warning :(
}
class LogicConjunction
{
const TLogic first, second; //TODO: universal argument list of functions?
public:
LogicConjunction(const TLogic First, const TLogic Second)
:first(First), second(Second)
{
}
bool operator()(int prop, si32 val) const
{
return first(prop,val) && second(prop,val);
}
};
TLogic operator&&(const TLogic &first, const TLogic &second);
class LogicAlternative
{
const TLogic first, second;
public:
LogicAlternative(const TLogic First, const TLogic Second)
:first(First), second(Second)
{
}
bool operator()(int prop, si32 val) const
{
return first(prop,val) || second(prop,val);
}
};
TLogic operator||(const TLogic &first, const TLogic &second);
class KnowledgeHandler///I'd opt for one omniscent knowledge manager, so no templates here
{
public:
std::list<BonusRule> knowledge; //permanent storage of rules
void parseKnowledge(std::string &filename){};
void addKnowledge(ExpertSystemShell<BRule,Bonus> &expert);
void addFacts(ExpertSystemShell<BRule,Bonus> &expert);
};

View File

@ -1,22 +0,0 @@
#include "StdInc.h"
#include "GeneralAI.h"
#include "../../CCallback.h"
using namespace geniusai::GeneralAI;
CGeneralAI::CGeneralAI()
: m_cb(NULL)
{
}
CGeneralAI::~CGeneralAI()
{
}
void CGeneralAI::init(CCallback *CB)
{
assert(CB != NULL);
m_cb = CB;
CB->waitTillRealize = true;
}

View File

@ -1,18 +0,0 @@
#pragma once
#include "Common.h"
namespace geniusai { namespace GeneralAI {
class CGeneralAI
{
public:
CGeneralAI();
~CGeneralAI();
void init(CCallback* CB);
private:
CCallback *m_cb;
};
}}

View File

@ -1,24 +0,0 @@
vcmiaidir = $(VCMI_AI_LIBS_DIR)
BUILT_SOURCES = StdInc.h.gch
StdInc.h.gch: StdInc.h
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
vcmiai_LTLIBRARIES = libGeniusAI.la
libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
libGeniusAI_la_CXXFLAGS = -DVCMI_DLL
libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
libGeniusAI_la_SOURCES = \
AIPriorities.cpp \
AIPriorities.h \
BattleHelper.cpp \
BattleHelper.h \
BattleLogic.cpp \
BattleLogic.h \
CGeniusAI.cpp \
CGeniusAI.h \
Common.h \
DLLMain.cpp \
GeneralAI.cpp \
GeneralAI.h \
neuralNetwork.cpp \
neuralNetwork.h

View File

@ -1,675 +0,0 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = AI/GeniusAI
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/aclocal/m4/ax_boost_base.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_filesystem.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_iostreams.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_program_options.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_system.m4 \
$(top_srcdir)/aclocal/m4/ax_boost_thread.m4 \
$(top_srcdir)/aclocal/m4/ax_compiler_vendor.m4 \
$(top_srcdir)/aclocal/m4/libtool.m4 \
$(top_srcdir)/aclocal/m4/ltoptions.m4 \
$(top_srcdir)/aclocal/m4/ltsugar.m4 \
$(top_srcdir)/aclocal/m4/ltversion.m4 \
$(top_srcdir)/aclocal/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(vcmiaidir)"
LTLIBRARIES = $(vcmiai_LTLIBRARIES)
libGeniusAI_la_DEPENDENCIES = $(top_builddir)/lib/libvcmi.la
am_libGeniusAI_la_OBJECTS = libGeniusAI_la-AIPriorities.lo \
libGeniusAI_la-BattleHelper.lo libGeniusAI_la-BattleLogic.lo \
libGeniusAI_la-CGeniusAI.lo libGeniusAI_la-DLLMain.lo \
libGeniusAI_la-GeneralAI.lo libGeniusAI_la-neuralNetwork.lo
libGeniusAI_la_OBJECTS = $(am_libGeniusAI_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
libGeniusAI_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
$(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) \
$(libGeniusAI_la_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_$(V))
am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
am__v_CXX_0 = @echo " CXX " $@;
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
am__v_at_0 = @
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_$(V))
am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
am__v_CXXLD_0 = @echo " CXXLD " $@;
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo " CC " $@;
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_$(V))
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libGeniusAI_la_SOURCES)
DIST_SOURCES = $(libGeniusAI_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
BOOST_FILESYSTEM_LIB = @BOOST_FILESYSTEM_LIB@
BOOST_IOSTREAMS_LIB = @BOOST_IOSTREAMS_LIB@
BOOST_LDFLAGS = @BOOST_LDFLAGS@
BOOST_PROGRAM_OPTIONS_LIB = @BOOST_PROGRAM_OPTIONS_LIB@
BOOST_SYSTEM_LIB = @BOOST_SYSTEM_LIB@
BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FFMPEG_CXXFLAGS = @FFMPEG_CXXFLAGS@
FFMPEG_LIBS = @FFMPEG_LIBS@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_CXXFLAGS = @SDL_CXXFLAGS@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VCMI_AI_LIBS_DIR = @VCMI_AI_LIBS_DIR@
VCMI_SCRIPTING_LIBS_DIR = @VCMI_SCRIPTING_LIBS_DIR@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
vcmiaidir = $(VCMI_AI_LIBS_DIR)
BUILT_SOURCES = StdInc.h.gch
vcmiai_LTLIBRARIES = libGeniusAI.la
libGeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
libGeniusAI_la_CXXFLAGS = -DVCMI_DLL
libGeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module -avoid-version
libGeniusAI_la_SOURCES = \
AIPriorities.cpp \
AIPriorities.h \
BattleHelper.cpp \
BattleHelper.h \
BattleLogic.cpp \
BattleLogic.h \
CGeniusAI.cpp \
CGeniusAI.h \
Common.h \
DLLMain.cpp \
GeneralAI.cpp \
GeneralAI.h \
neuralNetwork.cpp \
neuralNetwork.h
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu AI/GeniusAI/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu AI/GeniusAI/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-vcmiaiLTLIBRARIES: $(vcmiai_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(vcmiaidir)" || $(MKDIR_P) "$(DESTDIR)$(vcmiaidir)"
@list='$(vcmiai_LTLIBRARIES)'; test -n "$(vcmiaidir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(vcmiaidir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(vcmiaidir)"; \
}
uninstall-vcmiaiLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(vcmiai_LTLIBRARIES)'; test -n "$(vcmiaidir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(vcmiaidir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(vcmiaidir)/$$f"; \
done
clean-vcmiaiLTLIBRARIES:
-test -z "$(vcmiai_LTLIBRARIES)" || rm -f $(vcmiai_LTLIBRARIES)
@list='$(vcmiai_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libGeniusAI.la: $(libGeniusAI_la_OBJECTS) $(libGeniusAI_la_DEPENDENCIES)
$(AM_V_CXXLD)$(libGeniusAI_la_LINK) -rpath $(vcmiaidir) $(libGeniusAI_la_OBJECTS) $(libGeniusAI_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-AIPriorities.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleHelper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-BattleLogic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-DLLMain.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-GeneralAI.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
libGeniusAI_la-AIPriorities.lo: AIPriorities.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-AIPriorities.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-AIPriorities.Tpo $(DEPDIR)/libGeniusAI_la-AIPriorities.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='AIPriorities.cpp' object='libGeniusAI_la-AIPriorities.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-AIPriorities.lo `test -f 'AIPriorities.cpp' || echo '$(srcdir)/'`AIPriorities.cpp
libGeniusAI_la-BattleHelper.lo: BattleHelper.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleHelper.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleHelper.Tpo $(DEPDIR)/libGeniusAI_la-BattleHelper.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleHelper.cpp' object='libGeniusAI_la-BattleHelper.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleHelper.lo `test -f 'BattleHelper.cpp' || echo '$(srcdir)/'`BattleHelper.cpp
libGeniusAI_la-BattleLogic.lo: BattleLogic.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-BattleLogic.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-BattleLogic.Tpo $(DEPDIR)/libGeniusAI_la-BattleLogic.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='BattleLogic.cpp' object='libGeniusAI_la-BattleLogic.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-BattleLogic.lo `test -f 'BattleLogic.cpp' || echo '$(srcdir)/'`BattleLogic.cpp
libGeniusAI_la-CGeniusAI.lo: CGeniusAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-CGeniusAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-CGeniusAI.Tpo $(DEPDIR)/libGeniusAI_la-CGeniusAI.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='CGeniusAI.cpp' object='libGeniusAI_la-CGeniusAI.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-CGeniusAI.lo `test -f 'CGeniusAI.cpp' || echo '$(srcdir)/'`CGeniusAI.cpp
libGeniusAI_la-DLLMain.lo: DLLMain.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-DLLMain.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-DLLMain.Tpo $(DEPDIR)/libGeniusAI_la-DLLMain.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='DLLMain.cpp' object='libGeniusAI_la-DLLMain.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-DLLMain.lo `test -f 'DLLMain.cpp' || echo '$(srcdir)/'`DLLMain.cpp
libGeniusAI_la-GeneralAI.lo: GeneralAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-GeneralAI.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-GeneralAI.Tpo $(DEPDIR)/libGeniusAI_la-GeneralAI.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='GeneralAI.cpp' object='libGeniusAI_la-GeneralAI.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-GeneralAI.lo `test -f 'GeneralAI.cpp' || echo '$(srcdir)/'`GeneralAI.cpp
libGeniusAI_la-neuralNetwork.lo: neuralNetwork.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -MT libGeniusAI_la-neuralNetwork.lo -MD -MP -MF $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libGeniusAI_la-neuralNetwork.Tpo $(DEPDIR)/libGeniusAI_la-neuralNetwork.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='neuralNetwork.cpp' object='libGeniusAI_la-neuralNetwork.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libGeniusAI_la_CXXFLAGS) $(CXXFLAGS) -c -o libGeniusAI_la-neuralNetwork.lo `test -f 'neuralNetwork.cpp' || echo '$(srcdir)/'`neuralNetwork.cpp
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(vcmiaidir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool clean-vcmiaiLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-vcmiaiLTLIBRARIES
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-vcmiaiLTLIBRARIES
.MAKE: all check install install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-vcmiaiLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip install-vcmiaiLTLIBRARIES installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-vcmiaiLTLIBRARIES
StdInc.h.gch: StdInc.h
$(CXXCOMPILE) -DVCMI_DLL -fPIC -c $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,2 +0,0 @@
// Creates the precompiled header
#include "StdInc.h"

View File

@ -1,7 +0,0 @@
#pragma once
#include "../../Global.h"
// This header should be treated as a pre compiled header file(PCH) in the compiler building settings.
// Here you can add specific libraries and macros which are specific to this project.

View File

@ -1,244 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="RD|Win32">
<Configuration>RD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="RD|x64">
<Configuration>RD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}</ProjectGuid>
<RootNamespace>genius</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RD|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RD|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='RD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\VCMI_global.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='RD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\VCMI_global.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\VCMI_global.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\VCMI_global.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\AI\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)\AI\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(SolutionDir)$(Configuration)\bin\AI\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(SolutionDir)$(Configuration)\bin\AI\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RD|x64'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">false</GenerateManifest>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RD|x64'">false</GenerateManifest>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='RD|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='RD|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='RD|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='RD|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='RD|x64'" />
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IncludePath)</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(IncludePath)</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(IncludePath)</IncludePath>
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath>
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(LibraryPath)</LibraryPath>
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(LibraryPath)</LibraryPath>
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='RD|x64'">$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GENIUS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PrecompiledHeaderFile>StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)GeniusAI.dll</OutputFile>
<AdditionalLibraryDirectories>$(OutDir)..;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>
</OptimizeReferences>
<TargetMachine>MachineX86</TargetMachine>
<Profile>false</Profile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GENIUS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)GeniusAI.dll</OutputFile>
<AdditionalLibraryDirectories>$(OutDir)..;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>
</OptimizeReferences>
<Profile>false</Profile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">
<ClCompile>
<AdditionalOptions>/Oy- %(AdditionalOptions)</AdditionalOptions>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GENIUS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>$(SolutionDir)$(Configuration)\</AssemblerListingLocation>
<ProgramDataBaseFileName>$(SolutionDir)$(Configuration)\GeniusAI.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)GeniusAI.dll</OutputFile>
<AdditionalLibraryDirectories>$(OutDir)..;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RD|x64'">
<ClCompile>
<AdditionalOptions>/Oy- %(AdditionalOptions)</AdditionalOptions>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GENIUS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>$(SolutionDir)$(Configuration)\</AssemblerListingLocation>
<ProgramDataBaseFileName>$(SolutionDir)$(Configuration)\GeniusAI.pdb</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4512;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)GeniusAI.dll</OutputFile>
<AdditionalLibraryDirectories>$(OutDir)..;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="BattleHelper.cpp" />
<ClCompile Include="BattleLogic.cpp" />
<ClCompile Include="GeneralAI.cpp" />
<ClCompile Include="AIPriorities.cpp" />
<ClCompile Include="CGeniusAI.cpp" />
<ClCompile Include="DLLMain.cpp" />
<ClCompile Include="neuralNetwork.cpp" />
<ClCompile Include="StdInc.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BattleHelper.h" />
<ClInclude Include="BattleLogic.h" />
<ClInclude Include="GeneralAI.h" />
<ClInclude Include="AIPriorities.h" />
<ClInclude Include="CGeniusAI.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="neuralNetwork.h" />
<ClInclude Include="StdInc.h" />
<ClInclude Include="..\..\Global.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\VCMI_lib.vcxproj">
<Project>{b952ffc5-3039-4de1-9f08-90acda483d8f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,417 +0,0 @@
#include "StdInc.h"
#include "neuralNetwork.h"
//using namespace std;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static double norm(void)//add desired mean, multiply to get desired SD
{
static double kept = 0;
static bool in = 0;
if(!in)
{
double x = (rand() + 1) / static_cast<double>(RAND_MAX + 1);
double f = sqrtf( - 2.0 * log(x) );
x = (rand() + 1) / static_cast<double>(RAND_MAX + 1);
kept = f * cosf( 2.0 * M_PI * x );
in = true;
return f * sinf( 2.0 * M_PI * x );
}
else
{
in = false;
return kept;
}
}
/*******************************************************************
* Constructors
********************************************************************/
neuralNetwork::neuralNetwork() : nInput(0), nHidden1(0), nHidden2(0), nOutput(0)
{
inputNeurons = new double[1] ;
hiddenNeurons1 = new double[1] ;
hiddenNeurons2 = new double[1] ;
outputNeurons = new double[1] ;
wInputHidden = new double*[1] ;
wInputHidden[0] = new double[1];
wHidden2Hidden = new double*[1] ;
wHidden2Hidden[0] = new (double[1]);
wHiddenOutput = new double*[1] ;
wHiddenOutput[0] = new double[1];
}
neuralNetwork::neuralNetwork(const neuralNetwork& other): nInput(0), nHidden1(0), nHidden2(0), nOutput(0)
{
inputNeurons = new double[1] ;
hiddenNeurons1 = new double[1] ;
hiddenNeurons2 = new double[1] ;
outputNeurons = new double[1] ;
wInputHidden = new double*[1] ;
wInputHidden[0] = new double[1];
wHidden2Hidden = new double*[1] ;
wHidden2Hidden[0] = new (double[1]);
wHiddenOutput = new double*[1] ;
wHiddenOutput[0] = new double[1];
*this = other;
}
neuralNetwork::neuralNetwork(int nI, int nH1, int nH2, int nO) : nInput(nI), nHidden1(nH1), nHidden2(nH2), nOutput(nO)
{
//create neuron lists
//--------------------------------------------------------------------------------------------------------
inputNeurons = new double[nInput + 1] ;
for ( int i=0; i < nInput; i++ ) inputNeurons[i] = 0;
//create input bias neuron
inputNeurons[nInput] = -1;
hiddenNeurons1 = new double[nHidden1 + 1] ;
for ( int i=0; i < nHidden1; i++ ) hiddenNeurons1[i] = 0;
//create hidden bias neuron
hiddenNeurons1[nHidden1] = -1;
hiddenNeurons2 = new double[nHidden2 + 1] ;
for ( int i=0; i < nHidden2; i++ ) hiddenNeurons2[i] = 0;
//create hidden bias neuron
hiddenNeurons2[nHidden2] = -1;
outputNeurons = new double[nOutput] ;
for ( int i=0; i < nOutput; i++ ) outputNeurons[i] = 0;
//create weight lists (include bias neuron weights)
//--------------------------------------------------------------------------------------------------------
wInputHidden = new double*[nInput + 1] ;
for ( int i=0; i <= nInput; i++ )
{
wInputHidden[i] = new double[nHidden1];
for ( int j=0; j < nHidden1; j++ ) wInputHidden[i][j] = 0;
}
wHidden2Hidden = new double*[nHidden1 + 1] ;
for ( int i=0; i <= nHidden1; i++ )
{
wHidden2Hidden[i] = new (double[nHidden2]);
for ( int j=0; j < nHidden2; j++ ) wHidden2Hidden[i][j] = 0;
}
wHiddenOutput = new double*[nHidden2 + 1] ;
for ( int i=0; i <= nHidden2; i++ )
{
wHiddenOutput[i] = new double[nOutput];
for ( int j=0; j < nOutput; j++ ) wHiddenOutput[i][j] = 0;
}
//initialize weights
//--------------------------------------------------------------------------------------------------------
initializeWeights();
}
void neuralNetwork::operator = (const neuralNetwork&cpy)//assumes same structure
{
if( nInput != cpy.nInput || nHidden1 != cpy.nHidden1 || nHidden2 != cpy.nHidden2 || nOutput != cpy.nOutput)
{
delete[] inputNeurons;
delete[] hiddenNeurons1;
delete[] hiddenNeurons2;
delete[] outputNeurons;
//delete weight storage
for (int i=0; i <= nInput; i++) delete[] wInputHidden[i];
delete[] wInputHidden;
for (int j=0; j <= nHidden2; j++) delete[] wHiddenOutput[j];
delete[] wHiddenOutput;
for (int j=0; j <= nHidden1; j++) delete[] wHidden2Hidden[j];
delete[] wHidden2Hidden;
nInput = cpy.nInput;
nHidden1 = cpy.nHidden1;
nHidden2 = cpy.nHidden2;
nOutput = cpy.nOutput;
inputNeurons = new double[nInput + 1] ;
inputNeurons[nInput] = -1;
hiddenNeurons1 = new double[nHidden1 + 1] ;
hiddenNeurons1[nHidden1] = -1;
hiddenNeurons2 = new double[nHidden2 + 1] ;
hiddenNeurons2[nHidden2] = -1;
outputNeurons = new double[nOutput] ;
//create weight lists (include bias neuron weights)
//--------------------------------------------------------------------------------------------------------
wInputHidden = new double*[nInput + 1] ;
for ( int i=0; i <= nInput; i++ )
wInputHidden[i] = new double[nHidden1];
wHidden2Hidden = new double*[nHidden1 + 1] ;
for ( int i=0; i <= nHidden1; i++ )
wHidden2Hidden[i] = new (double[nHidden2]);
wHiddenOutput = new double*[nHidden2 + 1] ;
for ( int i=0; i <= nHidden2; i++ )
wHiddenOutput[i] = new double[nOutput];
}
for ( int i=0; i < nInput; i++ ) inputNeurons[i] = cpy.inputNeurons[i];
for ( int i=0; i < nHidden1; i++ ) hiddenNeurons1[i] = cpy.hiddenNeurons1[i];
for ( int i=0; i < nHidden2; i++ ) hiddenNeurons2[i] = cpy.hiddenNeurons2[i];
for ( int i=0; i < nOutput; i++ ) outputNeurons[i] = cpy.outputNeurons[i];
for ( int i=0; i <= nInput; i++ )
for ( int j=0; j < nHidden1; j++ )
wInputHidden[i][j] = cpy.wInputHidden[i][j];
for ( int i=0; i <= nHidden1; i++ )
for ( int j=0; j < nHidden2; j++ )
wHidden2Hidden[i][j] = cpy.wHidden2Hidden[i][j];
for ( int i=0; i <= nHidden2; i++ )
for ( int j=0; j < nOutput; j++ )
wHiddenOutput[i][j] = cpy.wHiddenOutput[i][j];
}
/*******************************************************************
* Destructor
********************************************************************/
neuralNetwork::~neuralNetwork()
{
//delete neurons
delete[] inputNeurons;
delete[] hiddenNeurons1;
delete[] hiddenNeurons2;
delete[] outputNeurons;
//delete weight storage
for (int i=0; i <= nInput; i++) delete[] wInputHidden[i];
delete[] wInputHidden;
for (int j=0; j <= nHidden2; j++) delete[] wHiddenOutput[j];
delete[] wHiddenOutput;
for (int j=0; j <= nHidden1; j++) delete[] wHidden2Hidden[j];
delete[] wHidden2Hidden;
}
double* neuralNetwork::feedForwardPattern(double *pattern)
{
feedForward(pattern);
return outputNeurons;
}
void neuralNetwork::mate(const neuralNetwork&n1,const neuralNetwork&n2)
{
for(int i = 0; i <= nInput; i++)
{
for(int j = 0; j < nHidden1; j++)
{
if(rand()%2==0)
wInputHidden[i][j] = n1.wInputHidden[i][j];
else
wInputHidden[i][j] = n2.wInputHidden[i][j];
}
}
for(int i = 0; i <= nHidden1; i++)
{
for(int j = 0; j < nHidden2; j++)
{
if(rand()%2==0)
wHidden2Hidden[i][j] =n1.wHidden2Hidden[i][j];
else
wHidden2Hidden[i][j] =n2.wHidden2Hidden[i][j];
}
}
for(int i = 0; i <= nHidden2; i++)
{
for(int j = 0; j < nOutput; j++)
{
if(rand()%2==0)
wHiddenOutput[i][j] =n1.wHiddenOutput[i][j];
else
wHiddenOutput[i][j] =n2.wHiddenOutput[i][j];
}
}
}
void neuralNetwork::tweakWeights(double howMuch)
{
//set range
double rH = 1/sqrt( (double) nInput);
double rO = 1/sqrt( (double) nHidden1);
for(int i = 0; i <= nInput; i++)
{
for(int j = 0; j < nHidden1; j++)
{
wInputHidden[i][j] += howMuch*norm();
}
}
for(int i = 0; i <= nHidden1; i++)
{
for(int j = 0; j < nHidden2; j++)
{
wHidden2Hidden[i][j] += howMuch*norm();
}
}
for(int i = 0; i <= nHidden2; i++)
{
for(int j = 0; j < nOutput; j++)
{
wHiddenOutput[i][j] += howMuch* norm();
}
}
//initializeWeights();
}
void neuralNetwork::initializeWeights()
{
//set range
double rH = 2.0/sqrt( (double) nInput);
double rO = 2.0/sqrt( (double) nHidden1);
//set weights between input and hidden
//--------------------------------------------------------------------------------------------------------
for(int i = 0; i <= nInput; i++)
{
for(int j = 0; j < nHidden1; j++)
{
//set weights to random values
wInputHidden[i][j] = norm()* rH;
}
}
for(int i = 0; i <= nHidden1; i++)
{
for(int j = 0; j < nHidden2; j++)
{
//set weights to random values
wHidden2Hidden[i][j] = norm()* rO;
}
}
//set weights between hidden and output
//--------------------------------------------------------------------------------------------------------
for(int i = 0; i <= nHidden2; i++)
{
for(int j = 0; j < nOutput; j++)
{
//set weights to random values
wHiddenOutput[i][j] = norm()* rO;
}
}
}
/*******************************************************************
* Activation Function
********************************************************************/
inline double neuralNetwork::activationFunction( double x )
{
//sigmoid function
return 1/(1+exp(-x));
}
/*******************************************************************
* Feed Forward Operation
********************************************************************/
void neuralNetwork::feedForward(double* pattern)
{
//set input neurons to input values
for(int i = 0; i < nInput; i++) inputNeurons[i] = pattern[i];
//Calculate Hidden Layer values - include bias neuron
//--------------------------------------------------------------------------------------------------------
for(int j=0; j < nHidden1; j++)
{
//clear value
hiddenNeurons1[j] = 0;
//get weighted sum of pattern and bias neuron
for( int i=0; i <= nInput; i++ ) hiddenNeurons1[j] += inputNeurons[i] * wInputHidden[i][j];
//set to result of sigmoid
hiddenNeurons1[j] = activationFunction( hiddenNeurons1[j] );
}
for(int j=0; j < nHidden2; j++)
{
//clear value
hiddenNeurons2[j] = 0;
//get weighted sum of pattern and bias neuron
for( int i=0; i <= nHidden1; i++ ) hiddenNeurons2[j] += hiddenNeurons1[i] * wHidden2Hidden[i][j];
//set to result of sigmoid
hiddenNeurons2[j] = activationFunction( hiddenNeurons2[j] );
}
//Calculating Output Layer values - include bias neuron
//--------------------------------------------------------------------------------------------------------
for(int k=0; k < nOutput; k++)
{
//clear value
outputNeurons[k] = 0;
//get weighted sum of pattern and bias neuron
for( int j=0; j <= nHidden2; j++ ) outputNeurons[k] += hiddenNeurons2[j] * wHiddenOutput[j][k];
//set to result of sigmoid
//outputNeurons[k] = activationFunction( outputNeurons[k] );
}
}
void neuralNetwork::backpropigate(double* pattern, double OLR, double H2LR, double H1LR )
{
//inputError = new double[nInput + 1] ;
double * hiddenError1 = new double[nHidden1 + 1] ;
double * hiddenError2 = new double[nHidden2 + 1] ;
double * outputError = new double[nOutput] ;
memset(hiddenError1,0,sizeof(double)*nHidden1);
memset(hiddenError2,0,sizeof(double)*nHidden2);
for(int i = 0; i < nOutput; i++)
{
outputError[i] = (pattern[i]-outputNeurons[i]);//*(outputNeurons[i]*(1-outputNeurons[i]));
for(int ii = 0; ii <= nHidden2;ii++)
hiddenError2[ii]+=outputError[i]*wHiddenOutput[ii][i];
for(int ii = 0; ii <= nHidden2;ii++)
wHiddenOutput[ii][i]+=OLR*hiddenNeurons2[ii]*outputError[i];
}
for(int i = 0; i < nHidden2; i++)
{
hiddenError2[i] *= (hiddenNeurons2[i]*(1-hiddenNeurons2[i]));
for(int ii = 0; ii <= nHidden1;ii++)
hiddenError1[ii]+=hiddenError2[i]*wHidden2Hidden[ii][i];
for(int ii = 0; ii <= nHidden1;ii++)
wHidden2Hidden[ii][i]+=H2LR*hiddenNeurons1[ii]*hiddenError2[i];
}
for(int i = 0; i < nHidden1; i++)
{
hiddenError1[i] *= (hiddenNeurons1[i]*(1-hiddenNeurons1[i]));
for(int ii = 0; ii <= nInput;ii++)
wInputHidden[ii][i]+=H1LR*inputNeurons[ii]*hiddenError1[i];
}
delete [] hiddenError1;
delete [] hiddenError2;
delete [] outputError;
}

View File

@ -1,61 +0,0 @@
/*******************************************************************
* addapted by Trevor Standley for use as a function approximator
* Addapted from:
* Basic Feed Forward Neural Network Class
* ------------------------------------------------------------------
* Bobby Anguelov - takinginitiative.wordpress.com (2008)
* MSN & email: banguelov@cs.up.ac.za
********************************************************************/
#pragma once
//standard includes
#include <limits>
class neuralNetwork
{
private:
//number of neurons
int nInput, nHidden1, nHidden2, nOutput;
//neurons
double* inputNeurons;
double* hiddenNeurons1;
double* hiddenNeurons2;
double* outputNeurons;
//weights
double** wInputHidden;
double** wHidden2Hidden;
double** wHiddenOutput;
public:
//constructor & destructor
neuralNetwork(int numInput, int numHidden1, int numHidden2, int numOutput);
neuralNetwork(const neuralNetwork&);
neuralNetwork();
void operator = (const neuralNetwork&);
~neuralNetwork();
//weight operations
double* feedForwardPattern( double* pattern );
void backpropigate(double* pattern, double OLR, double H2LR, double H1LR );
void tweakWeights(double howMuch);
void mate(const neuralNetwork&n1,const neuralNetwork&n2);
private:
void initializeWeights();
inline double activationFunction( double x );
void feedForward( double* pattern );
};
std::istream & operator >> (std::istream &, neuralNetwork & ann);
std::ostream & operator << (std::ostream &, const neuralNetwork & ann);