Skip to content

Commit

Permalink
Fix game tests for random dificulty
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrohml committed Dec 24, 2015
1 parent d878b7a commit c424b1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/game/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def select_goal_cell(dificulty)
depths = leafs.keys.sort
case dificulty
when :easy
selected_depth = depths[(depths.size*0.25).ceil]
selected_depth = depths[(depths.size/4).ceil]
when :medium
selected_depth = depths[(depths.size*0.5).ceil]
selected_depth = depths[(depths.size/2).ceil]
when :hard
selected_depth = depths.last
else
selected_depth = depths[rand((depths.size/2.0).ceil) + (depths.size/2.0).ceil]
selected_depth = depths[(depths.size/2.0).floor + rand((depths.size/2.0).round)]
end
leafs[selected_depth].content
end
Expand Down
6 changes: 3 additions & 3 deletions spec/game/game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
expect(maze.matrix.flatten).to include(2)
end

it '#generate_goal :easy' do
it '#generate_goal :medium' do
maze = @game.generate_goal(:medium)
expect(maze.matrix.flatten).to include(2)
end

it '#generate_goal :easy' do
it '#generate_goal :hard' do
maze = @game.generate_goal(:hard)
expect(maze.matrix.flatten).to include(2)
end

it '#generate_goal :easy' do
it '#generate_goal :random' do
maze = @game.generate_goal(:random)
expect(maze.matrix.flatten).to include(2)
end
Expand Down

0 comments on commit c424b1c

Please sign in to comment.