MCPcopy
hub / github.com/statelyai/xstate / newApple

Function newApple

examples/snake-react/src/snakeMachine.ts:88–94  ·  view source on GitHub ↗
(gridSize: Point, ineligibleGridPoints: Point[])

Source from the content-addressed store, hash-verified

86}
87
88function newApple(gridSize: Point, ineligibleGridPoints: Point[]) {
89 let newApple = randomGridPoint(gridSize);
90 while (find(ineligibleGridPoints, newApple)) {
91 newApple = randomGridPoint(gridSize);
92 }
93 return newApple;
94}
95
96function growSnake(snake: Snake): Snake {
97 return [...snake, snake[snake.length - 1]];

Callers 1

snakeMachine.tsFile · 0.85

Calls 2

randomGridPointFunction · 0.85
findFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…