--------------010706050109070401000700
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Test results (-m 5000)(Generated using my edited paper_rock_scissors.rb):

 #		   Name      Score
 1        AJBMetaPlayer    53116.0
 2           JIXPlayerD    50965.0
 3      DRPatternPlayer    49527.0
 4           JIXPlayerM    48782.5
 5     AJBHistoryPlayer    45518.0
 6       CNBiasInverter    35336.0
 7      AJBRandomPlayer    35101.5
 8            CNIrrflug    33951.5
 9           JIXPlayerT    31794.5
10           JIXPlayerC    26901.0
11        CNBiasFlipper    23821.5
12        CNBiasBreaker    23498.5
13          CNStepAhead    23043.0
14   AJBFrequencyPlayer    22988.5
15         CNMeanPlayer    20655.5

JIXPlayer D,T and C:
D: Dynamic Length Markov Chains
T: Word lengths of a text ;)
C: p r r s p s,p r r s ...



--------------010706050109070401000700
Content-Type: text/plain; x-mac-type="2A2A2A2A"; x-mac-creator="48647261";
 name="jix_player_c.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="jix_player_c.rb"

class JIXPlayerC < Player
    def initialize( opponent )
        @que=%w{paper rock rock scissors paper scissors}.map{|z|z.to_sym}
        @i=0
    end
    def choose
        @i+=1
        @i%=@que.size 
        @que[@i]
    end
end
--------------010706050109070401000700
Content-Type: text/plain; x-mac-type="2A2A2A2A"; x-mac-creator="48647261";
 name="jix_player_d.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="jix_player_d.rb"

class JIXPlayerD < Player
    WIN = {:paper => :scissors, :rock => :paper , :scissors => :rock}
    def initialize( opponent )
        @mk=Hash.new
        @last=[nil]*10
    end
    
    def choose
        out = []
        0.upto(@last.size-2) do |z|
        
            if !@last[z].nil?
                nodekey = @last[z..-1].map do |i|
                    i[0].to_s+"-"+i[1].to_s
                    #i[1].to_s
                end.join(",")
            out << @mk[nodekey] if @mk[nodekey]

            end
        end

        return [:paper,:rock,:scissors][rand(3)] if out == []
        
        out.sort_by{|z| - z.dfm}
        out[0].choose
    end
    
    def result( you, them, win_lose_or_draw )
        
        
        0.upto(@last.size-2) do |z|
            if !@last[z].nil?
                nodekey = @last[z..-1].map do |i|
                    i[0].to_s+"-"+i[1].to_s
                    #i[1].to_s
                end.join(",")
            @mk[nodekey]= MKNode.new if !@mk[nodekey]
            @mk[nodekey]<< WIN[them]
            end
        end


        @last[0,1]=[]
        @last<< [you,them]

    end
    private


    
    class MKNode
        def initialize(paper=0,rock=0,scissors=0)
            @paper=paper
            @rock=rock
            @scissors=scissors
        end
        def choose
            if @paper+@rock+@scissors == 0
                [:paper,:rock,:scissors][rand(3)]
            else
                rnd = rand(@paper+@rock+@scissors)
                if rnd < @paper
                    :paper
                elsif rnd < @paper+@rock
                    :rock
                else
                    :scissors
                end
            end
        end
        def dfm
            mid = (@paper+@rock+@scissors)/3.0
            (mid-@paper).abs+(mid-@rock).abs+(mid-@scissors).abs+mid
        end
        def <<(x)
            case x
            when :paper
                @paper+=1
            when :rock
                @rock+=1
            when :scissors
                @scissors+=1
            end
        end
        def inspect
            max = @paper+@rock+@scissors.to_f
            if max == 0
            "#<JIXPlayerDM::MKNode --- >"
            else
            "#<JIXPlayerDM::MKNode p{#{@paper/max}} r{#{@rock/max}} s{#{@scissors/max}} dfm{#{dfm}}>"
            end
        end
    end 
end
--------------010706050109070401000700
Content-Type: text/plain; x-mac-type="2A2A2A2A"; x-mac-creator="48647261";
 name="jix_player_t.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="jix_player_t.rb"

class JIXPlayerT < Player
    def initialize( opponent )
        
        text = <<'EOT'
Man is driven to create; I know I really love to create things. And while I'm not good at painting, drawing, or music, I can write software.

Shortly after I was introduced to computers, I became interested in programming languages. I believed that an ideal programming language must be attainable, and I wanted to be the designer of it. Later, after gaining some experience, I realized that this kind of ideal, all-purpose language might be more difficult than I had thought. But I was still hoping to design a language that would work for most of the jobs I did everyday. That was my dream as a student.

Years later I talked with colleagues about scripting languages, about their power and possibility. As an object-oriented fan for more than fifteen years, it seemed to me that OO programming was very suitable for scripting too. I did some research on the 'net for a while, but the candidates I found, Perl and Python, were not exactly what I was looking for. I wanted a language more powerful than Perl, and more object-oriented than Python.

Then, I remembered my old dream, and decided to design my own language. At first I was just toying around with it at work. But gradually it grew to be a tool good enough to replace Perl. I named it Ruby---after the precious red stone---and released it to the public in 1995.

Since then a lot of people have become interested in Ruby. Believe it or not, Ruby is actually more popular than Python in Japan right now. I hope that eventually it will be just as well received all over the world.

