コード例 #1
0
void testPushToQueue()	{

    cmdType nCommand_1=cmd_upgrade;
    cmdOption nStat_1=upgrade_power;
    int tar_1 = 1;

    cmdType nCommand_2=cmd_upgrade;
    cmdOption nStat_2=upgrade_range;
    int tar_2 = 2;

    ActionQueueStructure newQueue = getQueue(NULL);

    sput_fail_unless(pushToQueue(newQueue,nCommand_1,nStat_1,tar_1) == 1,"Valid: 1 Queue Item");
    sput_fail_unless(pushToQueue(newQueue,nCommand_2,nStat_2,tar_2) == 2,"Valid: 2 Queue Items");
    sput_fail_unless(getFirstCommand(newQueue) == cmd_upgrade,"Valid: Top of Queue Upgrade Command");
    sput_fail_unless(getFirstOption(newQueue) == upgrade_power,"Valid: Top of Queue Power Option");
    sput_fail_unless(getLastCommand(newQueue) == cmd_upgrade,"Valid: Last in Queue upgrade Command");
    sput_fail_unless(getLastOption(newQueue) == upgrade_range,"Valid: Last of Queue range Option");
    pushToQueue(newQueue,cmd_mktwr,mktwr_int,2);
    sput_fail_unless(getLastCommand(newQueue) == cmd_mktwr,"Valid: Last in Queue make tower command");
    sput_fail_unless(getLastOption(newQueue) == mktwr_int,"Valid: Last option in Queue is int tower");
    clearQueue();
}
コード例 #2
0
ファイル: UnitMng.cpp プロジェクト: b4rdos/StarBard
void UnitMng::generateInputs()
{
	BWAPI::Unit *enemyUnit=0;
	BWAPI::Unit *tempUnit=getUnit();
	
	//Units position

	//mapWidth() is in TilePosition Units which is 32 pixels
	inputs[0]=((tempUnit->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0));
	inputs[1]=(tempUnit->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0);
	//Group leader position
	inputs[2]=(UnitGroup->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0);
	inputs[3]=(UnitGroup->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0);
	//How many hit points?
	inputs[4]=getHitPoints();
	// Is there an enemy within the unit's seek range?
	enemyUnit=enemyExists(tempUnit);
	inputs[5]=enemyUnit?1.0:0;
	// Find closest enemy
	enemyUnit=closestEnemy();
	inputs[6]=enemyUnit?(UnitGroup->getPosition().x())/(BWAPI::Broodwar->mapWidth()*32.0):1.0;
	inputs[7]=enemyUnit?(UnitGroup->getPosition().y())/(BWAPI::Broodwar->mapHeight()*32.0):1.0;
	inputs[8]=underAttack();
	//check surroundings
	//east
	inputs[9]=getBlocked(0,1);
	//north-east
	inputs[10]=getBlocked(1,1);
	//north
	inputs[11]=getBlocked(1,0);
	//north-west
	inputs[12]=getBlocked(1,-1);
	//west
	inputs[13]=getBlocked(0,-1);
	//south-west
	inputs[14]=getBlocked(-1,-1);
	//south
	inputs[15]=getBlocked(-1,0);
	//south-east
	inputs[16]=getBlocked(-1,1);
	//Get Group Command;
	inputs[17]=GroupCommand();
	//get last Command or not maybe useless
	inputs[18]=getLastCommand();	
	//bias
	inputs[19]=1.0;
	//return inputs;
}