advent_of_code_2021/day_15/vendor/blackscorp/astar/src/Heuristic/Diagonal.php

16 lines
373 B
PHP

<?php
namespace BlackScorp\Astar\Heuristic;
use BlackScorp\Astar\HeuristicInterface;
use BlackScorp\Astar\Node;
class Diagonal implements HeuristicInterface
{
public function compare(Node $node, Node $goal)
{
$deltaX = abs($node->getX() - $goal->getX());
$deltaY = abs($node->getY() - $goal->getY());
return max($deltaX, $deltaY);
}
}