Game engine Questions

I have a couple of questions.

Since each player has 3 worms, on each turn do all 3 of them move, or just one? If all 3 how do I indicate which one each move is for? and if only one how do I know which one is moving?

Can someone please explain how the maps are generated in English? The code goes over my head at the moment.

Regarding the map generation.

The map is generated using Simplex noise. It is pretty much perlin noise generation. It generates smooth gradients between numbers, which often are represented in 2D for height-maps etc.

I have a blog post from many years back you can refer to. It does require flash to see the demos.

http://www.avanderw.co.za/beginnings-of-coherent-noise/
http://www.avanderw.co.za/as3-perlin-noise-experiment/

Some other uses of the noise
http://www.avanderw.co.za/animated-flag/
http://www.avanderw.co.za/static-distortion-effect/
http://www.avanderw.co.za/water-reflection-displacement-effect/

Then depending on the number in each cell (populated by the noise generation), it will cap it to be either wall or air. For instance a value between [0;1] you might have values < 0.5 = air and values >= 0.5 = wall. Thereafter it places the starting grids (overwrites the noise data) conforming to the starting template.

val spawnRoom = """
        |#####
        |#...#
        |#...#
        |#...#
        |#####
        """

It is safe to say that you will not really get the same map each time you play, unless you seed the noise and use the same seed.

1 Like

Regarding the worms.

Each round you will only be moving one worm.
In the state file you get the active worm id indicating your current active worm.
Between rounds the engine will cycle through your worms that are still alive to determine which worm will be active in the next round.

So at the start you will cycle through worms like: 1, 2, 3, 1, 2, 3, 1, …
Then let’s say worm 2 dies, the cycling continues: 3, 1, 3, 1, 3, 1, …
If another one of your worms die, you will play each round with the remaining worm after that.

One more thing.

How exactly do weapons work?
There’s only a description of weapon range, but none as to what the range is.

The range is explained under the “shoot” section of the game rules: https://github.com/EntelectChallenge/2019-Worms/blob/master/game-engine/game-rules.md#shoot

Thanks k290

but that only explains how shoot direction and range works.

It doesn’t say what range is, or how much hp a worm loses when it get shot, and possibly how those can change

Hi @linjoehan

I am not exactly sure what you are asking here, but I will try to explain.
Range controls how far a worm can shoot. From the readme

To determine if a cell is in range, calculate its euclidean distance from the worm’s position, round it downwards to the nearest integer (floor), and check if it is less than or equal to the max range

Essentially, we run over all cells in the shooting direction that are within range and apply the following logic:

  • If the cell contains a worm, the worm loses hp equal to the weapon damage
  • If the cell is dirt or deep space, the shot is blocked
  • Otherwise, continue on to the next cell

As k290 pointed out - all of the rules relating to shooting can be found in the game rules

@linjoehan the range of the weapon is the max distance it can shoot. To see if a target is within the range of the weapon you use the Euclidean distance calculation posted above

I understand that, I guess I’m asking what is the damage and range of a worms weapon? or is it randomly determined, and if it is random how is that random distributed

It isn’t explicitly in the rules because it is in the json file. It is in the weapon section:
myPlayer:
worm:
id: 1
health: 150
position:
x: 10
y: 10
weapon:
damage: 8
range: 4

If the damage is set to 8 and range to 4, you can shoot 4 squares away (with euclidian distance) and if you hit another worm they will lose 8 health.

2 Likes

Is it correct that worms collide only if both worm move to the same place. And all other cases are invalid moves?

For example
moving to a square with a stationery worm on it.
moving to a square with a worm, even if that worm moves to another square on that same turn.

or are these also considered collisions?

Hi @linjoehan

Collisions will only happen if two worms move to the same cell in the same round. These commands are not invalid, because from the worm’s perspective both are moving to a empty cell.

Move validation is done before any commands are executed, so movement to any cell that is occupied at the beginning of the turn is considered invalid. This includes your two examples.