Skip to content

Commit

Permalink
Fix closest
Browse files Browse the repository at this point in the history
  • Loading branch information
Petah committed Sep 3, 2020
1 parent 66fa9c9 commit 008d024
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/moveTowardsEnemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/server/snakes/tail-chase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 008d024

Please sign in to comment.