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

16 lines
370 B
PHP

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