Giter Site home page Giter Site logo

invisioblack / screeps-packrat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bencbartlett/screeps-packrat

0.0 0.0 0.0 14 KB

Lightning-fast and memory-efficient serialization of Screeps IDs, Coords, and RoomPositions

License: The Unlicense

JavaScript 51.39% TypeScript 48.61%

screeps-packrat's Introduction

screeps-packrat

Lightning-fast and memory-efficient serialization of Screeps IDs, Coords, and RoomPositions

Code written by Muon as part of Overmind Screeps AI.

Feel free to adapt as desired.

To use: import desired functions from module, or import entire module on main and use functions from global.

To benchmark: PackratTests.run()

Available methods

+--------------------------+------------------------------------------------+-----------------+--------------------+
|         function         |                  description                   | execution time* | memory reduction** |
+--------------------------+------------------------------------------------+-----------------+--------------------+
| packId                   | packs a game object id into 6 chars            | 500ns           | -75%               |
| unpackId                 | unpacks 6 chars into original format           | 1.3us           |                    |
| packIdList               | packs a list of ids into a single string       | 500ns/id        | -81%               |
| unpackIdList             | unpacks a string into a list of ids            | 1.2us/id        |                    |
| packPos                  | packs a room position into 2 chars             | 150ns           | -90%               |
| unpackPos                | unpacks 2 chars into a room position           | 600ns           |                    |
| packPosList              | packs a list of room positions into a string   | 150ns/pos       | -95%               |
| unpackPosList            | unpacks a string into a list of room positions | 1.5us/pos       |                    |
| packCoord                | packs a coord (e.g. {x:25,y:25}) as a string   | 150ns           | -80%               |
| unpackCoord              | unpacks a string into a coord                  | 60-150ns        |                    |
| packCoordList            | packs a list of coords as a string             | 120ns/coord     | -94%               |
| unpackCoordList          | unpacks a string into a list of coords         | 100ns/coord     |                    |
| unpackCoordAsPos         | unpacks string + room name into a pos          | 500ns           |                    |
| unpackCoordListAsPosList | unpacks string + room name into a list of pos  | 500ns/coord     |                    |
+--------------------------+------------------------------------------------+-----------------+--------------------+

*Execution time measured on shard2 public servers and may vary on different machines or shards.

**Memory reduction for list functions is the asymptotic limit of lists containing many entries. Lower reductions can be expected for smaller lists.

screeps-packrat's People

Contributors

bencbartlett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.