[QUIZ] Paper Rock Scissors (#16)

This is impossible for players which do not cheat.
You can't give any predictions on the next move of a random player.
Therefore you have a 1/3 prop. to choose a winning,losing or drawing move.

Here is another 'cheater' (which does not redefine a method):

SYMBOLS = [ :rock,
           :paper,
           :scissors ]
KILLER = { :rock => :paper, :paper => :scissors, :scissors => :rock }

class BHCheatPlayer < Player

  def initialize( opponent )
    super
    @opp = Object.const_get(opponent).new(self)
  end

  def choose
    KILLER[@opp.choose]
  end

  def result(you,them,result)
    @opp.result(them,you,result)
  end

end

···

On Mon, 24 Jan 2005 01:46:58 +0900, James Edward Gray II wrote:

On Jan 23, 2005, at 5:40 AM, Benedikt Huber wrote:

Otherwise, a strategy simply selecting a random choice will always
have a
50% chance of winning

Looks like we are seeing some strategies that do better than 50%
against a random player. :wink:

I have a similar solution:

SYMBOLS = [ :rock,
           :paper,
           :scissors ]
KILLER = { :rock => :paper, :paper => :scissors, :scissors => :rock }
MAXSIZE = 5

class Symbol
  def +(o)
    return (self.to_s+o.to_s).to_sym
  end
end

class BHAdaptPlayer4 < Player

  def initialize( opponent )
    @stats = Hash.new()
    @lastmoves = []
  end

  def get_keys
    keys = [ ]
    @lastmoves.each do |pair|
      keys.unshift( keys.empty? ? pair : (keys[0]+pair))
    end
    keys
  end

  def choose
    info = nil
    get_keys.each do |key|
      info = @stats[key]
      break if info
    end
    if ! info
      SYMBOLS[rand(3)]
    else
      max = -1
      msym = nil
      info.keys.each do |sym|
        msym,max = sym,info[sym] if(info[sym] > max)
      end
      KILLER[msym]
    end
  end

  # called after each choice you make to give feedback
  # you = your choice
  # them = opponent's choice
  # win_lose_or_draw = :win, :lose or :draw, your result
  def result( you, them, win_lose_or_draw )
    get_keys.each do |key|
      @stats[key] = create_stat if ! @stats[key]
      @stats[key][them] += 1
    end
    @lastmoves.unshift(@lastchoice)
    @lastmoves.pop if @lastmoves.size > MAXSIZE

    @lastchoice = them+you
  end

  def create_stat
    stat = {}
    SYMBOLS.each {|sym| stat[sym] = 0 }
    stat
  end

end

In the bottom of this mail are my 7 bots.

2 of them ne_cont_rand.rb and ne_cont_queue.rb uses continuations,
so its probably best to discard them.

···

--
Simon Strandgaard

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2005-01-23 15:41 CET by <neoneye@server>.
# Source directory was `/home/neoneye/code/quiz/rock_scissor_paper'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 555 -rw-r--r-- players/ne_queue.rb
# 707 -rw-r--r-- players/ne_rand.rb
# 1786 -rw-r--r-- players/ne_antibias.rb
# 1397 -rw-r--r-- players/ne_treshold.rb
# 1642 -rw-r--r-- players/ne_stupid.rb
# 400 -rw-r--r-- players/ne_cont_queue.rb
# 303 -rw-r--r-- players/ne_cont_rand.rb
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f
200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f
123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f
1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps. Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh06382; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= players/ne_queue.rb ==============
if test ! -d 'players'; then
  $echo 'x -' 'creating directory' 'players'
  mkdir 'players'
fi
if test -f 'players/ne_queue.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_queue.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_queue.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_queue.rb
M8VQA<W,@3D51=65U95!L87EE<B`\(%!L87EE<@T*"5%5155%(#T@6R`-"@D)
M.G)O8VLL(#IR;V-K+"`Z<F]C:RP@.G)O8VLL#0H)"3IS8VES<V]R<RP@.G-C
M:7-S;W)S+"`Z<&%P97(L(#IS8VES<V]R<RP-"@D).G!A<&5R+"`Z<&%P97(L
M(#IS8VES<V]R<RP@.G!A<&5R+"`-"@D).G)O8VLL(#IR;V-K+"`Z<F]C:RP@
M.G-C:7-S;W)S+`T*"0DZ<&%P97(L(#IS8VES<V]R<RP@.G-C:7-S;W)S+"`Z
M<&%P97(L#0H)"3IR;V-K+"`Z<&%P97(L(#IP87!E<BP@.G)O8VLL#0H)"3IS
M8VES<V]R<RP@.G!A<&5R+"`Z<F]C:RP@.G)O8VLL#0H)"3IS8VES<V]R<RP@
M.G)O8VLL(#IS8VES<V]R<RP@.G-C:7-S;W)S+`T*"0DZ<&%P97(L(#IS8VES
M<V]R<RP@.G!A<&5R+"`Z<&%P97(@#0H)70T*"61E9B!I;FET:6%L:7IE*"!O
M<'!O;F5N="`I#0H)"7-U<&5R#0H)0&EN9&5X(#T@,`T*"65N9`T*"61E9B!C
M:&]O<V4-"@D)8VAO:6-E(#T@455%545;0&EN9&5X70T*"0E`:6YD97@@*ST@
M,0T*"0E`:6YD97@@/2`P(&EF($!I;F1E>"`]/2!1545512YS:7IE#0H)"6-H
/;VEC90T*"65N9`T*96YD
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_queue.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_queue.rb' ||
  $echo 'restore of' 'players/ne_queue.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_queue.rb:' 'MD5 check failed'
