#!/usr/bin/ruby -w require 'src/play' require 'src/selection' winner_success_chance = 0.8 player_bitstrings = readlines.collect {|l| l.chomp.split(//).collect {|x| x.to_i}} # File.open('player.log', 'a') do |f| # player_bitstrings.each {|b| f.puts "Process #{Process.pid}: Received #{b}"} # end players = player_bitstrings.collect {|b| Genome.new(b).to_potential_player} handler = GameHandler.new(players, 1000) winner, moves = handler.play if winner == :draw or rand > winner_success_chance successful_player = players[rand(players.length)] else successful_player = winner end # File.open('player.log', 'a') do |f| # f.puts "Process #{Process.pid}: winner is #{successful_player.to_bitstring}" # end puts "#{successful_player.to_bitstring}"