summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdartbot.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/dartbot.rb b/dartbot.rb
index af6962f..62a1e0e 100755
--- a/dartbot.rb
+++ b/dartbot.rb
@@ -279,6 +279,38 @@ def play_match(start_points = 501, output = true)
m_darts
end
+def play_int_match(start_points = 501, output = true)
+ p_rem = start_points
+ rem = start_points
+ m_darts = []
+
+ output_visit(m_darts.length, rem) if output
+
+ loop do
+ rem, points, darts, bust = play_visit(rem)
+ m_darts << darts
+
+ output_visit(m_darts.length, rem, points, darts, bust) if output
+ if rem == 0
+ puts
+ puts 'Dartbot wins. :('
+ break
+ end
+
+ print "Enter points: "
+ p_points = gets.to_i
+ p_rem -= p_points
+ puts "Remaining: #{p_rem}"
+ puts
+ if p_rem == 0
+ puts 'You win! :)'
+ break
+ end
+ end
+
+ m_darts
+end
+
def test_average
avgs = (0..10000).map do |x|
m_darts = play_match(501, false)
@@ -294,5 +326,5 @@ def test_average
puts stdev
end
-play_match
+play_int_match
#test_average