Skip to content

Instantly share code, notes, and snippets.

@RGBKnights
Last active September 28, 2023 21:25
Show Gist options
  • Save RGBKnights/ee96cedfb82a65828108b9ca83961be8 to your computer and use it in GitHub Desktop.
Save RGBKnights/ee96cedfb82a65828108b9ca83961be8 to your computer and use it in GitHub Desktop.
Screeps - S&S

Spawn And Swamps:

The map is 100x100 tiles with random terain mostly covered by swamp. You have a Spwan structure that allows you to create Creeps by spending energy. Energy storage is available in Containers nearby.

Additional contested enegy storage is available in Containers taht constantly appear in different places and disappear shortly. These contains first start appearing in the jungle at 50 ticks, have decay of 100 ticks, and new ones will spwan every 50 ticks.

The time limit is 2000 ticks. When the time limit is expired, the game finihes in a draw.

Simplified Example Map (each squard is ~14 tiles): Note the the layout of the map with each swpan on the left and right. The starting side is randomized. There are a number of regions:

  1. Base is considered the side with player's spawn. [S]
  2. Lanes for top and bottom to access the spwan because of the impenetrable walls [X]
  3. Jungle the middle of map is often refered to as the jungle and often as mulitple ways to cross bettwen lanes.
[.][.][.][.][.][.][.]
[.][X][.][.][.][X][.]
[.][X][.][.][.][X][.]
[S][X][.][.][.][X][S]
[.][X][.][.][.][X][.]
[.][X][.][.][.][X][.]
[.][.][.][.][.][.][.]

Objective: Destory the opponent's Spawn.

Sample Code

import {getObjectsByPrototype} from 'game/utils';
import {ATTACK, MOVE} from 'game/constants';
import {StructureSpawn} from 'game/prototypes';

let attacker;

export function loop() {
    if(!attacker) {
        var mySpawn = getObjectsByPrototype(StructureSpawn).find(i => i.my);
        attacker = mySpawn.spawnCreep([MOVE, ATTACK]).object;
    }
    else {
        const enemySpawn = getObjectsByPrototype(StructureSpawn).find(i => !i.my);
        attacker.moveTo(enemySpawn);
        attacker.attack(enemySpawn);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment