This software calculates distances on a square grid using the 'chessboard metric' and allows for the inclusion of optional wormholes.
At its most basic level, the number of moves required to travel from point (x1, y1) to point (x2, y2) can be easily calculated using the following formula: d( (x1, y1), (x2, y2) ) = max( abs( x1 - x2 ), abs( y1 - y2) ). However, in the presence of wormholes, the actual number of moves required may be less.
Wormhole travel is conceptually represented in this module as a fixed number of moves required to traverse a distance. Users can specify the coordinates of wormholes through the use of the class Algorithm::Metric::Chessboard::Wormhole.
To use this module, users must first create an instance of Algorithm::Metric::Chessboard using the constructor method new(). During instantiation, users can provide the ranges of x and y values, along with any wormholes they wish to consider, and the cost required to travel through a wormhole.
Once the grid has been defined, users can obtain the nearest wormhole to a coordinate using nearest_wormhole(), and find the shortest path between two points using shortest_journey(). Overall, Algorithm::Metric::Chessboard is a useful tool for any Perl developer looking to calculate distances on a square grid with wormholes.
Version 0.01: N/A