From 008d02415ef333e896dfe7d2c52de5de7e3e7166 Mon Sep 17 00:00:00 2001 From: David Neilsen Date: Fri, 4 Sep 2020 09:33:13 +1200 Subject: [PATCH] Fix closest --- src/lib/moveTowardsEnemy.ts | 2 +- src/server/snakes/tail-chase.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/moveTowardsEnemy.ts b/src/lib/moveTowardsEnemy.ts index a39ec9a..a7c0495 100644 --- a/src/lib/moveTowardsEnemy.ts +++ b/src/lib/moveTowardsEnemy.ts @@ -4,7 +4,7 @@ import { closestEnemyHead } from './closestEnemyHead'; export function moveTowardsEnemy(data: BTData) { const closest = closestEnemyHead(data); - if (closest.direction) { + if (closest && closest.direction) { log('moveTowardsEnemy', closest.direction); return closest.direction; } diff --git a/src/server/snakes/tail-chase.ts b/src/server/snakes/tail-chase.ts index 2b130b1..850d0aa 100644 --- a/src/server/snakes/tail-chase.ts +++ b/src/server/snakes/tail-chase.ts @@ -26,7 +26,6 @@ export class TailChase extends BaseSnake implements ISnake { } const closest = closestEnemyHead(data); - console.log(closest); if (closest && closest.path.length <= 4) { direction = moveAway(data); }