<commit_before>#include "SupplyManager.h"

#include "Neohuman.h"
#include "BuildingQueue.h"
#include "Util.h"

Neolib::SupplyManager supplyManager;

namespace Neolib {

	SupplyCount::SupplyCount() : protoss(0), terran(0), zerg(0) {

	}

	SupplyCount::SupplyCount(int protoss, int terran, int zerg) : protoss(protoss), terran(terran), zerg(zerg) {

	}

	SupplyCount SupplyCount::operator+ (const SupplyCount &other) const {
		return SupplyCount(protoss + other.protoss, terran + other.terran, zerg + other.zerg);
	}

	SupplyCount &SupplyCount::operator+=(const SupplyCount &other) {
		protoss += other.protoss;
		terran += other.terran;
		zerg += other.zerg;
		return *this;
	}

	SupplyCount SupplyCount::operator- (const SupplyCount &other) const {
		return SupplyCount(protoss - other.protoss, terran - other.terran, zerg - other.zerg);
	}

	SupplyCount &SupplyCount::operator-=(const SupplyCount &other) {
		protoss -= other.protoss;
		terran -= other.terran;
		zerg -= other.zerg;
		return *this;
	}
	
	SupplyCount SupplyCount::operator* (const int factor) const {
		return SupplyCount(protoss * factor, terran * factor, zerg * factor);
	}

	SupplyCount &SupplyCount::operator*=(const int factor) {
		protoss *= factor;
		terran *= factor;
		zerg *= factor;
		return *this;
	}

	SupplyCount SupplyCount::operator/ (const int divisor) const {
		return SupplyCount(protoss / divisor, terran / divisor, zerg / divisor);
	}

	SupplyCount &SupplyCount::operator/=(const int divisor) {
		protoss /= divisor;
		terran /= divisor;
		zerg /= divisor;
		return *this;
	}

	int mainSupply(SupplyCount sc) {
		if (neoInstance->playingRace == BWAPI::Races::Protoss)
			return sc.protoss;
		if (neoInstance->playingRace == BWAPI::Races::Terran)
			return sc.terran;
		if (neoInstance->playingRace == BWAPI::Races::Zerg)
			return sc.zerg;

		return 0;
	}

	SupplyCount SupplyManager::usedSupply() {
		return SupplyCount(BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss),
						   BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran),
						   BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg));
	}

	SupplyCount SupplyManager::availableSupply() {
		return SupplyCount(BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Protoss),
						   BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Terran),
						   BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Zerg));
	}

	SupplyCount SupplyManager::wantedSupplyOverhead() {
		SupplyCount wantedOverhead;

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss) || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Protoss))
			wantedOverhead.protoss = 2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss) - 20) / 8, 0);

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran)  || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Terran))
			wantedOverhead.terran =  2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran) - 20) / 8, 0);

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg)    || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Zerg))
			wantedOverhead.zerg =    2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg) - 20) / 8, 0);

		return wantedOverhead;

	}

	SupplyCount SupplyManager::wantedAdditionalSupply() {
		return usedSupply() + wantedSupplyOverhead() - availableSupply() - buildingQueue.getQueuedSupply(false);
	}

}<commit_msg>Better supply managment, less resource floating too<commit_after>#include "SupplyManager.h"

#include "Neohuman.h"
#include "BuildingQueue.h"
#include "Util.h"

Neolib::SupplyManager supplyManager;

namespace Neolib {

	SupplyCount::SupplyCount() : protoss(0), terran(0), zerg(0) {

	}

	SupplyCount::SupplyCount(int protoss, int terran, int zerg) : protoss(protoss), terran(terran), zerg(zerg) {

	}

	SupplyCount SupplyCount::operator+ (const SupplyCount &other) const {
		return SupplyCount(protoss + other.protoss, terran + other.terran, zerg + other.zerg);
	}

	SupplyCount &SupplyCount::operator+=(const SupplyCount &other) {
		protoss += other.protoss;
		terran += other.terran;
		zerg += other.zerg;
		return *this;
	}

	SupplyCount SupplyCount::operator- (const SupplyCount &other) const {
		return SupplyCount(protoss - other.protoss, terran - other.terran, zerg - other.zerg);
	}

	SupplyCount &SupplyCount::operator-=(const SupplyCount &other) {
		protoss -= other.protoss;
		terran -= other.terran;
		zerg -= other.zerg;
		return *this;
	}
	
	SupplyCount SupplyCount::operator* (const int factor) const {
		return SupplyCount(protoss * factor, terran * factor, zerg * factor);
	}

	SupplyCount &SupplyCount::operator*=(const int factor) {
		protoss *= factor;
		terran *= factor;
		zerg *= factor;
		return *this;
	}

	SupplyCount SupplyCount::operator/ (const int divisor) const {
		return SupplyCount(protoss / divisor, terran / divisor, zerg / divisor);
	}

	SupplyCount &SupplyCount::operator/=(const int divisor) {
		protoss /= divisor;
		terran /= divisor;
		zerg /= divisor;
		return *this;
	}

	int mainSupply(SupplyCount sc) {
		if (neoInstance->playingRace == BWAPI::Races::Protoss)
			return sc.protoss;
		if (neoInstance->playingRace == BWAPI::Races::Terran)
			return sc.terran;
		if (neoInstance->playingRace == BWAPI::Races::Zerg)
			return sc.zerg;

		return 0;
	}

	SupplyCount SupplyManager::usedSupply() {
		return SupplyCount(BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss),
						   BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran),
						   BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg));
	}

	SupplyCount SupplyManager::availableSupply() {
		return SupplyCount(BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Protoss),
						   BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Terran),
						   BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Zerg));
	}

	SupplyCount SupplyManager::wantedSupplyOverhead() {
		SupplyCount wantedOverhead;

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss) || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Protoss))
			wantedOverhead.protoss = 2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Protoss) - 12) / 6, 0);

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran)  || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Terran))
			wantedOverhead.terran =  2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Terran) - 12) / 6, 0);

		if (BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg)    || BWAPI::Broodwar->self()->supplyTotal(BWAPI::Races::Zerg))
			wantedOverhead.zerg =    2 + MAX((BWAPI::Broodwar->self()->supplyUsed(BWAPI::Races::Zerg) - 12) / 6, 0);

		return wantedOverhead;
	}

	SupplyCount SupplyManager::wantedAdditionalSupply() {
		return usedSupply() + wantedSupplyOverhead() - availableSupply() - buildingQueue.getQueuedSupply(false);
	}

}
{'fraction_non_alphanumeric': 0.1637057700778153, 'fraction_numerical': 0.00557921010130671, 'mean_word_length': 5.284132841328414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 69, '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': '3258136', 'n_tokens_mistral': 2775, 'n_tokens_neox': 2411, 'n_words': 400}