Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. edggy
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    edggy

    @edggy

    5
    Posts
    1269
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    edggy Follow

    Posts made by edggy

    • WebAssembly Setup Issue (LinkError)

      I compiled the code from https://docs.screeps.com/modules.html#Build-wasm-file and tried to run it in the simulation.

      Here is my "main" (Copy and pasted from the tutorial):

      module.exports.loop = function () {
      
          // This will return an ArrayBuffer with `addTwo.wasm` binary contents
          const bytecode = require('addTwo');
      
          const wasmModule = new WebAssembly.Module(bytecode);
      
          const imports = {};
      
          // Some predefined environment for Emscripten. See here:
          // https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
          imports.env = {
              memoryBase: 0,
              tableBase: 0,
              memory: new WebAssembly.Memory({ initial: 256 }),
              table: new WebAssembly.Table({ initial: 0, element: 'anyfunc' })    
          };
      
          const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
      
          console.log(wasmInstance.exports._addTwo(2,3));
      }
      

      My wasm file is uploaded as the module "addTwo", here is the addTwo.c file i compiled:

      int addTwo(int a, int b) {
          return a + b;
      }
      

      The compile command was:

      emcc -s WASM=1 -s SIDE_MODULE=1 -O3 addTwo.c -o addTwo.wasm
      

      When I run the code the console outputs:

      LinkError: WebAssembly Instantiation: table import 0 is smaller than initial 2, got 0
          at Object.module.exports.loop:20:26
          at __mainLoop:1:15733
          at eval:2:4
          at Object.r.run:2:144134
      

      Does anyone know how to fix this issue?

      posted in Help
      edggy
    • RE: Committing Memory using direct API access

      The use case for this is for me to play with rawmemory.  I was trying to create my own data structure for the memory to optimize CPU usage instead of using a JSON object which takes CPU time to parse even if you don't access all of it's contents.

      When I was playing with this idea in a sandbox my memory kept on getting corrupted because the JSON parser failed and through and error before my code got executed and never ran my code.  The only way I was able to fix this problem was to reset my sandbox.

      I am scared that if I used this on the main server my data will become corrupted permanently and I will be unable to play at all.  In this case even if the sysadmin "reset" my memory I lose everything I have worked on.

      One simple fix to prevent "Cheating" would be to limit Download/Upload of memory to once per hour or day.

       

      Technically the rules don't ban external resources...

      posted in Feature Requests
      edggy
    • RoomPosition.findClosestByPath() error

      I am getting an error in my function only since an update:

      The function is:
      Creep.prototype.goNear = function(dist, opts) {
      dist =_.isNumber(dist) ? dist : 0;
      targs = this.target.pos.getNear(dist);
      this.log(targs + ' ' + opts)
      var goal = this.pos.findClosestByPath(targs);
      //this.log(goal)
      return this.moveTo(goal, opts)
      }

      The arguments given are:
      dist = [room E11N4 pos 35,-1],[room E11N4 pos 35,0],[room E11N4 pos 35,1],[room E11N4 pos 35,2],[room E11N4 pos 35,3],[room E11N4 pos 35,4],[room E11N4 pos 35,5],[room E11N4 pos 36,-1],[room E11N4 pos 36,0],[room E11N4 pos 36,1],[room E11N4 pos 36,2],[room E11N4 pos 36,3],[room E11N4 pos 36,4],[room E11N4 pos 36,5],[room E11N4 pos 37,-1],[room E11N4 pos 37,0],[room E11N4 pos 37,1],[room E11N4 pos 37,2],[room E11N4 pos 37,3],[room E11N4 pos 37,4],[room E11N4 pos 37,5],[room E11N4 pos 38,-1],[room E11N4 pos 38,0],[room E11N4 pos 38,1],[room E11N4 pos 38,2],[room E11N4 pos 38,3],[room E11N4 pos 38,4],[room E11N4 pos 38,5],[room E11N4 pos 39,-1],[room E11N4 pos 39,0],[room E11N4 pos 39,1],[room E11N4 pos 39,2],[room E11N4 pos 39,3],[room E11N4 pos 39,4],[room E11N4 pos 39,5],[room E11N4 pos 40,-1],[room E11N4 pos 40,0],[room E11N4 pos 40,1],[room E11N4 pos 40,2],[room E11N4 pos 40,3],[room E11N4 pos 40,4],[room E11N4 pos 40,5],[room E11N4 pos 41,-1],[room E11N4 pos 41,0],[room E11N4 pos 41,1],[room E11N4 pos 41,2],[room E11N4 pos 41,3],[room E11N4 pos 41,4],[room E11N4 pos 41,5]
      opts = undefined

      Here is the error message:
      [3:29:24 PM]TypeError: Cannot set property '35' of undefined
      at arrayEach (/opt/engine/node_modules/lodash/index.js:1289:13)
      at Function.<anonymous> (/opt/engine/node_modules/lodash/index.js:3345:13)
      at Creep.goNear (creep:626:25)
      at Creep.tick (creep:298:15)

      Line 'at Creep.goNear (creep:626:25)' is 'var goal = this.pos.findClosestByPath(targs);' which is an API function

      If you can fix this that would be great

      Thanks

      posted in Technical Issues and Bugs
      edggy
    • Committing Memory using direct API access

      I made a Python script that periodically grabs the code on the servers and downloads it locally using direct API access

      Since I've seen several instances of users' memory being wiped It would be nice to download and upload our Memory in a similar fashon

      It seems simple enough and would help many of us sleep at night knowing that our Memory is safe too

       

      Thanks

       

      posted in Feature Requests
      edggy
    • RawMemory bug

      I am playing around with using different serialization algorithms besides JSON.parse for my memory. I ran into a problem because (at least in the simulation) when I set RawMemory to something not parseable by JSON.parse I get the error:

      Error: Could not parse raw memory
      at Object.defineProperty.get [as Memory]:6:4524
      at main:1:135
      at eval:68:4
      at Object.i:6:2741
      at Object.c.runCode:6:10639

      And none of my code is executed and I am forced to restart the simulation

      Here is the simplest example where the error occurs:

      console.log("Starting Code");
      RawMemory.set(" ");

      Can somebody please fix this so I can implement my own non-JSON based parsing?

      Has anyone else successfully utilized RawMemory? If so how did you use it?

      Thank You

      posted in Technical Issues and Bugs
      edggy