コード例 #1
0
//----------------------------------------------------------------------------------------------
void DefinitionCrossMapping::InitPlayers()
{
	vector< pair<TID, MetaData::PlayerType> > m_players;
	set<BWAPI::Player*> &players = Broodwar->getPlayers();
	BWAPI::Player *pPlayer;

	for(set<BWAPI::Player*>::const_iterator i = players.begin();
		i != players.end();
		++i)
	{
		pPlayer = (*i);

		if(pPlayer->getType().getID() == PlayerTypes::Player.getID())
			m_players.push_back(make_pair(pPlayer->getID(), PLAYER_Self));
		else if(pPlayer->getType().getID() == PlayerTypes::Computer.getID())
			m_players.push_back(make_pair(pPlayer->getID(), PLAYER_Enemy));
		else if(pPlayer->isNeutral())
			m_players.push_back(make_pair(pPlayer->getID(), PLAYER_Neutral));
	}

	PlayerMapping = CrossMap<TID, MetaData::PlayerType>(m_players);
}
コード例 #2
0
void ExampleAIModule::onPlayerLeft(BWAPI::Player player)
{
  // Interact verbally with the other players in the game by
  // announcing that the other player has left.
  Broodwar->sendText("Goodbye %s!", player->getName().c_str());
}
コード例 #3
0
void ExampleAIModule::onReceiveText(BWAPI::Player player, std::string text)
{
  // Parse the received text
  Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}
コード例 #4
0
BWAPI::TilePosition MapTools::getNextExpansion(BWAPI::Player player)
{
    BWTA::BaseLocation * closestBase = nullptr;
    double minDistance = 100000;

    BWAPI::TilePosition homeTile = player->getStartLocation();

    // for each base location
    for (BWTA::BaseLocation * base : BWTA::getBaseLocations())
    {
        // if the base has gas
        if (!base->isMineralOnly() && !(base == BWTA::getStartLocation(player)))
        {
            // get the tile position of the base
            BWAPI::TilePosition tile = base->getTilePosition();
            bool buildingInTheWay = false;

            for (int x = 0; x < BWAPI::Broodwar->self()->getRace().getCenter().tileWidth(); ++x)
            {
                for (int y = 0; y < BWAPI::Broodwar->self()->getRace().getCenter().tileHeight(); ++y)
                {
                    BWAPI::TilePosition tp(tile.x + x, tile.y + y);

                    for (auto & unit : BWAPI::Broodwar->getUnitsOnTile(tp))
                    {
                        if (unit->getType().isBuilding() && !unit->isFlying())
                        {
                            buildingInTheWay = true;
                            break;
                        }
                    }
                }
            }
            
            if (buildingInTheWay)
            {
                continue;
            }

            // the base's distance from our main nexus
            BWAPI::Position myBasePosition(player->getStartLocation());
            BWAPI::Position thisTile = BWAPI::Position(tile);
            double distanceFromHome = MapTools::Instance().getGroundDistance(thisTile,myBasePosition);

            // if it is not connected, continue
            if (!BWTA::isConnected(homeTile,tile) || distanceFromHome < 0)
            {
                continue;
            }

            if (!closestBase || distanceFromHome < minDistance)
            {
                closestBase = base;
                minDistance = distanceFromHome;
            }
        }

    }

    if (closestBase)
    {
        return closestBase->getTilePosition();
    }
    else
    {
        return BWAPI::TilePositions::None;
    }
}
コード例 #5
0
ファイル: SwarmCAT.cpp プロジェクト: 4rChon/ACT-AI
void SwarmCAT::onPlayerLeft(BWAPI::Player player)
{
	Broodwar->sendText("Goodbye %s!", player->getName().c_str());
}
コード例 #6
0
ファイル: SwarmCAT.cpp プロジェクト: 4rChon/ACT-AI
void SwarmCAT::onReceiveText(BWAPI::Player player, std::string text)
{
	Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}
コード例 #7
0
ファイル: StrategyManager.cpp プロジェクト: 0x4849/c350
const int StrategyManager::getScore(BWAPI::Player player) const
{
	return player->getBuildingScore() + player->getKillScore() + player->getRazingScore() + player->getUnitScore();
}
コード例 #8
0
ファイル: OpprimoBot.cpp プロジェクト: n9jlo/OpprimoBot
void OpprimoBot::onReceiveText(BWAPI::Player player, std::string text)
{
    Broodwar << player->getName() << " said '" << text << "'" << endl;
}
コード例 #9
0
ファイル: TurkAnalyzer.cpp プロジェクト: cowden/Turk
void TurkAnalyzer::onReceiveText(BWAPI::Player player, std::string text)
{
	// Parse the received text
	Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}