Created
October 5, 2012 01:44
-
-
Save agarie/3837594 to your computer and use it in GitHub Desktop.
A basic input creation script and some random inputs generated by it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# This script creates checkerboard inputs for CS325 Program #4. | |
# | |
# Carlos Agarie | |
# | |
prng = Random.new | |
# Arbitrarily decided that 80% are checkers and 20% are kings. | |
red_checkers = %w{RC RC RC RC RK} | |
black_checkers = %w{BC BC BC BC BK} | |
p = red_checkers.size | |
# P(red checker) = P(black checker) = 12/64 = 3/16 | |
# P(blank) = 40/64 = 10/16 | |
checkers = [] | |
10.times { |i| checkers << 'b' } | |
3.times { |i| checkers << red_checkers[prng.rand(p)] } | |
3.times { |i| checkers << black_checkers[prng.rand(p)] } | |
k = checkers.size | |
8.times do |i| | |
8.times { |j| print "#{checkers[ prng.rand(k) ]} " } | |
print "\n" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b b b b b b RC b | |
b b BC BC b BC RC b | |
b b b b b RC b RC | |
BK RC RC RC b b b b | |
b b RC RC b BC b b | |
RC b b RC b b BC RC | |
b b BC b b b b RC | |
b b b RC RC RC b b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b b b BC b BC b b | |
BC b BC RC BC RC RC RC | |
BC b BC b RC b RC b | |
b BC b b RC BC b RC | |
RC b b b RC b b b | |
b b b b b BC b BC | |
b b b RC b b b b | |
RC b b b b BC b b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RC BC BC RC b b b RK | |
RC b b b RC b BC b | |
b RC b b b RC b b | |
b b BC b b b RK b | |
b BC RC b RK b RC b | |
b b RC BC b RC b b | |
b b b BC b BC b b | |
RC RK b b b b BC BC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment