Created
April 12, 2013 16:59
-
-
Save tomchapin/5373481 to your computer and use it in GitHub Desktop.
A quick ruby script that takes a series of player names as command line arguments and pairs them up with each other in random fashion. Example usage:
> ruby player_selector.rb Bob John Jim Billy George
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
| require 'active_support/core_ext/string/inflections' | |
| require 'colorize' | |
| players = ARGV.clone | |
| raise 'You must specify players (separated by spaces) as parameters.' and exit(1) unless players.count > 0 | |
| until players.count == 0 | |
| player1, player2 = players.shuffle!.slice!(0,2) | |
| player2 ||= "Bot(AI)" | |
| puts player1.titleize.blue + " is paired with ".light_white + player2.titleize.blue | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment