--------------000402080705020908050800
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This is my first player (Markov chain based)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB87jh5YRWfc27RzQRAoqpAJ4uEzEGtiKqZpgl7wRJopUofihhywCcDK+k
eG/3jZfl12/u8KFhfHqxuwE xb
-----END PGP SIGNATURE-----
--------------000402080705020908050800
Content-Type: text/plain; x-mac-type="2A2A2A2A"; x-mac-creator="48647261";
name ix_player_m.rb"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename ix_player_m.rb"
class JIXPlayerM < Player
WIN :paper :scissors, :rock :paper , :scissors :rock}
def initialize( opponent )
@mk
sh.new
@last il]*3 # try other values
end
def choose
if !@last[0].nil?
nodekey last.map do |i|
i[0].to_s+"-"+i[1].to_s
end.join(",")
@mk[nodekey] KNode.new if !@mk[nodekey]
@mk[nodekey].choose
else
[:paper,:rock,:scissors][rand(3)]
end
end
def result( you, them, win_lose_or_draw )
if !@last[0].nil?
nodekey last.map do |i|
i[0].to_s+"-"+i[1].to_s
end.join(",")
@mk[nodekey] KNode.new if !@mk[nodekey]
@mk[nodekey]<< WIN[them]
end
@last[0,1]
@last<< [you,them]
end
private
class MKNode
def initialize(paper rock scissors
@paper
per
@rock ck
@scissors
issors
end
def choose
if @paper+@rock+@scissors 0
[:paper,:rock,:scissors][rand(3)]
else
rnd and(@paper+@rock+@scissors)
if rnd < @paper
:paper
elsif rnd < @paper+@rock
:rock
else
:scissors
end
end
end
def <<(x)
case x
when :paper
@paper+ when :rock
@rock+ when :scissors
@scissors+ end
end
def inspect
max paper+@rock+@scissors.to_f
if max 0
"#<JIXPlayerM::MKNode --- >"
else
"#<JIXPlayerM::MKNode p{#{@paper/max}} r{#{@rock/max}} s{#{@scissors/max}} >"
end
end
end
end
--------------000402080705020908050800--