<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CPU Assignment buggy]]></title><description><![CDATA[<p>I'm trying to do fully automatic cross shard expansion &amp; cpu management.</p>
<p>I managed to give negative and float cpu assignment to my shards. This may as well be caused by problems on my end, but since I'm now on a 12 hour lockdown I'm locked out of 3 of the 4 shards.</p>
<p>This also triggered a cpu bug on shard 2 a while after some creeps entered:</p>
<pre><code>TypeError: `timeout` must be integer
    at Object.exports.evalCode (&lt;runtime&gt;:15992:76)
    at Object.exports.run (&lt;runtime&gt;:30483:24)
</code></pre>
<p>I wasn't able to run any code on shard 2 afterwards. This error was on repeat until all my creeps died.</p>
<p><img src="/forum/assets/uploads/files/1561724631679-68a595b7-e178-41ec-b7c5-188b2beab4e2-image-resized.png" alt="0_1561724630518_68a595b7-e178-41ec-b7c5-188b2beab4e2-image.png" class="img-responsive img-markdown" /></p>
<p>This is the code that <em>probably</em> triggered it:</p>
<pre><code>        // populate shard names (by trial and error!!)
        /**@type {String[]} */
        this._shards = [];

        try {
            let i=0;
            for(let i=0; i&lt;1000;i++) {
                let shardName = 'shard'+i;
                InterShardMemory.getRemote(shardName)
                this._shards.push (shardName);
            }
        }
        catch (err) {}

            // divide cpu evenly between shards
            let totalCPU = 0;
            let shardLimits = Game.cpu.shardLimits;
            for (let shard in shardLimits) {
                totalCPU += shardLimits[shard]
            }
            let dividedCPU = totalCPU / this._shards.length;
            for (let shard of this._shards) {
                shardLimits[shard] = dividedCPU;
            }
            Game.cpu.setShardLimits(shardLimits);
</code></pre>
<p>I'm at 20 cpu, so this gives a 5/5/5/5 division.</p>
<p>There's at least one bug in my code: I'm assigning my own shardLimits by reference, thereby I modify the Game.cpu.shardlimits by accident. Does this maybe break setshardlimits?</p>
<p>Questions related to this bug:</p>
<ul>
<li>What am I doing wrong in my setShardLimit call?</li>
<li>Setshardlimit isn't documented very well. Can I pass floats or do they need to be ints?</li>
<li>Can I pass values higher then my CPU limit?</li>
<li>How can I determine my max CPU limit (without hard coding). Is my assumption correct that I can sum all assigned shard CPU?</li>
<li>How can I safely determine all shard names? Getshardlimits only returned my current shard before I reassigned.</li>
<li>What happens if I pass values higher or lower then my total or the shard limit?</li>
<li>Can setCPUlimit get some safety checking before committing to the 12 hour countdown? like: no negative values, no floats, unspend CPU automatically allocated or not allowed. The GUI already does this.</li>
</ul>
<p>Because the timeout is 12 hours and I can't find the CPU stuff in the source code on github, it's very hard to experiment / find this out for myself.</p>
]]></description><link>http://screeps.com/forum/topic/2752/cpu-assignment-buggy</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 17:23:21 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/2752.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Jun 2019 12:54:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CPU Assignment buggy on Invalid Date]]></title><description><![CDATA[<p>I'm trying to do fully automatic cross shard expansion &amp; cpu management.</p>
<p>I managed to give negative and float cpu assignment to my shards. This may as well be caused by problems on my end, but since I'm now on a 12 hour lockdown I'm locked out of 3 of the 4 shards.</p>
<p>This also triggered a cpu bug on shard 2 a while after some creeps entered:</p>
<pre><code>TypeError: `timeout` must be integer
    at Object.exports.evalCode (&lt;runtime&gt;:15992:76)
    at Object.exports.run (&lt;runtime&gt;:30483:24)
</code></pre>
<p>I wasn't able to run any code on shard 2 afterwards. This error was on repeat until all my creeps died.</p>
<p><img src="/forum/assets/uploads/files/1561724631679-68a595b7-e178-41ec-b7c5-188b2beab4e2-image-resized.png" alt="0_1561724630518_68a595b7-e178-41ec-b7c5-188b2beab4e2-image.png" class="img-responsive img-markdown" /></p>
<p>This is the code that <em>probably</em> triggered it:</p>
<pre><code>        // populate shard names (by trial and error!!)
        /**@type {String[]} */
        this._shards = [];

        try {
            let i=0;
            for(let i=0; i&lt;1000;i++) {
                let shardName = 'shard'+i;
                InterShardMemory.getRemote(shardName)
                this._shards.push (shardName);
            }
        }
        catch (err) {}

            // divide cpu evenly between shards
            let totalCPU = 0;
            let shardLimits = Game.cpu.shardLimits;
            for (let shard in shardLimits) {
                totalCPU += shardLimits[shard]
            }
            let dividedCPU = totalCPU / this._shards.length;
            for (let shard of this._shards) {
                shardLimits[shard] = dividedCPU;
            }
            Game.cpu.setShardLimits(shardLimits);