3259093536e9765638990620064d3bc5 players/ne_queue.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_queue.rb'`"
    test 555 -eq "$shar_count" ||
    $echo 'players/ne_queue.rb:' 'original size' '555,' 'current size'
"$shar_count!"
  fi
fi
# ============= players/ne_rand.rb ==============
if test -f 'players/ne_rand.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_rand.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_rand.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_rand.rb
M8VQA<W,@3F5O;F5Y95)A;F0@/"!0;&%Y97(-"@E1545512`](%L@.G)O8VLL
M#0H)"3IS8VES<V]R<RP-"@D).G-C:7-S;W)S(%T-"@T*"61E9B!I;FET:6%L
M:7IE*"!O<'!O;F5N="`I#0H)"7-U<&5R#0H)"4!I;F1E>"`](#`-"@D)0&AI
M<W1O<GD@/2!;70T*"65N9`T*#0H)9&5F(&-H;V]S90T*"0ER971U<FX@.G)O
M8VL@:68@0&AI<W1O<GDN96UP='D_#0H)"0T*"0EY;W4L('1H96TL('=L9"`]
M($!H:7-T;W)Y+FQA<W0-"@D)8V%S92!W;&0-"@D)=VAE;B`Z9')A=PT*"0D)
M0&EN9&5X(#T@*$!I;F1E>"`K(%%5155%+G-I>F4@*R`Q("T@<F%N9"@R*2D@
M)2!1545512YS:7IE#0H)"0ER971U<FX@455%545;0&EN9&5X70T*"0EW:&5N
M(#IL;W-E#0H)"0EB970@/2`H<F%N9"@Q,#`I(#X@-S4I(#\@,"`Z(#(-"@D)
M"4!I;F1E>"`]("A`:6YD97@@*R!B970I("4@455%544N<VEZ90T*"0D)<F5T
M=7)N(%%5155%6T!I;F1E>%T-"@D)=VAE;B`Z=VEN#0H)"0EB970@/2`H<F%N
M9"@Q,#`I(#X@.#`I(#\@,2`Z(#`-"@D)"4!I;F1E>"`]("A`:6YD97@@*R!B
M970I("4@455%544N<VEZ90T*"0D)<F5T=7)N(%%5155%6T!I;F1E>%T-"@D)
M96YD#0H)"3IR;V-K#0H)96YD#0H)"0T*"61E9B!R97-U;'0H('EO=2P@=&AE
M;2P@=VEN7VQO<V5?;W)?9')A=R`I#0H)"4!H:7-T;W)Y(#P\(%MY;W4L('1H
@96TL('=I;E]L;W-E7V]R7V1R87==#0H)96YD#0IE;F1Y
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_rand.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_rand.rb' ||
  $echo 'restore of' 'players/ne_rand.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_rand.rb:' 'MD5 check failed'
9df2864007f62d8a563f0780128fd754 players/ne_rand.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_rand.rb'`"
    test 707 -eq "$shar_count" ||
    $echo 'players/ne_rand.rb:' 'original size' '707,' 'current size'
"$shar_count!"
  fi
fi
# ============= players/ne_antibias.rb ==============
if test -f 'players/ne_antibias.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_antibias.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_antibias.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_antibias.rb
M8VQA<W,@3F5O;F5Y94%N=&EB:6%S(#P@4&QA>65R#0H)455%544@/2!;(#IS
M8VES<V]R<RP@.G)O8VLL(#IP87!E<B!=#0H)9&5F(&EN:71I86QI>F4H(&]P
M<&]N96YT("D-"@D)<W5P97(-"@D)0&AI<W1O<GD@/2!;70T*"0E`8V]U;G0@
M/2`P#0H)"4!L;W-E(#T@6UT-"@D)0&1R87<@/2!;70T*"0E`=VEN(#T@6UT-
M"@D)0&-O=6YT<R`]('LZ<V-I<W-O<G,]/C`L(#IR;V-K/3XP+"`Z<&%P97(]
M/C`@?0T*"65N9`T*"61E9B!Q<PT*"0E1545512YS:7IE#0H)96YD#0H)9&5F
M('%U975E*&DI#0H)"5%5155%6VD@)2!1545512YS:7IE70T*"65N9`T*"61E
M9B!C:&%N8V4H;&5V96PL(&$L(&(I#0H)"2AR86YD*#$P,"D@/"!L979E;"D@
M/R!A(#H@8@T*"65N9`T*"61E9B!C:&]O<V4-"@D)0&-O=6YT("L](#$-"@D)
M#0H)"2,@,7-T('-T<F%T96=Y.B!T<GD@86QL(&-O;6)I;F%T:6]N<PT*"0ER
M971U<FX@<75E=64H0&-O=6YT+3$I(&EF($!C;W5N="`\/2!Q<PT*"0D-"@D)
M(R`R;F0@<W1R871E9WDZ('!L87D@;VX@=&AO<V4@=VAE<F4@=V4@=V]N#0H)
M"6EF($!C;W5N="`\/2!Q<RHR#0H)"0EY;W4L('1H96TL('=L9"`]($!H:7-T
M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*"0EB970@/2`Z<V-I<W-O<G,@:68@=G,K;"`^('9R(&%N
M9"!V<RML(#X@=G`-"@D)8F5T(#T@.G!A<&5R(&EF('9P*VP@/B!V<B!A;F0@
M=G`K;"`^('9S#0H)"0D)"0D-"@D)<F5T=7)N(&-H86YC92@Q,"P@8F5T+"`H
M=VQD("$](#IL;W-E*2`_('1H96T@.B!C:&]I8V4I#0H)96YD#0H)"0T*"61E
M9B!R97-U;'0H('EO=2P@=&AE;2P@=VEN7VQO<V5?;W)?9')A=R`I#0H)"4!C
M;W5N='-;>6]U72`K/2`Q#0H)"6-A<V4@=VEN7VQO<V5?;W)?9')A=R`-"@D)
M=VAE;B`Z;&]S93H@0&QO<V4@/#P@6WEO=2P@=&AE;5T-"@D)=VAE;B`Z9')A
M=SH@0&1R87<@/#P@6WEO=2P@=&AE;5T-"@D)=VAE;B`Z=VEN.B`@0'=I;B`\
M/"!;>6]U+"!T:&5M70T*"0EE;F0-"@D)0&AI<W1O<GD@/#P@6WEO=2P@=&AE
?;2P@=VEN7VQO<V5?;W)?9')A=UT-"@EE;F0-"F5N9'D@
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_antibias.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_antibias.rb' ||
  $echo 'restore of' 'players/ne_antibias.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_antibias.rb:' 'MD5 check failed'
5e97bc2a6069f46ca39e44c12f0f442e players/ne_antibias.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_antibias.rb'`"
    test 1786 -eq "$shar_count" ||
    $echo 'players/ne_antibias.rb:' 'original size' '1786,' 'current
size' "$shar_count!"
  fi
fi
# ============= players/ne_treshold.rb ==============
if test -f 'players/ne_treshold.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_treshold.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_treshold.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_treshold.rb
M8VQA<W,@3F5O;F5Y951H<F5S:&]L9"`\(%!L87EE<@T*"5%5155%(#T@6R`Z
M<F]C:RP-"@D).G-C:7-S;W)S+`T*"0DZ<&%P97(L#0H)"3IP87!E<BP-"@D)
M.G!A<&5R+`T*"0DZ<F]C:RP-"@D).G!A<&5R+`T*"0DZ<F]C:RP-"@D).G-C
M:7-S;W)S(%T-"@T*"61E9B!I;FET:6%L:7IE*"!O<'!O;F5N="`I#0H)"7-U
M<&5R#0H)"4!I;F1E>"`](#`-"@D)0&AI<W1O<GD@/2!;70T*"0E`8V]U;G0@
M/2`P#0H)"4!L;W-T(#T@,`T*"0D-"@D)0'-T<F%T96=Y(#T@.F-H;V]S95]R
M86YD;VT-"@D)0&QE=F5L,2`](#<U#0H)"4!L979E;#(@/2`Y,`T*"65N9`T*
M#0H)9&5F(&-H;V]S90T*"0EI9B!`8V]U;G0@/3T@-3`@86YD($!L;W-T(#X@
M-0T*"0D)(W`@(F-H86YG:6YG('-T<F%T96=Y(@T*"0D)0&QE=F5L,2`](#<U
M#0H)"0E`;&5V96PR(#T@,3`P#0H)"65N9`T*"0EI9B!`8V]U;G0@/3T@,3`P
M(&%N9"!`;&]S="`^(#(P#0H)"0DC<"`B;&5T<R!T<GD@<V]M971H:6YG(&5L
M<V4B#0H)"0E`;&5V96PQ(#T@-#`-"@D)"4!L979E;#(@/2`Y,`T*"0EE;F0-
M"@D):68@0&-O=6YT(#T](#$U,"!A;F0@0&QO<W0@/B`S,`T*"0D)(W`@(F)A
M8VL@=&\@9&5F875L="!S=')A=&5G>2(-"@D)"4!L979E;#$@/2`X,`T*"0D)
M0&QE=F5L,B`](#DU#0H)"65N9`T*"0E`8V]U;G0@*ST@,0T*"0ES96YD*$!S
M=')A=&5G>2D-"@EE;F0-"@D)#0H)9&5F(&-H;V]S95]R86YD;VT-"@D)<F5T
M=7)N(#IR;V-K(&EF($!H:7-T;W)Y+F5M<'1Y/PT*"0D-"@D)>6]U+"!T:&5M
M+"!W;&0@/2!`:&ES=&]R>2YL87-T#0H)"6-A<V4@=VQD#0H)"7=H96X@.F1R
M87<-"@D)"4!I;F1E>"`]("A`:6YD97@@*R!1545512YS:7IE("L@,2`M(')A
M;F0H,BDI("4@455%544N<VEZ90T*"0D)<F5T=7)N(%%5155%6T!I;F1E>%T-
M"@D)=VAE;B`Z;&]S90T*"0D)8F5T(#T@*')A;F0H,3`P*2`^($!L979E;#$I
M(#\@,"`Z(#$-"@D)"4!I;F1E>"`]("A`:6YD97@@*R!B970I("4@455%544N
M<VEZ90T*"0D)<F5T=7)N(%%5155%6T!I;F1E>%T-"@D)=VAE;B`Z=VEN#0H)
M"0EB970@/2`H<F%N9"@Q,#`I(#X@0&QE=F5L,BD@/R`Q(#H@,`T*"0D)0&EN
M9&5X(#T@*$!I;F1E>"`K(&)E="D@)2!1545512YS:7IE#0H)"0ER971U<FX@
M455%545;0&EN9&5X70T*"0EE;F0-"@D).G)O8VL-"@EE;F0-"@D-"@ED968@
M8VAO;W-E7W%U975E#0H)"4!I;F1E>"`]("A`:6YD97@@*R`Q*2`E(%%5155%
M+G-I>F4-"@D)<F5T=7)N(%%5155%6T!I;F1E>%T-"@EE;F0-"@D)#0H)9&5F
M(')E<W5L="@@>6]U+"!T:&5M+"!W:6Y?;&]S95]O<E]D<F%W("D-"@D)0&QO
M<W0@*ST@,2!I9B!W:6Y?;&]S95]O<E]D<F%W(#T](#IL;W-E#0H)"4!H:7-T
M;W)Y(#P\(%MY;W4L('1H96TL('=I;E]L;W-E7V]R7V1R87==#0H)96YD#0IE
";F1Y
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_treshold.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_treshold.rb' ||
  $echo 'restore of' 'players/ne_treshold.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_treshold.rb:' 'MD5 check failed'
4421a31f3a80c43e74d69bbc4b513020 players/ne_treshold.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_treshold.rb'`"
    test 1397 -eq "$shar_count" ||
    $echo 'players/ne_treshold.rb:' 'original size' '1397,' 'current
size' "$shar_count!"
  fi
fi
# ============= players/ne_stupid.rb ==============
if test -f 'players/ne_stupid.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_stupid.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_stupid.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_stupid.rb
M8VQA<W,@3F5O;F5Y95-T=7!I9"`\(%!L87EE<@T*"5%5155%(#T@6R`Z<V-I
M<W-O<G,L(#IR;V-K+"`Z<&%P97(@70T*"61E9B!I;FET:6%L:7IE*"!O<'!O
M;F5N="`I#0H)"7-U<&5R#0H)"4!H:7-T;W)Y(#T@6UT-"@D)0&-O=6YT(#T@
M,`T*"0E`;&]S92`](%M=#0H)"4!D<F%W(#T@6UT-"@D)0'=I;B`](%M=#0H)
M96YD#0H)9&5F('%S#0H)"5%5155%+G-I>F4-"@EE;F0-"@ED968@<75E=64H
M:2D-"@D)455%545;:2`E(%%5155%+G-I>F5=#0H)96YD#0H)9&5F(&-H86YC
M92AL979E;"P@82P@8BD-"@D)*')A;F0H,3`P*2`\(&QE=F5L*2`_(&$@.B!B
M#0H)96YD#0H)9&5F(&-H;V]S90T*"0E`8V]U;G0@*ST@,0T*"0D-"@D)(R`Q
M<W0@<W1R871E9WDZ('1R>2!A;&P@8V]M8FEN871I;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]U+"!T
M:&5M+"!W;&0@/2!`:&ES=&]R>2YL87-T#0H)"6-H;VEC92`](&-A<V4@=VQD
M#0H)"7=H96X@.F1R87<Z(&-H86YC92@X,"P@=&AE;2P@<75E=64H0&-O=6YT
M("T@,2DI#0H)"7=H96X@.FQO<V4Z('1H96T-"@D)=VAE;B`Z=VEN.B!Y;W4-
M"@D)96YD#0H)"0T*"0EI9B!`;&]S92YS:7IE(#X@0'=I;BYS:7IE#0H)"0ER
M971U<FX@=&AE;0T*"0EE;F0-"@D)"0D)"0T*"0ER971U<FX@8VAO:6-E#0H)
M96YD#0H)"0T*"61E9B!R97-U;'0H('EO=2P@=&AE;2P@=VEN7VQO<V5?;W)?
M9')A=R`I#0H)"6-A<V4@=VEN7VQO<V5?;W)?9')A=R`-"@D)=VAE;B`Z;&]S
M93H@0&QO<V4@/#P@6WEO=2P@=&AE;5T-"@D)=VAE;B`Z9')A=SH@0&1R87<@
M/#P@6WEO=2P@=&AE;5T-"@D)=VAE;B`Z=VEN.B`@0'=I;B`\/"!;>6]U+"!T
M:&5M70T*"0EE;F0-"@D)0&AI<W1O<GD@/#P@6WEO=2P@=&AE;2P@=VEN7VQO
6<V5?;W)?9')A=UT-"@EE;F0-"F5N9'D@
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_stupid.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_stupid.rb' ||
  $echo 'restore of' 'players/ne_stupid.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_stupid.rb:' 'MD5 check failed'
