Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TooAngel/screeps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6078ba1a4774122fc85e95abd20052130e7b9af7
Choose a base ref
..
head repository: TooAngel/screeps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f8ceddbf015a0f38aa7883e58d1fab1d3a737c8f
Choose a head ref
Showing with 25 additions and 1 deletion.
  1. +21 −0 src/brain_memory.js
  2. +1 −1 src/brain_nextroom.js
  3. +3 −0 test/test.js
21 changes: 21 additions & 0 deletions src/brain_memory.js
Original file line number Diff line number Diff line change
@@ -206,11 +206,32 @@ Upgrade less: ${strings.upgradeLess}
=========================`);
};

brain.executeEveryTicks = function(ticks) {
const timer = (ticks > 3000) ? Game.time - Memory.time + 1 : 0;
return (timer > 1) ? (Game.time % ticks) < timer : (Game.time % ticks) === 0;
};

brain.setDynamicConfigInternal = function() {
Memory.dynamicConfig = Memory.dynamicConfig || {};
Memory.dynamicConfig.nextRoom = Memory.dynamicConfig.nextRoom || {};
Memory.dynamicConfig.nextRoom.maxRooms = Math.min(config.nextRoom.maxRooms, Game.gcl.level);
};

brain.setDynamicConfigInternal();

brain.setDynamicConfig = function() {
if (!this.executeEveryTicks(1000)) {
return false;
}
this.setDynamicConfigInternal();
};

brain.prepareMemory = function() {
Memory.username = Memory.username || _.chain(Game.rooms).map('controller').flatten().filter('my').map('owner.username').first().value();
Memory.myRooms = Memory.myRooms || [];
Memory.squads = Memory.squads || {};
Memory.skippedRooms = [];
brain.setDynamicConfig();
brain.setMarketOrders();
brain.setConstructionSites();
brain.cleanCreeps();
2 changes: 1 addition & 1 deletion src/brain_nextroom.js
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ function haveEnoughSystemResources() {
return false;
}
} else {
if (Memory.myRooms.length >= config.nextRoom.maxRooms) {
if (Memory.myRooms.length >= Memory.dynamicConfig.nextRoom.maxRooms) {
return false;
}

3 changes: 3 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@ global.Game = new function() {
getUsed: () => {
},
};
this.gcl = {
level: 10
}
};
global.Memory = new function() {
};