Skip to content

Instantly share code, notes, and snippets.

@tomchapin
Created April 12, 2013 16:59
Show Gist options
  • Save tomchapin/5373481 to your computer and use it in GitHub Desktop.
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
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