Giter Club home page Giter Club logo

genie-rms's Introduction

genie-rms

Age of Empires 2 Random Map Script parser for Node and the browser.

This library aims to be as compatible with AoE2 as possible. This means that its implementation imitates all the quirks of the AoE2 parser, too. It does not use an AST and does not have separate lexing and parsing steps. If you need a parser for a subset of all valid RMS code, but that returns an AST that you can manipulate, try the mangudai library.

Status - Install - Usage - Credits - License: GPL-3.0

Status

Parsing is roughly complete.

Terrain generation more or less works, as does object generation. Both are probably inaccurate compared to AoC, though. Object generation does not support civilization bonuses.

Land positioning and generation is buggy. While lands are placed, sometimes they are placed outside the map, crashing the generator. Lands of enemy players may be placed directly next to each other instead of on near-opposite sides of the map. Team-based placement is not yet implemented.

Cliff generation more or less half-works. Cliff generation does two things: change the terrain and place cliff objects. The terrain update part is implemented, but cliff objects are not. It does not correctly avoid player lands, so cliffs may be placed near or underneath town centers and the like.

Elevation generation has some implementation but whether it works is unclear.

Connections between player lands are not implemented.

UserPatch and HD Edition commands are not implemented. The goal is to first finish 1.0c semi-compatibility. Ideally, compatibility modes for UP and HD could be introduced later. As such, Zip-RMS from UserPatch 1.5 are also not implemented, although there is a utility class for reading files from them without requiring a full zip library in src/ZipRMS.js.

Install

npm install genie-rms

Usage

const { Parser, CRandom } = require('genie-rms')
const fs = require('fs')
const source = fs.readFileSync('./my-script.rms', 'utf-8')

const seed = 32767
const parser = new Parser({
  // Omit for a random seed
  random: new CRandom(seed)
})

parser.write(source)

const result = parser.end()
console.log(result)

Credits

Most of this is made possible by the reverse engineering work by Yvan-Burrie, JustTesting123 and others in genie-reverse.

License

GPL-3.0

genie-rms's People

Contributors

goto-bus-stop avatar hszemi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

genie-rms's Issues

implement Map#cleanTerrain()

This was low priority for me at first but I think it's quite important in order to make generated maps look decent. The terrains this project generates right now are very holey and jagged compared to the nice lumps generated by AoC.

TODO list

adding things i remember off the top of my head, to be extended—

1.0c compat:

  • "team together" player positioning
  • elevation generation
  • place cliff objects in cliff generation
  • place walls better. maybe not as advanced as AoC's to start, it calls into the AI code to place random map walls
  • add a way to do civ specific things, like the chinese +3 vils bonus or the meso scouts, ideally not hardcoded
  • shallows
  • options that map to the various RMS constants, to allow if LOW_RESOURCES etc

UP compat:

  • grouped_by_team
  • direct_placement
  • support for ZipRMS using genie-scx
  • maybe record effect_amount and such somewhere? so you can use genie-rms + genie-dat to determine actual stats for a game?

Write script that outputs SCX files

It would be nice to also view generated maps in-game. https://github.com/genie-js/genie-scx can not quite generate SCX files yet because awestruct doesn't support the same dynamic stuff for writing as it does for reading. Awestruct likely needs a major version bump to allow that. Then this script should be fairly simple to write (if a bit tedious).

Make the Parser.end() return value serializable

  const content = fs.readFileSync(require.resolve('./test/Arabia.rms'), 'utf8')

  const parser = new Parser({})

  parser.write(randomMapDef)
  parser.write(content)
  const parseResult = parser.end()

  console.log(parseResult)
  console.log(JSON.stringify(parseResult)) // json serialization
  expect(parseResult).toMatchSnapshot() // jest snapshot testing

I wanted to experiment with adding some automated tests, but strictObject.js Proxy seems to prevent me from doing any kind of serialization / snapshot testing:

TypeError: toJSON is undefined

       6 |       const val = target[prop]
       7 |       if (typeof prop === 'symbol' || whitelist.has(prop)) return val
    >  8 |       if (val === undefined) throw new TypeError(`${prop} is undefined`)
         |                                    ^
       9 |       return val
      10 |     }
      11 |   })

      at Object.get (src/strictObject.js:8:36)
          at JSON.stringify (<anonymous>)
      at Object.stringify (src/test/Parser.test.js:16:20)

Or alternatively with jest:

PrettyFormatPluginError: $$typeof is undefined

       6 |       const val = target[prop]
       7 |       if (typeof prop === 'symbol' || whitelist.has(prop)) return val
    >  8 |       if (val === undefined) throw new TypeError(`${prop} is undefined`)
         |                                    ^
       9 |       return val
      10 |     }
      11 |   })

      TypeError: $$typeof is undefined
      at Object.get (src/strictObject.js:8:36)
      at Object.<anonymous>.exports.test.val [as test] (node_modules/pretty-format/build/plugins/react_test_component.js:71:48)
      at findPlugin (node_modules/pretty-format/build/index.js:318:22)
      at printer (node_modules/pretty-format/build/index.js:330:18)
      at printListItems (node_modules/pretty-format/build/collections.js:135:9)
      at printComplexValue (node_modules/pretty-format/build/index.js:224:43)
      at printer (node_modules/pretty-format/build/index.js:344:10)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:170:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:270:48)
      at prettyFormat (node_modules/pretty-format/build/index.js:499:10)

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Add the `if` in comments parsing bug

this is fixed in UP 1.5 but can have a significant effect on maps before that. I think the commentDepth check in Parser.js#parseToken needs to be moved somewhere down.

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.