diff --git a/src/lib/weight.ts b/src/lib/weight.ts index 8d0674a..bbabd7b 100644 --- a/src/lib/weight.ts +++ b/src/lib/weight.ts @@ -108,6 +108,14 @@ export function weight(data: BTData, x: number, y: number, blockHeads = true) { } function computeWeight(data: BTData, x: number, y: number, blockHeads = true) { + if (data.board.hazards) { + for (const hazard of data.board.hazards) { + if (hazard.x == x && hazard.y == y) { + return 5; + } + } + } + let result = 100; for (const snake of data.board.snakes) { const body = snake.body; diff --git a/src/types/BTData.ts b/src/types/BTData.ts index a714674..5d7a911 100644 --- a/src/types/BTData.ts +++ b/src/types/BTData.ts @@ -15,7 +15,7 @@ export interface BTBoard { width: number, height: number, food: BTXY[], - hazards: BTXY[], + hazards?: BTXY[], snakes: BTSnake[], } diff --git a/src/web/grid.ts b/src/web/grid.ts index 9f4686d..4333db3 100644 --- a/src/web/grid.ts +++ b/src/web/grid.ts @@ -57,6 +57,14 @@ export function loadGrid(moveJson) { const col = getCol(food.x, food.y); $('