matchscore 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/matchscore.rb +28 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e316ba81a88f2bc20fd478a424a2047a9902bc1
4
+ data.tar.gz: ec32fb59a961f02c448a32302f1e8105a8839ca1
5
+ SHA512:
6
+ metadata.gz: d8cebdbe4ee0898c9a58f42a2daea3080fbc614b437a008c4b82872bdb05e1f2718ac222cd5fe8209f7cc008e821dd48a303ac6b46face4302dcbf789f6a69bd
7
+ data.tar.gz: 306337b5e42b460da4d8cd0e6f342c65c82ba3606e7b53c5a935f6d1b1954bff8b2e2c531c43c1e512a43088c0d7d763b42287848202d5a27d72d09d3ffb2d14
data/lib/matchscore.rb ADDED
@@ -0,0 +1,28 @@
1
+
2
+
3
+ class Matchscore
4
+ def self.winner a_odds=50, number_of_games=3
5
+ a_wins = 0
6
+ z_wins = 0
7
+ game_number = 1
8
+ while a_wins < (number_of_games+1)/2 && z_wins < (number_of_games+1)/2
9
+ result = Random::rand 100
10
+ if result < a_odds
11
+ a_wins += 1
12
+ puts "A wins game #{game_number} (#{result})"
13
+ else
14
+ z_wins += 1
15
+ puts "Z wins game #{game_number} (#{result})"
16
+ end
17
+ game_number += 1
18
+ end
19
+ if a_wins > z_wins
20
+ puts "A wins #{a_wins} games to #{z_wins}"
21
+ winner = 'A'
22
+ else
23
+ puts "Z wins #{z_wins} games to #{a_wins}"
24
+ winner = 'Z'
25
+ end
26
+ winner
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matchscore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hunter Wong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: hjwong@bluejeans.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/matchscore.rb
20
+ homepage: https://github.com/0ryhara/hjwgem
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Simulates match results
44
+ test_files: []