Mercurial > maze-src
comparison distance_grid.rb @ 0:1eef88068f9f tip
initial commit of maze game source
| author | ferencd |
|---|---|
| date | Sun, 15 Sep 2019 11:46:47 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1eef88068f9f |
|---|---|
| 1 #--- | |
| 2 # Excerpted from "Mazes for Programmers", | |
| 3 # published by The Pragmatic Bookshelf. | |
| 4 # Copyrights apply to this code. It may not be used to create training material, | |
| 5 # courses, books, articles, and the like. Contact us if you are in doubt. | |
| 6 # We make no guarantees that this code is fit for any purpose. | |
| 7 # Visit http://www.pragmaticprogrammer.com/titles/jbmaze for more book information. | |
| 8 #--- | |
| 9 require 'grid' | |
| 10 | |
| 11 class DistanceGrid < Grid | |
| 12 attr_accessor :distances | |
| 13 | |
| 14 def contents_of(cell) | |
| 15 if distances && distances[cell] | |
| 16 distances[cell].to_s | |
| 17 else | |
| 18 super | |
| 19 end | |
| 20 end | |
| 21 end |
