From the Steam announcements: "Season #7 is open! The season will last for two months, from September 1st until November 1st."
So the Season 7 ended.
From the Steam announcements: "Season #7 is open! The season will last for two months, from September 1st until November 1st."
So the Season 7 ended.
Another tip on performance: Trying to move to the center of the room new RoomPosition(25,25,roomName)
can lead to a very high cpu usage if there are walls at and around that position, because you can never reach that position so that the search is quite exhaustive to find a route. Better moveTo the target position directly.
Also don't forget to add the range option to each goal that is in the wall (like controller, source) because of the same reason. For a source range:1 is enough.
If the creep stops in the other room, then maybe you don't call moveTo to the same target position anymore.
That makes sense as there is another opening some tiles down. It routes to the next room and a few tiles down back again.
If you keep moving to the same target position and stop changing the target depending on the current room, then this works fine.
If you do not want that other rooms are taken into account, then add to the options maxRooms:1
There is some help on discord #cpu-clinic. A link from there is:
https://github.com/bonzaiferroni/screepswiki/wiki/%23cpu-clinic-faq#javascript-performance-links
The mentioned profiler can help to identify where your cpu goes:
You can also copy attributes into an object.
e.g. sources: _.map(roomSources, s=>{id:s.id,pos:s.pos})
As a tip: It is really easier to just moveTo the target position instead of doing special cases for different rooms and border positions. But you've done is what I've done as well. The problem arises near the border because the path sometimes moves one step to the border. But the creep would end up in the wrong room and the logic would repath to the sources in that room then.
What helped to me as a workaround was to return if I end up in the wrong room by mistake. What's the best solution is to moveTo the target directly. What I didn't know at the beginning is: You can moveTo any RoomPosition, even from rooms which you do not have sight on. So I would just store the positions of the sources in Memory and then directly move to that position. It can be multiple rooms away and PathFinder will find a way. In complex rooms you might hit a limit, then you need to increase the ops in the options.
You could also create your own CostMatrix to wall off the borders with the value 255. Then the path will never end up at the border tile.
So the actual bug is that the path uses border tiles without being necessary. It can also be counted as inconvenience. If you move to the target source directly using a RoomPosition then this won't be an issue.
Usually you get quick help on discord in #world-help
The Memory object is stringified to JSON at the end of your tick, so you can only add objects that can be stringified. I never add any GameObjects, instead I add their id and resolve them later with Game.getObjectById
.
So I would map the ids of the roomSources: sources: _.map(roomSources, s=>s.id)
.
var existingData = Game.rooms[creep.memory.home].memory.roomData;
assuming that roomData is an array and initialized somewhere else, you should be able to push to it.
Later you can access the sources from Memory by mapping them back again:
var roomSources = _.map(roomData.sources, s=>Game.getObjectById(s));
Keep in mind that getObjectById only works for objects that your bot can see. You would need a creep in the remote room to see the sources. That's why I also like to store the position for pathing without sight.
I've just encountered the problem that I've got -16 cpu token. In my automatic market code there is a condition like if (!Game.resources[itemName]) continue;
. my cpuToken are 0 all times.
Yesterday evening at around 22 p.m. (CET) my script suddenly sells cpuUnlocks which I do not own., so that now I have -16 cpuUnlock.
The actual code is:
const globalResources = ['cpuUnlock', 'pixel', 'accessKey'];
...
for (var itemName of globalResources) {
if (!Game.resources[itemName]) continue;
...
if (Game.market.deal(bestOrder.id, Math.min(Game.resources[itemName], bestOrder.amount)) === OK)
...
So the engine must have delivered some Game.resources
for cpuUnlock that were not existing, whatever evaluates to false after given to the ! operator.
Even then Game.market.deal should have refused the deal because no cpuUnlock are owned to sell, instead it returned OK
.
My market code runs on shard2.
@chencreep you can recreate the missing properties with Memory.creeps={}
and Memory.rooms={}
and Memory.spawns={}
In your main.js you can write if (!_.isPlainObject(Memory.rooms)) Memory.rooms = {};
for rooms, creeps, spawns to automatically fix issues like this.