From 86fda8f9ff0eb0bd32f67c5d2bbdae0ec5b6033c Mon Sep 17 00:00:00 2001 From: mo k Date: Mon, 13 Feb 2012 13:19:50 -0700 Subject: check bounds when facing south and moving forward. --- lib/south.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 lib/south.rb (limited to 'lib') diff --git a/lib/south.rb b/lib/south.rb old mode 100644 new mode 100755 index 04851c0..5e8a434 --- a/lib/south.rb +++ b/lib/south.rb @@ -5,7 +5,9 @@ class South def turn_left East.new end - def forward(current_location, terrain) - current_location[:y] = current_location[:y]-1 + def forward(location, terrain) + unless terrain.is_out_of_bounds({:x => location[:x], :y => location[:y]-1}) + location[:y] = location[:y]-1 + end end end -- cgit v1.2.3