Skip to content

Instantly share code, notes, and snippets.

@tsmarsh
Created January 1, 2019 17:08
Show Gist options
  • Save tsmarsh/f3800af19cfab20caff8490ee5a03245 to your computer and use it in GitHub Desktop.
Save tsmarsh/f3800af19cfab20caff8490ee5a03245 to your computer and use it in GitHub Desktop.
Features for Game of Life
Feature: Main game
Any live cell with fewer than two live neighbors dies, as if by under population.
Any live cell with two or three live neighbors lives on to the next generation.
Any live cell with more than three live neighbors dies, as if by overpopulation.
Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
Scenario: A cell starts dead
Given we have a game:
"""
0,0,0
0,0,0
0,0,0
"""
Then the cell 0,0 should be dead
Scenario: A cell can be bought to life
Given we have a game:
"""
X,0,0
0,0,0
0,0,0
"""
Then the cell 0,0 should be alive
And the cell 0,1 should be dead
Scenario: Loneliness
Given we have a game:
"""
X,0,0
0,0,0
0,0,0
"""
When we advance the game
Then the cell 0,0 should be dead
Scenario: Survival with 2 neighbours and a little reproduction
Given we have a game:
"""
0,0,0,0,0
0,X,X,X,0
0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,X,0,0
0,0,X,0,0
0,0,X,0,0
"""
Scenario: Explode
Given we have a game:
"""
0,0,0,0,0
0,X,X,X,0
0,X,X,X,0
0,X,X,X,0
0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,X,0,0
0,X,0,X,0
X,0,0,0,X
0,X,0,X,0
0,0,X,0,0
"""
Scenario: Reproduction
Given we have a game:
"""
X,X,0
X,0,0
0,0,0
"""
When we advance the game
Then the game state is:
"""
X,X,0
X,X,0
0,0,0
"""
Feature: Oscillating patterns
Scenario: Blinker
Given we have a game:
"""
0,0,0,0,0
0,0,X,0,0
0,0,X,0,0
0,0,X,0,0
0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0
0,0,0,0,0
0,X,X,X,0
0,0,0,0,0
0,0,0,0,0
"""
Given we have a game:
"""
0,0,0,0,0
0,0,0,0,0
0,X,X,X,0
0,0,0,0,0
0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0
0,0,X,0,0
0,0,X,0,0
0,0,X,0,0
0,0,0,0,0
"""
Scenario: Blinker
Given we have a game:
"""
0,0,0,0,0,0
0,0,0,X,0,0
0,X,0,0,X,0
0,X,0,0,X,0
0,0,X,0,0,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,0,0,0,0,0
0,0,X,X,X,0
0,X,X,X,0,0
0,0,0,0,0,0
0,0,0,0,0,0
"""
Given we have a game:
"""
0,0,0,0,0,0
0,0,0,0,0,0
0,0,X,X,X,0
0,X,X,X,0,0
0,0,0,0,0,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,0,0,X,0,0
0,X,0,0,X,0
0,X,0,0,X,0
0,0,X,0,0,0
0,0,0,0,0,0
"""
Scenario: Beacon
Given we have a game:
"""
0,0,0,0,0,0
0,X,X,0,0,0
0,X,0,0,0,0
0,0,0,0,X,0
0,0,0,X,X,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,X,X,0,0,0
0,X,X,0,0,0
0,0,0,X,X,0
0,0,0,X,X,0
0,0,0,0,0,0
"""
Given we have a game:
"""
0,0,0,0,0,0
0,X,X,0,0,0
0,X,X,0,0,0
0,0,0,X,X,0
0,0,0,X,X,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,X,X,0,0,0
0,X,0,0,0,0
0,0,0,0,X,0
0,0,0,X,X,0
0,0,0,0,0,0
"""
Feature: Stable patterns
Scenario: Block
Given we have a game:
"""
0,0,0,0
0,X,X,0
0,X,X,0
0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0
0,X,X,0
0,X,X,0
0,0,0,0
"""
Scenario: Behive
Given we have a game:
"""
0,0,0,0,0,0
0,0,X,X,0,0
0,X,0,0,X,0
0,0,X,X,0,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,0,X,X,0,0
0,X,0,0,X,0
0,0,X,X,0,0
0,0,0,0,0,0
"""
Scenario: Loaf
Given we have a game:
"""
0,0,0,0,0,0
0,0,X,X,0,0
0,X,0,0,X,0
0,0,X,0,X,0
0,0,0,X,0,0
0,0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0,0
0,0,X,X,0,0
0,X,0,0,X,0
0,0,X,0,X,0
0,0,0,X,0,0
0,0,0,0,0,0
"""
Scenario: Tub
Given we have a game:
"""
0,0,0,0,0
0,0,X,0,0
0,X,0,X,0
0,0,X,0,0
0,0,0,0,0
"""
When we advance the game
Then the game state is:
"""
0,0,0,0,0
0,0,X,0,0
0,X,0,X,0
0,0,X,0,0
0,0,0,0,0
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment