feat(js): m04 random and spawn with fixtures and tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
2e39f23bb3
commit
08b462d5cc
@@ -0,0 +1,452 @@
|
||||
{
|
||||
"function": "spawnApple",
|
||||
"cases": [
|
||||
{
|
||||
"name": "spawn-picks-a-free-cell-and-advances-seed",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 1831565813,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-other-seed-picks-other-cell",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 1,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 1831565814,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-with-one-free-cell",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 1
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 7,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 1
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 1831565820,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-on-full-board",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 1
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 1
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Won",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-apple-present-unchanged",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-paused-unchanged",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-gameover-unchanged",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "GameOver",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "GameOver",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "spawn-won-unchanged",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Won",
|
||||
"frame": 0
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": null,
|
||||
"seed": 5,
|
||||
"score": 0,
|
||||
"status": "Won",
|
||||
"frame": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user