</code></pre>
<p>I'm at 20 cpu, so this gives a 5/5/5/5 division.</p>
<p>There's at least one bug in my code: I'm assigning my own shardLimits by reference, thereby I modify the Game.cpu.shardlimits by accident. Does this maybe break setshardlimits?</p>
<p>Questions related to this bug:</p>
<ul>
<li>What am I doing wrong in my setShardLimit call?</li>
<li>Setshardlimit isn't documented very well. Can I pass floats or do they need to be ints?</li>
<li>Can I pass values higher then my CPU limit?</li>
<li>How can I determine my max CPU limit (without hard coding). Is my assumption correct that I can sum all assigned shard CPU?</li>
<li>How can I safely determine all shard names? Getshardlimits only returned my current shard before I reassigned.</li>
<li>What happens if I pass values higher or lower then my total or the shard limit?</li>
<li>Can setCPUlimit get some safety checking before committing to the 12 hour countdown? like: no negative values, no floats, unspend CPU automatically allocated or not allowed. The GUI already does this.</li>
</ul>
<p>Because the timeout is 12 hours and I can't find the CPU stuff in the source code on github, it's very hard to experiment / find this out for myself.</p>
]]></description><link>http://screeps.com/forum/post/13902</link><guid isPermaLink="true">http://screeps.com/forum/post/13902</guid><dc:creator><![CDATA[Jerdaz]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to CPU Assignment buggy on Sat, 29 Jun 2019 06:57:14 GMT]]></title><description><![CDATA[<p>An update:
I now manually set cpu limit to 1/1/5/13 for my shards.
After sending in new creeps from shard3 &gt; shard2 I was struck by the timeout error again after 2 ticks.</p>
<p>After a while it reset and stopped. I'm now logging the CPU and it is as follows:
immediately</p>
<pre><code>{&quot;tickLimit&quot;:500,&quot;limit&quot;:5,&quot;bucket&quot;:628.8095238095225,&quot;shardLimits&quot;:{&quot;shard0&quot;:1,&quot;shard1&quot;:1,&quot;shard2&quot;:5,&quot;shard3&quot;:13}}
</code></pre>
<p>What I'm seeing is that:</p>
<ul>
<li>My bucket didn't fill up when I had no creeps there (I wasn't there for &gt; 12 hours)</li>
<li>My bucket still has floats in it.</li>
<li>The timout error triggers if I have a bucket &lt;500 with a float value.</li>
</ul>
<p>I hope it fixes itself when I get to a full bucket again.</p>
]]></description><link>http://screeps.com/forum/post/13904</link><guid isPermaLink="true">http://screeps.com/forum/post/13904</guid><dc:creator><![CDATA[Jerdaz]]></dc:creator><pubDate>Sat, 29 Jun 2019 06:57:14 GMT</pubDate></item><item><title><![CDATA[Reply to CPU Assignment buggy on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/2135">@jerdaz</a> Thank you for your report! We'll try to reproduce the assignment issue.
Here, some answers:</p>
<ul>
<li>You supposed to use integers in setShardLimits</li>
<li>You can't pass values higher than your CPU limit. If you managed to do that, please report the bug into the official support system</li>
<li>Your max CPU limit is always 20 without a subscription or 20 + GCL*10 with a subscription. Sum of all assigned shard CPU should be the same. If it's not, please report the bug...</li>
<li>There is no safe way to get shards list currently. We'll see what we can do about it.</li>
<li>If you pass values higher or lower then your total limit, you'll get the error. If you pass a value higher than the shard limit, it will be accepted and CPU will be assigned to the shard, but excess CPU will not be used.</li>
<li>setShardLimits should check arguments and return an error if something is wrong. If it's not, please report the bug...</li>
</ul>
]]></description><link>http://screeps.com/forum/post/13907</link><guid isPermaLink="true">http://screeps.com/forum/post/13907</guid><dc:creator><![CDATA[o4kapuk]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to CPU Assignment buggy on Invalid Date]]></title><description><![CDATA[<p>Hi Nikolay,</p>
<p>Thanks for the info. I've let it rest for some time but did another attempt at dynamic cpu assignment.</p>
<p>I think the bug is triggered by assigning too much cpu to shard3 (more then 20).</p>
<p>I tried cpu assignment again last night. This time with a 60/60/60/60 division. This triggered the bug again. Because of negative cpu on shard 0/2/3 my entire economy collapsed for 12 hours.</p>
<p>This morning I added a manual code snippet that did a 200/10/10/20 assignment and it worked fine.</p>
<p>My goal is to be able to colonize to current and future shards fully autonomously, without hardcoding constants about those shards. This doesn't seem possible at the moment.</p>
<p>The reason I assign too much to shard 3 is:</p>
<ul>
<li>Currently I do not need more then 20 cpu per shard</li>
<li>I haven't found a way to find the shard limit without hardcoding constants</li>
</ul>
<p>To fix it, I will have to adjust my code to:</p>
<ul>
<li>Add a max cpu constant for shard3</li>
<li>Disable colonization to shard4 and beyond</li>
</ul>
]]></description><link>http://screeps.com/forum/post/14097</link><guid isPermaLink="true">http://screeps.com/forum/post/14097</guid><dc:creator><![CDATA[Jerdaz]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>