summaryrefslogtreecommitdiff
path: root/dartbot.rb
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-02 04:47:08 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-02 04:47:08 -0700
commit172229560dd8a7dba317a13d7b954409f7af3fcb (patch)
tree81410474a361b36a5a783edf48c3b44442c86d0d /dartbot.rb
parent7d23b640eacd0c49578a5227f6cbb7fcf1d4396b (diff)
downloaddartboat-172229560dd8a7dba317a13d7b954409f7af3fcb.tar.gz
dartboat-172229560dd8a7dba317a13d7b954409f7af3fcb.tar.xz
add (unpolished) interactive mode
Diffstat (limited to 'dartbot.rb')
-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