Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Algorithm::Evolve 0.01

Company: Mike Rosulek
Date Added: October 23, 2013  |  Visits: 339

Calculate distances on a square grid with optional wormholes (the 'chessboard metric')<br /><br />Algorithm::Metric::Chessboard is a Perl module to calculate distances on a square grid with optional wormholes (the 'chessboard metric').<br /><br />Calculates the minimum number of moves between two points in a game played on a square grid, where one move is a jump from a point to a horizontal, vertical or diagonal neighbour.<br /><br />With no other features, the number of moves taken to go from the point (x1, y1) to (x2, y2) would be quite simple:<br /><br /> d( (x1, y1), (x2, y2) ) = max( abs( x1 - x2 ), abs( y1 - y2) )<br /><br />However within the space are "wormholes" which allow you to travel between any two distant points, so the actual number of moves may be smaller than the above. Wormhole travel costs a fixed number of moves.<br /><br />SYNOPSIS<br /><br /> my @wormholes = (<br /> Algorithm::Metric::Chessboard::Wormhole->new( x => 5, y => 30 ),<br /> Algorithm::Metric::Chessboard::Wormhole->new( x => 98, y => 99 ),<br /> );<br /><br /> my \$grid = Algorithm::Metric::Chessboard->new(<br /> x_range => [ 0, 99 ],<br /> y_range => [ 0, 99 ],<br /> wormholes => @wormholes,<br /> wormhole_cost => 3,<br /> );<br /><br /> my \$wormhole = \$grid->nearest_wormhole( x => 26, y => 53 );<br /><br /> my \$journey = \$grid->shortest_journey(start => [1, 6], end => [80, 1]);<br /><br />Requirements:<br /><br />?*A* Perl<br />

 Requirements: No special requirements Platforms: *nix, Linux Keyword: Actual,  Algorithm,  Chessboard,  Costs,  Distances,  Distant,  Fixed,  Metric,  Moves,  Movessynopsis,  Number,  Optional,  Point,  Points,  Smaller,  Square,  Travel,  Wormhole,  Wormholes Users rating: 0/10