Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NobodysNightmare
Last active May 11, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NobodysNightmare/0700104cd98346f40d6a83b9ae5f39aa to your computer and use it in GitHub Desktop.
Save NobodysNightmare/0700104cd98346f40d6a83b9ae5f39aa to your computer and use it in GitHub Desktop.
Equal entitlement powerbank sharing (EEPS)

Equal entitlement powerbank sharing (EEPS)

Status of this specification: DRAFT

Abstract

The equal entitlement powerbank sharing (EEPS) is an algorithm that allows multiple players to share the power of a single room in the online game Screeps.

It has the following properties:

  • each player is entitled to the same amount of power eventually
  • sharing is performed on a per room basis
  • power distribution can be tracked by each player individually
  • permanent observation of the target room is not necessary, but each powerbank has to be seen at least once
  • sharing is independent of players actually taking the power they are entitled to

Algorithm

Each player is assigned a power tally, which is an integer tracking the amount of power this player has been entitled to.

When detecting a powerbank, a decision on the entitled player is made as follows:

  1. if the same powerbank has already been scanned before, return the result of the previous decision on that powerbank
  2. find the player with the lowest power tally so far
    • if two players have the same tally, choose the player with the lexigraphically first name
  3. increase the tally of that player by the amount of power stored in the powerbank
  4. the player is entitled to the contents of the powerbank

The entitled player SHOULD be taking necessary steps to take posession of the power of that powerbank.

All other players of the party MUST NOT obtain any of the power of that powerbank and they MUST NOT interfere with the entitled player harvesting it.

Every player SHOULD log at least the following details for each encountered powerbank into permanent storage:

  • game time of first seeing the powerbank
  • amount of power in the powerbank
  • player entitled to the power

Keeping such a log is encouraged to be able to resolve conflicts in a diplomatic way, in case players can't agree on the entitlement for a given powerbank (this can happen if a player failed to notice the presence of a powerbank).

For the same reason players are also encouraged to implement alerting/logging for party members harvesting power without entitlement.

Starting a new party

When starting a new party, all members will start with a power tally of zero.

Adding players to a party

When adding a player to an existing party, the player with get the same tally as the player with the highest tally so far. This ensures that any existing imbalance has been settled, before the new player is entitled for the first time.

Removing players from a party

Upon removing players from a party they can't be entitled for further powerbanks. If players are removed while being entitled to an active powerbank, the powerbank MUST NOT be entitled to a different player.

Limitations

The following topics are not covered by this specification and implementing them is up the party members. It is encouraged to define further specifications compatible with this one, to deal with these aspects.

Synchronizing state

In different situations all players must agree on the common state at a given point in time:

  • when setting up a new party (players have to agree which powerbank is the first to be distributed by the algorithm)
  • when adding or removing players from the party
  • after a desynchronization (e.g. due to coding errors or a player not seeing a powerbank)

It is generally possible to perform such synchronizations maually (e.g. agree on all existing tallies while the room is devoid of a powerbank), but automatic synchronizations might reduce error potential and allow to start a mining party without human intervention.

Unlawful players

The algorithm generally assumes players within the party to play by the rules. If any player violates the rules, it is up to the party members to decide how to proceed.

Guarding

Protecting the mining operation from players outside the party is outside the scope of this specification. Probable general directions:

  • the entitled player is responsible for guarding a powerbank
  • the whole party is responsible for guarding a powerbank

Fair room distribution

It is assumed that players agree on whether they want to begin a common mining operation in any given room. For any group of players it might make sense to employ different rules on how to decide which rooms are shared among which players and if at all...

The following is an example on how the algorithm may play out. It serves illustrative purposes to understand the algorithm.

Alice an Bob decide to start a common mining operation in a room. The initial overview of power tallies:

Player Power Tally
Alice 0
Bob 0

A new powerbank with 5000 power spawns. Alice is entitled to harvest it, since she and Bob have an equal tally, but Alice's player name is lexigraphically first.

The updated tally:

Player Power Tally
Alice 5000
Bob 0

A new powerbank with 2000 power spawns. Bob is entitled, since he has the lower power tally.

Player Power Tally
Alice 5000
Bob 2000

Caroline joins the party, since she has not taken part so far, she will get the most unfavorable tally (Alice's):

Player Power Tally
Alice 5000
Bob 2000
Caroline 5000

A new powerbank with 4000 power spawns. Bob is entitled, since he still has the lowest tally.

Player Power Tally
Alice 5000
Bob 6000
Caroline 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment