<commit_before>#include "MapManager.h"

#include "UnitManager.h"
#include "DetectionManager.h"
#include "BaseManager.h"

//#include <algorithm>

BWAPI::TilePosition startPos;

Neolib::MapManager mapManager;

struct sortLocations {
	static bool fromStartPos(const BWEM::Base *lhs, const BWEM::Base *rhs) {
		return lhs->Location().getApproxDistance(startPos) < rhs->Location().getApproxDistance(startPos);
	}
};

namespace Neolib {

	void MapManager::init() {
		BWEM::Map::Instance().Initialize();
		BWEM::Map::Instance().EnableAutomaticPathAnalysis();

		for (auto &a : BWEM::Map::Instance().Areas())
			for (auto &b : a.Bases())
				allBases.push_back(&b);

		for (auto &b : allBases) {
			if (BWAPI::Broodwar->isVisible(b->Location())) {
				startPos = b->Location();
				std::sort(allBases.begin(), allBases.end(), sortLocations::fromStartPos);
			}
		}
	}

	void MapManager::onFrame() {
		for (auto it = unexploredBases.begin(); it != unexploredBases.end(); ++it) {
			if (BWAPI::Broodwar->isVisible((*it)->Location())) {
				unexploredBases.erase(it);
				break;
			}
		}
	}

	const std::vector <const BWEM::Base*> MapManager::getAllBases() const {
		return allBases;
	}
	const std::set    <const BWEM::Base*> MapManager::getUnexploredBases() const {
		return unexploredBases;
	}

	const BWAPI::TilePosition MapManager::getNextBasePosition() const {
		for (auto &b : allBases) {
			for (auto &ob : baseManager.getAllBases())
				if (ob.BWEMBase == b)
					goto skiplocation;

			if (!BWAPI::Broodwar->isExplored(b->Location()))
				detectionManager.requestDetection((BWAPI::Position)b->Location());
			if (BWAPI::Broodwar->canBuildHere(b->Location(), BWAPI::UnitTypes::Terran_Command_Center, nullptr, true)) {
				for (auto &eu : unitManager.getVisibleEnemies())
					if (eu.lastPosition.getApproxDistance(BWAPI::Position(b->Location())) < 200)
						goto skiplocation;
				for (auto &eu : unitManager.getNonVisibleEnemies())
					if (eu.lastPosition.getApproxDistance(BWAPI::Position(b->Location())) < 200)<commit_msg>No more expanding next to enemies<commit_after>#include "MapManager.h"

#include "UnitManager.h"
#include "DetectionManager.h"
#include "BaseManager.h"

//#include <algorithm>

BWAPI::TilePosition startPos;

Neolib::MapManager mapManager;

struct sortLocations {
	static bool fromStartPos(const BWEM::Base *lhs, const BWEM::Base *rhs) {
		return lhs->Location().getApproxDistance(startPos) < rhs->Location().getApproxDistance(startPos);
	}
};

namespace Neolib {

	void MapManager::init() {
		BWEM::Map::Instance().Initialize();
		BWEM::Map::Instance().EnableAutomaticPathAnalysis();

		for (auto &a : BWEM::Map::Instance().Areas())
			for (auto &b : a.Bases())
				allBases.push_back(&b);

		for (auto &b : allBases) {
			if (BWAPI::Broodwar->isVisible(b->Location())) {
				startPos = b->Location();
				std::sort(allBases.begin(), allBases.end(), sortLocations::fromStartPos);
			}
		}
	}

	void MapManager::onFrame() {
		for (auto it = unexploredBases.begin(); it != unexploredBases.end(); ++it) {
			if (BWAPI::Broodwar->isVisible((*it)->Location())) {
				unexploredBases.erase(it);
				break;
			}
		}
	}

	const std::vector <const BWEM::Base*> MapManager::getAllBases() const {
		return allBases;
	}
	const std::set    <const BWEM::Base*> MapManager::getUnexploredBases() const {
		return unexploredBases;
	}

	const BWAPI::TilePosition MapManager::getNextBasePosition() const {
		for (auto &b : allBases) {
			for (auto &ob : baseManager.getAllBases())
				if (ob.BWEMBase == b)
					goto skiplocation;

			if (!BWAPI::Broodwar->isExplored(b->Location()))
				detectionManager.requestDetection((BWAPI::Position)b->Location());
			if (BWAPI::Broodwar->canBuildHere(b->Location(), BWAPI::UnitTypes::Terran_Command_Center, nullptr, true)) {
				for (auto &eu : unitManager.getVisibleEnemies())
					if (eu.lastPosition.getApproxDistance(BWAPI::Position(b->Location())) < 1000)
						goto skiplocation;
				for (auto &eu : unitManager.getNonVisibleEnemies())
					if (eu.lastPosition.getApproxDistance(BWAPI::Position(b->Location())) < 500)
{'fraction_non_alphanumeric': 0.16760874907839765, 'fraction_numerical': 0.003194888178913738, 'mean_word_length': 5.092814371257485, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1622804', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1390, 'n_words': 250}