//----------------------------------------------------------------------------------------------
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);
}
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());
}
void ExampleAIModule::onReceiveText(BWAPI::Player player, std::string text)
{
  // Parse the received text
  Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}
Beispiel #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;
    }
}
Beispiel #5
0
void SwarmCAT::onPlayerLeft(BWAPI::Player player)
{
	Broodwar->sendText("Goodbye %s!", player->getName().c_str());
}
Beispiel #6
0
void SwarmCAT::onReceiveText(BWAPI::Player player, std::string text)
{
	Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}
Beispiel #7
0
const int StrategyManager::getScore(BWAPI::Player player) const
{
	return player->getBuildingScore() + player->getKillScore() + player->getRazingScore() + player->getUnitScore();
}
Beispiel #8
0
void OpprimoBot::onReceiveText(BWAPI::Player player, std::string text)
{
    Broodwar << player->getName() << " said '" << text << "'" << endl;
}
Beispiel #9
0
void TurkAnalyzer::onReceiveText(BWAPI::Player player, std::string text)
{
	// Parse the received text
	Broodwar << player->getName() << " said \"" << text << "\"" << std::endl;
}