Navigation

    forum

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

    Posts made by PostCrafter

    • RE: Best way to perform simulations

      @devblazer screeps-server-mockup, despite its name, is essentially just a wrapper to the official screeps server. All you should really need is to update the dependencies to the most recent server version and it should be good to go, I personally haven't used it in a while though.

      AFAIK there is no builtin way to run a server one tick at a time, but it should be able to do so with a custom mod. You might want to check out the #servers channel in slack, @ags131 is usually able to help with any kind of server related questions.

      posted in General Discussion
      PostCrafter
    • RE: Best way to perform simulations

      It's not quite up to date, so you might have to do some updating yourself, but you might go ahead and try out screeps-server-mockup. It allows you to setup a private server via API including things such as terrain and RoomObjects (creeps, structures, etc) and run it one tick at a time.

      posted in General Discussion
      PostCrafter
    • RE: Help wanted: Source Keepers overhaul

      @semperrabbit It's not optimized in any ways yet (paths aren't getting saved to database yet) and there are a few other things I would change before merging it in. Due to my experience with past pull requests I don't feel like spending more time on this until I get some sort of official response whether my changes are going into the anticipated direction at all.

      posted in General Discussion
      PostCrafter
    • RE: Help wanted: Source Keepers overhaul

      I've started working on this, progress can be viewed in the pull request on the engine and driver. I plan on cleaning up some of the code and cache the paths properly before marking it as ready to merge in.

      The source keepers should already act like they would normally do, but I can't confirm as I lack source keeper harvesting code, therefore I appreciate any feedback on this.

      If anyone wants to test the changes, feel free to check out the source-keeper-to-processor branch on my screeps-server-dev repo which will help with setting up a server quickly.

      posted in General Discussion
      PostCrafter
    • RE: Help wanted: Source Keepers overhaul

      @artch Mind sharing what exactly you think the issue with moving the Pathfinding to the processor is? I'm still fiddling with the server code to understand how exactly NPCs are integrated into the flow of the game, but calling the pathfinder differently seems like a fairly small issue to me, so maybe I'm missing something here.

      Also what exactly is the overhead here? Is it the creation of the vm for each SourceKeeper or the setup of the API wrapper usercode has? Is it an option to just remove the vm layer for NPCs?

      posted in General Discussion
      PostCrafter
    • RE: Help wanted: Source Keepers overhaul

      How about moving the keeper lairs right on top of the sources? This will remove the need to find a path at all and also won't require move logic in the source keeper code. Additionally this doesn't cause any issues for cases where the source is located on a single wall tile - I don't have an example for such a case in a source keeper room, but I certainly saw those in normal rooms.

      I would like to pick up this challenge, but unfortunately I don't have a lot of time this weekend.

      posted in General Discussion
      PostCrafter
    • RE: How is constant CPU cost applied?

      Sounds about right, except that each type of intent will only cost once for each creep. If your creep moves once and changes it mind in the same tick and moves somewhere else the constant cost is only applied for the first move call. In your example above this means that the constant cost will only be applied to creep.move(RIGHT).

      Also keep in mind that multiple creeps trying to move to the same tile, interacting with the same object or conflicting actions will not conflict with each other inside your code, they will both return OK and the constant cost will be applied multiple times, even if only one of those actions is actually executed.

      posted in Help
      PostCrafter
    • RE: PTR Changelog 2018-01-18: isolated VM

      Will we get isolated-vm support for private servers as well?

      I had the idea of giving bot creators a tool to create a binary of their bot's isolate snapshot that can be shared without publishing the source code. Currently bot publisher are trying to not publish a lot of offensive code, because it's going to be used on the official server, which in turn is hindering the experience of newer players. If this idea were to be implemented they could hold back parts of their code just like they do now, but publish the entire bot including military.

      Actually implementing the upload and use of a binary snapshot can be taken care of by a mod, I'm just interested in whether we will get full isolated-vm support.

      posted in News & Announcements
      PostCrafter
    • RE: Creep death: more than just a delete

      @hiryus To my understand only the tombstone decays and drops the resources on the ground afterwards, then they'll decay normally.

      posted in Feature Requests
      PostCrafter
    • RE: Creep death: more than just a delete

      I can start working on it this afternoon.

      Still got a few question that I need some input on:

      Should the tombstone be created for creeps that die of old age as well? I think it should and contain the resources the creep was carrying.

      Should creeps that suicide() create a tomstone? Maybe add this as an optional parameter (true/false)?

      Should I add a FIND_TOMBSTONES contant as well? Are there any other ways of how to access tombstones?

      Should this replace the current dropToContainer mechanic NPCs have? I think it should but it might break some peoples NPC raids or make them a lot less profitable until adjusting their code to tombstones.

      Should room owners be able to remove()/destroy() tombstones before their ticksToDecay reached 0?

      @artch said in Creep death: more than just a delete:

      • One tombstone per creep, no stacking.

      What do you mean with this? If multiple creeps die at the same RoomPosition, should there be multiple tombstones, one for each creep?

      @artch said in Creep death: more than just a delete:

      • No active actions.

      What is this supposed to mean? No creep actions against tombstones? I previously thought about allowing Creep#withdraw (see NPC containers above), but this got me thinking. If withdraw isn't allowed it just delays resource decay, does it?

      posted in Feature Requests
      PostCrafter
    • RE: PTR Changelog 2018-01-18: isolated VM

      Great news, nice to see this implemented.

      It seems like you currently need to save your code after switching to isolated mode, in order to force a code reload to the new virtual machine.

      I already found a first bug, Game.shard seems to be undefined.

      posted in News & Announcements
      PostCrafter
    • RE: StructureLink.transferEnergy(...) shows deprecated warning message

      The transferEnergy method is only deprecated when targetting a creep, in that case you should use Creep.withdraw instead.

      In your example this means that you have to replace l.transferEnergy(receiver) with receiver.withdraw(l). Keep in mind that it's still possible to use link.transferEnergy(anotherLink) though.

      posted in Technical Issues and Bugs
      PostCrafter
    • RE: Discussion: Contract system

      From discussions in slack I came to the conclusion that contracts are most useful to check for conditions instead of executing code that queues intents.

      This way contracts require an implementation from the person fulfilling the contract, which not only allows the contractor to solve it in their own way and optimize it for stuff like CPU, they can be seen as some kind of quest or mission.

      I completely understand the need for manual review, but even though I'm repeating myself, limiting it to manual interaction only is a mistake in my opinion.

      When going for parameterized contracts you could easily create a checksum of the module and require to review the module at least once, after that your code is free to accept any contracts with the same checksum. Additionally your code can verify whether it actually wants to accept a contract based on those parameters.

      In the long term it would be nice being able to accept a contract without manual review, either by a well established list of tested contracts or by adding the exact same contract module to your own code.

      Example contract

      Following is a scenario of how I expect the process to look like when working with contracts.

      Player A: contractee Player B: contractor

      1. The contractee create a contract module, in this case it's a module that requires a nuke to be sent by the contractor to a specific position:
      const { x, y, roomName } = Game.contract.parameters;
      const pos = new RoomPosition(x, y, room);
      
      const hasVision = roomName => roomName in Game.rooms;
      const isMyRoom = roomName => _.get(Game.rooms, [roomName, 'controller', 'my'], false);
      
      module.exports.loop = function() {
      	if (!hasVision(roomName)) {
      		return false;
      	}
      	const nukes = pos.lookFor(LOOK_NUKE);
      	if (!nukes) {
      		return false;
      	}
      	return nukes.some(({ launchRoomName }) => isMyRoom(launchRoomName));
      }
      
      
      1. The contractee creates a contract based on this module:
      function requestNuke(pos, reward) {
      	const { x, y, roomName } = pos;
      	return Game.contracts.create('contract-nuke.js', reward, { x, y, roomName });
      }
      
      requestNuke(new RoomPosition(25, 25, 'N0E0'), 100000);
      
      1. The potential contractor ( Player B ) views all of the available contracts in the UI, reviews the contract's code and approves it, the checksum is then added to their list of allowed contracts.

      2. Player B's code views a list of available contracts and chooses appropriately, afterwards every accepted contract is getting executed (contracts won't be accepted until the next tick). If the contract hasn't been reviewed yet an appropriate error code will get returned.

      const CHECKSUM = '1b1774169003e863931fa3c5ddbfa7f1';
      const MINIMUM_REWARD = 80000;
      
      const myRoom = room => _.get(room, ['controller', 'my'], false);
      const getNuker = room => room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_NUKER }});
      const hasNuker = room => !!getNuker(room);
      const inNukeRange = (room, target) => Game.map.getRoomLinearDistance(room.name, target) <= NUKE_RANGE;
      
      function getFirstNukerInRange(targetRoom) {
      	return _.first(_.values(Game.rooms), room => myRoom(room) && hasNuker(room) && inNukeRange(room, targetRoom));
      }
      
      const isNukeContract = contract => contract.checksum === CHECKSUM;
      const isNukeContractValuable = contract => contract.reward >= MINIMUM_REWARD;
      const isNukeContractInRange = contract => !!getFirstNukerInRange(contract.parameters.roomName);
      
      function acceptNukeContracts(contract) {
      	if (!isNukeContract(contract)) {
      		return;
      	}
      	if (!isNukeContractValuable(contract)) {
      		return;
      	}
      	if (!isNukeContractInRange(contract)) {
      		return;
      	}
      	Game.contracts.accept(contract.id);
      }
      
      function executeNukeContracts(contract) {
      	if (!isNukeContract(contract)) {
      		return;
      	}
      	const { x, y, roomName } = contract.parameters;
      	const nuker = getFirstNukerInRange(roomName);
      	nuker.launchNuke(new RoomPosition(x, y, roomName));
      }
      
      module.exports.loop = function loop() {
      	_.forEach(Game.contracts.available, acceptNukeContracts);
      	
      	_.forEach(Game.contracts.accepted, executeNukeContracts);
      }
      

      This is a fairly simple implementation (but devastating none the less!) but I hope this example shows how automation would be able to handle contracts.

      Contracts API Draft

      The following is a little draft of how the contract API could look like, it's probably a good idea to replace the properties under Game.contracts with a function similar to Game.market.getAllOrders.

      • Contract object
      property type description
      id string A unique identifier, can be used to interact with a contract
      checksum string Checksum of the contained code, each checksum will have to be allowed manually once by reviewing the associated code
      contractee string The player of which the contract was created
      contractor optional string The player that accepted the contract, might not be set yet
      reward number The amount of credits that the contractee pays the contractor once the contract has been fulfilled
      parameters otpional object Any valid json object that can be used to modify the modules behaviour
      • Game.constract: Is only available from within a contract, contains the currently executed Contract object.

      • Game.contracts.available: Array of available Contract objects.

      • Game.contracts.accepted: Array of Contract objects that you accepted.

      • Game.contracts.created: Array of Contract objects that you created but are not accepted yet.

      • Game.contracts.running: Array of Contract objects that you created any were accepted by someone else.

      • Game.contracts.create(moduleName, reward, [parameters]): Create a new contract

      parameter type description
      moduleName string Name of the module you want to create as a contract
      reward number The amount of credits that the contractee pays the contractor once the contract has been fulfilled
      parameters otpional object Any valid json object that can be used to modify the modules behaviour
      • Game.contracts.accept(id): Accept an available contract
      parameter type description
      id string A unique identifier of the contract you want to accept
      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      @artch said in Discussion: Contract system:

      @postcrafter We won't have API for automatic contracts acceptance/creation, so environment variables don't make a lot of difference.

      I seem to have missed that part about no automatic creation and acceptance of contracts earlier. Unfortunately this makes it a non-feature for me, I think you do at least need to be able to create contracts automatically, accepting them is a bit riskier for obvious reasons, but it's a problem that's absolutely solveable.

      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      @artch said in Discussion: Contract system:

      @postcrafter

      Taking your example from above, if someone wants to setup two contracts for different sourceIds, he will have to copy the module's code and change the constant's value for each of them. It doesn't make any sense to copy an entire file just to change a single value. This would not only be bad coding practice (DRY), it would be impossible or at least impractical to automate.

      Oh, I see. Well, it's just how the system works basically - every contract consists of some code. You can use an external template (e.g. from GitHub) to create that code, but essentialy it will be a separate script in the database. In the same way as how we have a lot of players running identical open source code base - it's also suboptimal, but it is how it works.

      When two independent players want to use the same contract template that's an entirely different story and saving the contracts separately in the database once they've been created is absolutely fine.

      Would you be open to accept pull requests to add some sort of parameter/environment variable/contract memory when the feature is actually added to the game?

      This would also make automatic accepting of contracts a lot easier, add a checksum of the module to the contract and let your code decide whether it wants to accept it or not based on the parameters. This will only work for "well written" contract code, but that's something we as the community are responsible for.

      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      @artch said in Discussion: Contract system:

      Even with this functionality, which is awesome by the way, this won't solve the problem of reusing the same code for multiple contracts.

      What is the problem here exactly?

      Taking your example from above, if someone wants to setup two contracts for different sourceIds, he will have to copy the module's code and change the constant's value for each of them. It doesn't make any sense to copy an entire file just to change a single value. This would not only be bad coding practice (DRY), it would be impossible or at least impractical to automate.

      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      @artch So a contract can consist of multiple modules which will simply run in the context of another player? Even with this functionality, which is awesome by the way, this won't solve the problem of reusing the same code for multiple contracts.

      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      @artch To my understanding a contract is a fully isolated module without the ability to require other modules. In order to setup a new contract I would have to create a new module every time (which is impossible for my code to do) or fall back to string concatenation/manipulation - depending on the implementation -, which means the potential loss of IDE support.

      posted in General Discussion
      PostCrafter
    • RE: Discussion: Contract system

      Will we be able to provide parameters to a contract, sort of like environment variables? This can be used to use the same code but targeted at different rooms, ticks or players. Otherwise we would have to modify the code and/or use string modification for each contract which seems kind of bad.

      In the example above, both sourceId and dropPosition would be provided with these parameters instead of putting them directly into the code.

      posted in General Discussion
      PostCrafter
    • RE: Debugging steam private server

      I've never tried it myself, but you might want to install screepsmod-user-script-debug.

      posted in Feature Requests
      PostCrafter