Home » MODDING HQ 1.13 » v1.13 Coding Talk » Learning how the tactical AI works
Re: Learning how the AI works[message #274360] Wed, 23 February 2011 21:13 Go to previous messageGo to previous message
MorgluM is currently offline MorgluM

 
Messages:24
Registered:March 2004
Location: Qu
Buns

Just received my teacher's comment for my master -- looks like I can't procrastinate anymore today.

I'd love to see if I can implement that.

I'm slowly becoming functional. I've installed Visual Studio 2010, and I compiled the "solution" for the latest SVN downloaded with Tortoise.

It runs and the file is called JA2-ENG-DEBUG.EXE. So I assume I compiled the WIN32 DEBUG and not the WIN32 RELEASE version by default, which is great.

Question to coders: When I start JA2-ENG-DEBUG.EXE, it creates a file named AIDEBUG.TXT ("AI DEBUG") in the JA2 program files folder. For some reason it remains empty of text when I play the game. Any reason why?

(some meat that help to answer):
I manually added some text to the AIDEBUG.TXT file and that file was removed (probably by the InitAI method, partially shown below)

I guess this means that "#ifdef JA2TESTVERSION" (from InitAI) is true but "#ifdef DEBUGDECISIONS" (from DecideAction) isnt. I'll dig a bit further to understand what #ifdef means...


here's the code for the DebugAI method, which is called a lot by the DecideAction, but only if "#ifdef DEBUGDECISIONS" is true... any idea how to set it on?
void DebugAI( STR szOutput )
{
#ifdef DEBUGDECISIONS
	// Send regular debug msg AND AI debug message
	FILE *		DebugFile;

	DebugMsg( TOPIC_JA2, DBG_LEVEL_3, szOutput );
	if ((DebugFile = fopen( "aidebug.txt", "a+t" )) != NULL)
	{
		fputs( szOutput, DebugFile );
		fputs( "
", DebugFile );
		fclose( DebugFile );
	}
	else {ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"Debug: AIDEBUG.TXT = NULL" );}  // SIMON
#endif
}

Here's the beginning of the InitAI method:

BOOLEAN InitAI( void )
{
#ifdef JA2TESTVERSION
	FILE *		DebugFile;
#endif

#ifdef _DEBUG
	if (gfDisplayCoverValues)
	{
		//memset( gsCoverValue, 0x7F, sizeof( INT16 ) * WORLD_MAX );
	}
#endif

	//If we are not loading a saved game ( if we are, this has already been called )
	if( !( gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
	{
		//init the panic system
		InitPanicSystem();
	}

#ifdef JA2TESTVERSION
	// Clear the AI debug txt file to prevent it from getting huge
	if ((DebugFile = fopen( "aidebug.txt", "w" )) != NULL)
	{
		fputs( "
", DebugFile );
		fclose( DebugFile );
	}
#endif



some code in the DecideAction method:
#ifdef DEBUGDECISIONS
	sprintf( tempstr,"DecideAction: selected action %d, actionData %d

",bAction,pSoldier->aiData.usActionData);
	DebugAI( tempstr );
#endif

[Updated on: Wed, 23 February 2011 21:23] by Moderator

Report message to a moderator

Private 1st Class
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Doubling image size
Next Topic: RII - Resolution Independent Interface [UPDATE :RII v4f]
Goto Forum:
  


Current Time: Fri Feb 14 09:52:20 GMT+2 2025

Total time taken to generate the page: 0.01478 seconds