private void displayAllResourceCount() { if (gameState == null) { Debug.Log("Null game state"); } foreach (ResourceType rt in gameState.getAllResourceTypes()) { this.resourceDisplay.updateResourceCount(rt, gameState.getStockpile(rt)); } }
private void updateAiResourceDisplay() { Debug.Log("Updating ai resource display"); Debug.Log(bank + ", " + stone + ", " + wood + ", " + silver); foreach (ResourceType rt in aiCurrentGameState.getAllResourceTypes()) { //Debug.Log("update: " + rt + ", " + aiCurrentGameState.getStockpile(rt)); aiResourceDisplay.updateCountAndRPT(rt, aiCurrentGameState.getStockpile(rt), aiCurrentGameState.getChangePerTick(rt)); } aiResourceDisplay.updateWorkers(); }
private void updateTargetDisplay(BuildingGS gameState, int indexActor) { Debug.Log("actor to update target display: " + indexActor); ResourceDisplayController rdc = meTargetDisplay; if (indexActor == indexAi) { rdc = aiTargetDisplay; } foreach (ResourceType rt in gameState.getAllResourceTypes()) { rdc.updateCountAndRPT(rt, gameState.getStockpile(rt), gameState.getChangePerTick(rt)); } }
private BuildingGS modifyGameStateForPersonality(BuildingGS targetGsHuman, AIPersonalityType aiPersonality) { switch (aiPersonality) { case AIPersonalityType.GoldDigger: targetGsHuman.setStockpile(ResourceType.Gold, targetGsHuman.getStockpile(ResourceType.Gold) * 2); targetGsHuman.addResourcePerTick(ResourceType.Gold, targetGsHuman.getChangePerTick(ResourceType.Gold) * 2); break; case AIPersonalityType.Pragmatist: foreach (ResourceType rt in targetGsHuman.getStockpileResourceTypes()) { targetGsHuman.setStockpile(rt, (int)(targetGsHuman.getStockpile(rt) * 1.3)); } break; case AIPersonalityType.Warrior: case AIPersonalityType.ScienceGeek: case AIPersonalityType.Conservative: default: break; } return(targetGsHuman); }
private bool isTargetReached(int indexActor) { BuildingGS gsToCheck = GameController.gameState; if (indexActor == indexAi) { gsToCheck = aiCurrentGameState; } BuildingGS targetGs = targetGameStates[currentTargetGsIndex[indexActor]]; foreach (ResourceType rt in gsToCheck.getAllResourceTypes()) { if ((gsToCheck.getStockpile(rt) < targetGs.getStockpile(rt)) || (gsToCheck.getChangePerTick(rt) < targetGs.getChangePerTick(rt))) { return(false); } } Debug.Log("Target reached for : " + indexActor); return(true); }
public static RemainingDistance estematedRemainingDistance(BuildingGS currentGS, BuildingGS targetGS) { // How far away are we from the target? RemainingDistance result = new RemainingDistance(); // Compare numerical distance foreach (ResourceType rt in targetGS.getAllResourceTypes()) { int currentStockpile = currentGS.getStockpile(rt); int targetStockpile = targetGS.getStockpile(rt); int stockpileDelta = Mathf.Max(0, targetStockpile - currentStockpile); result.updateStockpileDelta(stockpileDelta); int currentResourcePerTick = currentGS.getChangePerTick(rt); int targetResourcePerTick = targetGS.getChangePerTick(rt); int rptDelta = Mathf.Max(0, targetResourcePerTick - currentResourcePerTick); result.updateCPTDelta(rt, rptDelta); int currentBestResourcePerTick = currentGS.getBestPossibleChangePerTick(rt); int bestPossibleRPTDelta = Mathf.Max(0, targetResourcePerTick - currentBestResourcePerTick); result.updateBestPossibleCPTDelta(bestPossibleRPTDelta); if (currentResourcePerTick <= 0) { result.addInfinity(); } else { float exactWaitTime = stockpileDelta / (float)currentResourcePerTick; int estWaitTime = (int)(exactWaitTime + 0.5f); result.updateWaitTime(estWaitTime); float bestPossibleWaitTime = stockpileDelta / (float)currentBestResourcePerTick; int estBestWaitTime = (int)(bestPossibleWaitTime + 0.5f); result.updateBestPossibleWaitTime(estBestWaitTime); } } return(result); }