I believe that the purpose of life is, at least in part, to be happy. Based on this belief, Ruby is designed to make programming not only easy, but also fun. It allows you to concentrate on the creative side of programming, with less stress. If you don't believe me, read this book and try Ruby. I'm sure you'll find out for yourself.

I'm very thankful to the people who have joined the Ruby community; they have helped me a lot. I almost feel like Ruby is one of my children, but in fact, it is the result of the combined efforts of many people. Without their help, Ruby could never have become what it is.

I am especially thankful to the authors of this book, Dave Thomas and Andy Hunt. Ruby has never been a well-documented language. Because I have always preferred writing programs over writing documents, the Ruby manuals tend to be less thorough than they should be. You had to read the source to know the exact behavior of the language. But now Dave and Andy have done the work for you.

They became interested in a lesser-known language from the Far East. They researched it, read thousands of lines of source code, wrote uncountable test scripts and e-mails, clarified the ambiguous behavior of the language, found bugs (and even fixed some of them), and finally compiled this great book. Ruby is certainly well documented now!

Their work on this book has not been trivial. While they were writing it, I was modifying the language itself. But we worked together on the updates, and this book is as accurate as possible.

It is my hope that both Ruby and this book will serve to make your programming easy and enjoyable. Have fun!

Yukihiro Matsumoto, a.k.a. ``Matz''
EOT
        @sizes=text.gsub(/[^A-Za-z\s]/,"").split(/\s+/).map{|z|z.size%3}
        @count=rand(@sizes.size)
    end
    def choose
        @count+=1
        @count%=@sizes.size
        [:paper,:rock,:scissors][@sizes[@count]]
    end
end
--------------010706050109070401000700
Content-Type: text/plain; x-mac-type="2A2A2A2A"; x-mac-creator="48647261";
 name="paper_rock_scissors.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="paper_rock_scissors.rb"

#!/usr/bin/env ruby
class Player
	@@players = [ ]
	
	def self.inherited( player )
		@@players << player
	end
	
	def self.each_pair
		(0...(@@players.size - 1)).each do |i|
			((i + 1)...@@players.size).each do |j|
				yield @@players[i], @@players[j]
			end
		end
	end
	
	def initialize( opponent )
		@opponent = opponent
	end
	
	def choose
		raise NoMethodError, "Player subclasses must override choose()."
	end
	
	def result( you, them, win_lose_or_draw )
		# do nothing--sublcasses can override as needed
	end
end

class Game
    attr_reader :score1,:score2
	def initialize( player1, player2 )
		@player1	= player1.new(player2.to_s)
		@player2	= player2.new(player1.to_s)
		@score1		= 0
		@score2		= 0
	end
	
	def play( match )
		match.times do
			hand1 = @player1.choose
			hand2 = @player2.choose
			case hand1
			when :paper
				case hand2
				when :paper
					draw hand1, hand2
				when :rock
					win @player1, hand1, hand2
				when :scissors
					win @player2, hand1, hand2
				else
					raise "Invalid choice by #{@player2.class}."
				end
			when :rock
				case hand2
				when :paper
					win @player2, hand1, hand2
				when :rock
					draw hand1, hand2
				when :scissors
					win @player1, hand1, hand2
				else
					raise "Invalid choice by #{@player2.class}."
				end
			when :scissors
				case hand2
				when :paper
					win @player1, hand1, hand2
				when :rock
					win @player2, hand1, hand2
				when :scissors
					draw hand1, hand2
				else
					raise "Invalid choice by #{@player2.class}."
				end
			else
				raise "Invalid choice by #{@player1.class}."
			end
		end
	end
	
	def results
		match = "#{@player1.class} vs. #{@player2.class}\n" +
					"\t#{@player1.class}: #{@score1}\n" +
					"\t#{@player2.class}: #{@score2}\n"
		if @score1 == @score2
			match + "\tDraw\n"
		elsif @score1 > @score2
			match + "\t#{@player1.class} Wins\n"
		else
			match + "\t#{@player2.class} Wins\n"
		end
	end
	
	private
	
	def draw( hand1, hand2 )
		@score1 += 0.5
		@score2 += 0.5
		@player1.result(hand1, hand2, :draw)
		@player2.result(hand2, hand1, :draw)
	end
	
	def win( winner, hand1, hand2 )
		if winner == @player1
			@score1 += 1
			@player1.result(hand1, hand2, :win)
			@player2.result(hand2, hand1, :lose)
		else
			@score2 += 1
			@player1.result(hand1, hand2, :lose)
			@player2.result(hand2, hand1, :win)
		end
	end
end


match_game_count = 1000
if ARGV.size > 2 and ARGV[0] == "-m" and ARGV[1] =~ /^[1-9]\d*$/
	ARGV.shift
	match_game_count = ARGV.shift.to_i
end

ARGV.each do |p|
	if test(?d, p)
		Dir.foreach(p) do |file|
			next if file =~ /^\./
			next unless file =~ /\.rb$/
			require File.join(p, file)
		end
	else
		require p
	end
end
overallscore=Hash.new(0)

Player.each_pair do |one, two|
	game = Game.new one, two
	game.play match_game_count
	puts game.results
	overallscore[one]+=game.score1
	overallscore[two]+=game.score2
end
puts("%2s %20s %10s" % ["#","Name","Score"])
z=0

overallscore.to_a.sort_by{|i|-i[1]}.each do |scorepair|
    puts("%2i %20s %10.1f" % [z+=1,scorepair[0],scorepair[1]])
end
--------------010706050109070401000700--