diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-02 04:47:08 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-02 04:47:08 -0700 |
commit | 172229560dd8a7dba317a13d7b954409f7af3fcb (patch) | |
tree | 81410474a361b36a5a783edf48c3b44442c86d0d | |
parent | 7d23b640eacd0c49578a5227f6cbb7fcf1d4396b (diff) | |
download | dartboat-172229560dd8a7dba317a13d7b954409f7af3fcb.tar.gz dartboat-172229560dd8a7dba317a13d7b954409f7af3fcb.tar.xz |
add (unpolished) interactive mode
-rwxr-xr-x | dartbot.rb | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -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 |