Initial commit
[trapthecap.git] / play-one-game.rb
1 #!/usr/bin/ruby -w
2
3 require 'src/play'
4 require 'src/selection'
5
6 winner_success_chance = 0.8
7
8 player_bitstrings = readlines.collect {|l| l.chomp.split(//).collect {|x| x.to_i}}
9
10 # File.open('player.log', 'a') do |f|
11 # player_bitstrings.each {|b| f.puts "Process #{Process.pid}: Received #{b}"}
12 # end
13
14 players = player_bitstrings.collect {|b| Genome.new(b).to_potential_player}
15
16 handler = GameHandler.new(players, 1000)
17 winner, moves = handler.play
18
19 if winner == :draw or rand > winner_success_chance
20 successful_player = players[rand(players.length)]
21 else
22 successful_player = winner
23 end
24
25 # File.open('player.log', 'a') do |f|
26 # f.puts "Process #{Process.pid}: winner is #{successful_player.to_bitstring}"
27 # end
28
29 puts "#{successful_player.to_bitstring}"