4 require 'src/selection'
6 winner_success_chance
= 0.8
8 player_bitstrings
= readlines
.collect
{|l
| l
.chomp
.split(//).collect
{|x
| x
.to_i
}}
10 # File.open('player.log', 'a') do |f|
11 # player_bitstrings.each {|b| f.puts "Process #{Process.pid}: Received #{b}"}
14 players
= player_bitstrings
.collect
{|b
| Genome
.new(b
).to_potential_player
}
16 handler
= GameHandler
.new(players
, 1000)
17 winner
, moves
= handler
.play
19 if winner
== :draw or rand
> winner_success_chance
20 successful_player
= players
[rand(players
.length
)]
22 successful_player
= winner
25 # File.open('player.log', 'a') do |f|
26 # f.puts "Process #{Process.pid}: winner is #{successful_player.to_bitstring}"
29 puts
"#{successful_player.to_bitstring}"