Advertisement
Guest User

Untitled

a guest
May 25th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. # What's more?
  2. # a quick guesstimation game
  3. # (Emoji-enhanced Ruby version)
  4.  
  5. require 'time'
  6.  
  7. cont = true
  8.  
  9. r = 0
  10. t = Time.now.to_f
  11.  
  12. # "Fisheye" & "Bullseye"
  13. #bchar = ["\u25C9","\u25CE"]
  14. # "Cloud" & "Umbrella"
  15. bchar = ["\u2601", "\u2602"]
  16.  
  17. begin
  18.  
  19. c = [ 0, 0 ]
  20.  
  21. r += 1
  22. br = rand()
  23. fd = ""
  24.  
  25. # field composition & output needs to be cached in Ruby
  26. for y in 1..10 do
  27. for x in 1..10 do
  28. rand() > br ? n = 1 : n = 0
  29. c[n] += 1
  30. fd += " #{ bchar[n] } "
  31. end
  32. fd += "\n" * 2
  33. end
  34.  
  35. fd += "\n"
  36. puts fd
  37.  
  38. begin
  39. inp_err = false
  40. print "What's more (#{bchar[0]}=0 or #{bchar[1]}=1)?"
  41.  
  42. k = gets.to_i
  43.  
  44. if k != 0 and k != 1 then
  45. puts "invalid input!"
  46. inp_err = true
  47. end
  48.  
  49. end while inp_err
  50.  
  51. for i in 0..1 do
  52. puts "#{bchar[i]}: #{c[i]}"
  53. if c[i] > c[k] then cont = false; end
  54. end
  55.  
  56. puts
  57.  
  58.  
  59. end while cont
  60.  
  61. puts "YOUR RUN: #{r} ROUNDS(S) in #{(Time.now.to_f - t).round(3)} SECONDS TIME!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement