I\'ve just ended the basic programmation for the BL2 DEMO mode. Now, i\'m looking for a good evaluation function. If you are insterred in testing and designing an evaluation function for BL2, grab the source from cvs (D3D/WIN32 only) and recompile it. I added a \"Demo Mode\" menu item on the main page and all code concerning the AI is located in the file BotPlayer.cpp.
All the path finding and move enumeration stuff is already coded. The function which need improvements is especially the function BotPlayer::Evaluate().
Here is an example of such a function:
(This one plays rather well in OOC)
Code: Select all
float BotPlayer::Evaluate() {
// Drop the block
float descent = DropBlock();
// Number of hole before adding the block
float nbHole0 = GetNbHole();
// Add the block to the pit
AddBlock();
// Get the ratio of common edge between the block and the pit
// This greatly increase the building efficiency
float commonEdge = GetCommonEdge();
// Remove lines
float nbLines = RemoveLines();
// Number of hole after the move
float nbHole1 = GetNbHole();
// Number of added Hole (can be negative)
float addedHole = nbHole1 - nbHole0;
// Free depth (free space at the top of the pit)
float freeDepth = GetFreeDepth();
// Evaluation function
/* GOOD in 3D Mania
if( freeDepth > 0.4f )
return -addedHole + 2.0f*commonEdge + descent;
else
return nbLines + commonEdge + descent;
*/
return nbLines - 3.0f*addedHole + commonEdge + descent + 0.5f*freeDepth;
}
If you have any questions, don\'t hesitate....