d0b6e5c0c587ee049f83b845a9ffc6d5 players/ne_stupid.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_stupid.rb'`"
    test 1642 -eq "$shar_count" ||
    $echo 'players/ne_stupid.rb:' 'original size' '1642,' 'current
size' "$shar_count!"
  fi
fi
# ============= players/ne_cont_queue.rb ==============
if test -f 'players/ne_cont_queue.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_cont_queue.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_cont_queue.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_cont_queue.rb
M8VQA<W,@3F5O;F5Y94-O;G11=65U92`\(%!L87EE<@T*"5%5155%(#T@6R`Z
M<F]C:RP@.G-C:7-S;W)S+"`Z<&%P97(L(#IP87!E<BP@.G)O8VLL(#IS8VES
M<V]R<R!=#0H)9&5F(&EN:71I86QI>F4H(&]P<&]N96YT("D-"@D)<W5P97(-
M"@D)0')E<W5M92`](&QA;6)D82![?0T*"0E`:6YD97@@/2`P#0H)96YD#0H)
M9&5F(&-H;V]S90T*"0EC86QL8V-[?$!R97-U;65\?0T*"0E`:6YD97@@/2`H
M0&EN9&5X("L@,2D@)2!1545512YS:7IE#0H)"2-1545515MR86YD*%%5155%
M+G-I>F4I70T*"0E1545515M`:6YD97A=#0H)96YD#0H)9&5F(')E<W5L="@@

6]U+"!T:&5M+"!W:6Y?;&]S95]O<E]D<F%W("D-"@D)0')E<W5M92YC86QL

