Giter Site home page Giter Site logo

terranova's Introduction

TerraNova

World generator in Typescript.

Live Demo

http://terranova.kaelan.org/ (requires Chrome 70+, or Firefox with SharedArrayBuffers enabled)

Build status: CircleCI

Install

  • npm run dev: starts webpack dev server
  • npm run build: builds for production

Releasing

Currently, all commits to master will automatically release to production. Versions are used to track incompatible changes and warn the user when their saved games or worlds are obsolete. These warnings are based on the package.json version.

When to release

  • When the world generator is changed
  • When the game code is changed

How to release

We use release-it to handle releases. This is configured to update the npm package version (we don't publish to npm) and push git tags, which are available on Github.

e.g.: npx release-it minor

terranova's People

Contributors

eranimo avatar smoss avatar thallada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

maksymsharindev

terranova's Issues

Migration

Migration occurs when neighboring cells have more unused carrying capacity than the cell a pop occupies, the rate should be related to the difference

Housing

  • Pops require housing
  • Buildings provide housing
  • If there is a deficit of housing, more will be built.

Sending entity updates to the render thread

Background

  • passing data between the two threads:
    • game thread: game.worker.ts - handles simulation, game loop
    • render thread: (i.e. main thread) GameManager.ts - renders React UI, map renderer
  • data is sent to the render thread using:
    • "shared memory" - SharedArrayBuffers (population map mode uses this)
      • this is hugely performant for very fast updates and anything that can be expressed in 2D
    • "data passing" - observables, passed via postMessage-style events I called "channels". Render thread only receives updates to observables they subscribe to, not all of them. Components that listen to these should unsubscribe from the channel after they unmount.
      • this is less memory efficient but it's far easier to use
  • ObservableDict allows you to observe both a specific key or the entire dict itself.

Problem

  • This above is kinda clunky and primitive, since what we really want is an "entity system" that can:
    • have references to each other (game cell -> pop for instance)
    • easily send updates to the render thread
    • work with the game loop
    • use as little memory as possible

Proposal

  • Entities have an ID and a type.
  • Entities have an ObservableDict called data whose values can be anything JSON serializable, or special types which we define, one of which is a Reference object to another Entity (more will probably be added later)

Open questions

  • Should entities have references, or should a "manager" class hold the references?
  • Is the above proposal too memory inefficient?
  • should attributes be defined as observables that belong to an entity, which is simply an ID number in a lookup table? (this is called an entity-attribute system). This might be more flexible, and better allow for references.
  • How should the entity updates be sent?

Related

Carrying Capacity

Every cell has a carrying capacity, dictated by stuff(climate, biome), each food production method has a certain multiplier on that carrying capacity(tbd)
The advantage of foraging is that it has 0 infrastructure requirements, other methods require more infrastructure but can produce higher multipliers of carrying capacity

Food

  • Food is a resource.
  • Pops use a set amount of food per day. This amount is dependent on the pop type.
  • Pops produce a set amount of food per day. This amount is dependent on the pop type, the biome of the cell, the terrain of the cell.

Pops

Population units can exist on each cell. Each cell has a certain amount of each pop type.

Pop types and base production:

  • Foragers
    • produces 1 unit of food
    • produces 1 unit of wood
  • Farmers
    • produces 2 units of food
  • Laborers
    • produces 2 units of wood
  • Nobles
    • can't produce jack shit

Farmers need farm buildings.

Buildings

Each cell has a certain amount of each building type. Buildings have different effects.

Building types:

  • House

Resources

Each cell has a certain amount of each resource type.

Resource types:

  • Food
  • Wood
  • Stone

Farmers

Assuming there is adequate food and housing farmers will construct farms which allow them to produce food, otherwise they will become foragers, foragers should construct a small amount of farms that will serve as the initial farms for farmers(this can be justified either as experimental agriculture or the slow process of land clearing and environment modification that is enacted by foragers)

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.