[size=75]Split from the Milestones + Concerns about the AI[/size] thread. (Zamolxis)
I just downloaded the code, and have been working with it.
I was able to get the client to compile, at which time I discovered that the AI is a dll, which is great modularity.
I want to start working on some adventure AI, the first thing I want to do is get the enemy heroes to wander randomly, but I can’t quite figure it out.
This is my current attempt, but it doesn’t really work:
void CGeniusAI::yourTurn()
{
const CGHeroInstance * lastHero = m_cb->getHeroInfo(0,0);
MsgBox("** CGeniusAI::yourTurn “);
if(!lastHero==NULL)
{
MsgBox(” AI moved hero **");
int3 dir;
//while(lastHero->)// check if dir is valid move
{
dir = lastHero->getSightCenter();
dir.x+=rand()%3-1;
dir.y+=rand()%3-1;
}
if(m_cb->moveHero(lastHero,dir)) MsgBox("** move successful **");
}
m_cb->endTurn();
}
Issue 1:
This compiles, and something does happen. The AI heroes are always shown to be in their original spots, but if you move your hero there, it just walks over it, and if you move to an adjacent spot, you enter a battle, as if the portrait never moves, but the actual hero does.
Issue 2:
This would be a pretty good start if it continued after round 1. But after the first move, the console reports that the move is invalid no matter which way it tries to move. It is as if the first move breaks the hero’s ability to move again.
Any help would be apriciated.