H(&EF('=I;E]L;W-E7V]R7V1R87<@/3T@.FQO<V4-"@EE;F0-"F5N9"YC
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_cont_queue.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_cont_queue.rb' ||
  $echo 'restore of' 'players/ne_cont_queue.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_cont_queue.rb:' 'MD5 check failed'
6a81061c36cfd276a19c7b514b762360 players/ne_cont_queue.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_cont_queue.rb'`"
    test 400 -eq "$shar_count" ||
    $echo 'players/ne_cont_queue.rb:' 'original size' '400,' 'current
size' "$shar_count!"
  fi
fi
# ============= players/ne_cont_rand.rb ==============
if test -f 'players/ne_cont_rand.rb' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'players/ne_cont_rand.rb' '(file already exists)'
else
  $echo 'x -' extracting 'players/ne_cont_rand.rb' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 players/ne_cont_rand.rb
M8VQA<W,@3F5O;F5Y94-O;G1286YD(#P@4&QA>65R#0H)455%544@/2!;(#IR
M;V-K+"`Z<V-I<W-O<G,L(#IP87!E<B!=#0H)9&5F(&EN:71I86QI>F4H(&]P
M<&]N96YT("D-"@D)<W5P97(-"@D)0')E<W5M92`](&QA;6)D82![?0T*"65N
M9`T*"61E9B!C:&]O<V4-"@D)8V%L;&-C>WQ`<F5S=6UE?'T-"@D)455%545;
M<F%N9"A1545512YS:7IE*5T-"@EE;F0-"@ED968@<F5S=6QT*"!Y;W4L('1H
M96TL('=I;E]L;W-E7V]R7V1R87<@*0T*"0E`<F5S=6UE+F-A;&P@:68@=VEN
A7VQO<V5?;W)?9')A=R`]/2`Z;&]S90T*"65N9`T*96YD
`
end
SHAR_EOF
  (set 20 05 01 23 15 39 04 'players/ne_cont_rand.rb'; eval "$shar_touch") &&
  chmod 0644 'players/ne_cont_rand.rb' ||
  $echo 'restore of' 'players/ne_cont_rand.rb' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    >> $echo 'players/ne_cont_rand.rb:' 'MD5 check failed'
b58dc408275f688d35443ec344b92f83 players/ne_cont_rand.rb
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'players/ne_cont_rand.rb'`"
    test 303 -eq "$shar_count" ||
    $echo 'players/ne_cont_rand.rb:' 'original size' '303,' 'current
size' "$shar_count!"
  fi
fi
rm -fr _sh06382
exit 0

James Edward Gray II wrote:

Protecting yourself, eh? That looks like a challenge. Anyone want to out cheat this cheater? It can be done!

Use .freeze or the method_added etc. hooks. :slight_smile:

Thanks for the link. Here's a good quote from there:

  lypanov notes that the quiz is a bit silly as the reason many good players win in real life
  is because they react fast to the hand formations so unless you have a real person playing
  against a bot guessing the players move by recognition, its kind of boring :stuck_out_tongue:

Actually, this is one of the reasons I chose to use Paper Rock Scissors. I could have easily picked something with a little more strategy. :wink:

James Edward Gray II

···

On Jan 23, 2005, at 12:01 PM, Christian Neukirchen wrote:

James Edward Gray II <james@grayproductions.net> writes:

On Jan 23, 2005, at 7:31 AM, Christian Neukirchen wrote:

First, congratulations to this great quiz. It was a great fun for me
and other people on #ruby-lang.

Any interesting discussion occur on the channel you would like to
share with the rest of the group?

James Edward Gray II

Check:

     http://meme.b9.com/cview.html?channel=ruby-lang&date=050122

11 o'clock and later.

Benedikt Huber wrote:

This is impossible for players which do not cheat.
You can't give any predictions on the next move of a random player.
Therefore you have a 1/3 prop. to choose a winning,losing or drawing move.

Here is another 'cheater' (which does not redefine a method):

This is similar to my solution, but mine does also copy the state of its enemy.

This 'cheater' isn't gauranteed. Try it against this naive random player:

class RandomPlayer < Player
   def initialize( opponent )
     super
   end

  def choose
    [ :paper, :scissors, :rock ][ rand(3) ]
  end

  def result(you,them,result)
  end
end

There's no gaurantee that the answer you get from @opp.choose will be
the same one the referee gets when he calls choose on the bot. :slight_smile:

Jacob Fugal

···

On Mon, 24 Jan 2005 05:15:52 +0900, Benedikt Huber <benjovi@gmx.net> wrote:

Here is another 'cheater' (which does not redefine a method):

SYMBOLS = [ :rock,
           :paper,
           :scissors ]
KILLER = { :rock => :paper, :paper => :scissors, :scissors => :rock }

class BHCheatPlayer < Player

  def initialize( opponent )
    super
    @opp = Object.const_get(opponent).new(self)
  end

  def choose
    KILLER[@opp.choose]
  end

  def result(you,them,result)
    @opp.result(them,you,result)
  end

end

Still, it's a mighty clever trick against many strategies.

James Edward Gray II

···

On Jan 24, 2005, at 9:17 PM, Jacob Fugal wrote:

There's no gaurantee that the answer you get from @opp.choose will be
the same one the referee gets when he calls choose on the bot. :slight_smile:

Jacob Fugal wrote:

This 'cheater' isn't gauranteed. Try it against this naive random player:

  def choose
    [ :paper, :scissors, :rock ][ rand(3) ]
  end

Still, even in that situation you will pick an attack against a random invalid move which means you'll still have a 50% chance of winning.

An alternate solution to the Rock, Paper, Scissors problem.

http://www.comp.leeds.ac.uk/vision/cogvis/games.html

···

On Tue, 25 Jan 2005 12:29:32 +0900, James Edward Gray II <james@grayproductions.net> wrote:

On Jan 24, 2005, at 9:17 PM, Jacob Fugal wrote:

> There's no gaurantee that the answer you get from @opp.choose will be
> the same one the referee gets when he calls choose on the bot. :slight_smile:

Still, it's a mighty clever trick against many strategies.

James Edward Gray II