Skip to content

Instantly share code, notes, and snippets.

@Dexaran
Last active October 6, 2019 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dexaran/db82e6bd4dda05619b4c7f5f478ca5aa to your computer and use it in GitHub Desktop.
Save Dexaran/db82e6bd4dda05619b4c7f5f478ca5aa to your computer and use it in GitHub Desktop.

GalaxEOS smart-contract game

Intro

The game is intended to be developed on top of EOSIO blockchain. The core components of the game will be written in C++ (smart-contracts) and the UI will represent a JS website that will display the state of the game which is obtained from smart-contracts.

Game mechanics

The game represents an open world strategy. Action takes place in space. Players control planets, gather resources, build fleets and fight with each other.

All actions take place and are processed in the EOS blockchain. All game state is fully recorded and stored on the blockchain.

A player should interact with the smart contract during the game. So, the player needs to have a signed up EOSIO account.

The game process requires that information (game state) be read from the smart-contract, as well as that user actions are converted into transactions and broadcasted to EOS network, thus sent to the smart-contract.

All the actions that a player can perform are invocations of various functions of the smart-contract which are performed by signing and sending transactions. This includes:

  • Spawning the player in the game

  • Placing "tasks" in planetary task queue (tasks are resolved automatically then)

  • Giving "orders" to the planetary fleet (these are resolved automaticaly as well)

Every type of actions in the game requires (1) a certain task to be placed and (2) a certain amount of time to complete.

So, what a player can do in the game is limited to

  • placing tasks
  • waiting for the completion time and observing the results

Resources

There are three resource types in the game: metal, crystals, gas.

Metal and crystals are used for building ships and structures. Gas is used as a fuel for fleets.

Map

The game map is an arbitrary size 2D grid. Each cell represents a sector. Each sector may contain a planet or not. Each planet may be colonized by players.

Planets

Planet represents the main game object. A planet may be controlled by a player or it may be empty (awaiting for colonization). The more planets a player has, the more time it will take for him to colonize one more.

Planet has the following characteristics:

  • Size (determines how much structures a planet can support): 20 to 50

  • Temperature (determines resource mining coefficients): 0 to 200

  • Resource storage capacity for each resource: defaults to 1500

The planet serves as the main source of resources in the game. To extract and store resources, the player must build structures on the planet. Fleets of players are also being built on planets.

A fleet may be deployed on the planet.

Building structures

Each structure has building cost, building time and level stats.

  • Metal/ Crystal/ Gas mine: produces X * level metal/ crystal/ gas per second

  • Metal/ Crystal/ Gas storage: Increases metal/ crystal/ gas storage capacity of a planet by X * level units

  • Shield: increases durability of the defensive ships by X * level %

  • Command center: allows to send fleets outside of this planet, has no level mechanic

  • Assembly: allows to build fleets, has no level mechanic

Each building consumes 1 point of Planetary size per level. Once the planetary limit is reached, building costs are doubled for each point of limit exceed. It is possible to "upgrade" a structure by paying its building cost thus increasing its level. Upgrade requires building time to complete.

Ships

There are 3 ship types in a game currently (first release beta):

Battleship

  • Stats: 100 attack/ 150 durability/ 20 cargo

Cargo ship

  • Stats: 10 attack/ 400 durability/ 500 cargo

Colonizer

  • Stats: 10 attack/ 700 durability/ 500 cargo

  • Can colonize a new planet. Will be destroyed upon colonization.

Fleets

When ships are built on a planet, they are automatically added to the fleet of this planet. A player can send some ships outside of a planet if the planet has a "Command center" building. A player chooses how much ships to send and pays the gas cost for the flight - then the ships leave the planet and proceed to their tasks. The amount of time needed for a fleet to reach the destination is determined by the distance between the home planet cell of the fleet and the destination cell.

There are the following task types for the fleets:

  • Attack (attacks an enemy planet)

  • Transport (moves resources to the destination allied planet then returns the fleet back to the home planet)

  • Move (moves the fleet to the destination allied planet and adds it to the destination planet's fleet)

  • Colonize (only for colonizer ships; colonized a planet for the sender player, destroys the colonizer ship)

A player can send resources alongside the fleet to transport. The max amount of resources for transportation is determined by the cargo capacity of the fleet.

Combat

A player can attack another player by sending a fleet with "Attack" order. Damage stats of each fleet (defenders and attackers) are calculated and the damage is simultaneously applied to both fleets. Battleships take damage first. If the amount of damage exceeds the amount of ships durability then the rest of damage is applied to Cargo ships and then to the Colonizers.

If the attackers destroy defending fleets completely then they proceed to gathering resources from planet's storages and return back to their home planet.

Start

Each player starts with 1 planet. There are Metal mine(lvl 1), Crystal mine(lvl 1) structures built at the starting planet.

@Dexaran
Copy link
Author

Dexaran commented Sep 6, 2019

@Sparke2

It will take you up to 200x more CPU to maintain this update rates, so it will cost you ~$1200 at the current price rate (which is very likely to change). I'm OK if you decide to pay for it but it may be worth to sacrifice some EOS for RAM and optimize the performance for future use.

Compiled it with -Ofast for testing reasons and it gave 2x performance improvement.

As for CPU and RAM payments - CPU price remains the same. It means that I can invest 1000 EOS in CPU and it will be the same 1000 EOS when I will unstake.

RAM tends to cheapen because the whole EOS ecosystem is trying to make smart-contracts cheaper. Thats why I prefer to sacrifice performance.

@Dexaran
Copy link
Author

Dexaran commented Sep 6, 2019

@Sparke2 unfortunately universe.x name is already registered. Any new name suggestions?

@Sparke2
Copy link

Sparke2 commented Sep 6, 2019

galaxeos.x ? what do you think?

@Sparke2
Copy link

Sparke2 commented Sep 6, 2019

btw top planets were updated half an hour ago. its too long. even for an empty galaxy. lets increase update rate a bit. Your CPU replenishes as i can see.

@Sparke2
Copy link

Sparke2 commented Sep 6, 2019

your 0.0002 EOS will be unstaked in 44 min -_-

@Dexaran
Copy link
Author

Dexaran commented Oct 4, 2019

GalaxEOS UI definition

GalaxEOS UI serves to represent data stored in the game smart-contract and provide a user with the ability to interact with it.

UI must include:

  1. MAP: a Text representation of game state and a 2D grid representation

  2. Detailed planet info layer

  3. Action modeals: currently "send fleet" action only

Map representation: text representation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment