Master Mind / Code Breaker

Platform:  mIRC
Published  Mar 15, 2009
Updated  Feb 07, 2010

The bot will pick 4-6 random colours and then you'll have up to 10 guesses to figure it out.
It tells you if you have the right colour but it isn't in the right spot and it will tell you if it's the right colour in the right spot but it's up to you to figure out which it's talking about.

Hope that's a good enough explanation. :S


Commands:

  • !mm or !mastermind will start the game.
    If there's no number after the command it will start a 4 code game. If you say 5 or 6 it will start a 5 or 6 code game.
  • !g or !guess <rbgyop> will let you guess the code.
    e.g. !guess rbroyo would work in a 6 code game
  • !reset
    This will end your game. (And add 1 to failed)
  • !cheat/!infinite
    You can still win using these but your number of cheats will go up.
  • !stats (nick)
    Will tell you the either your own stats or (nick)'s stats.


If the script doesn't work there's an older version http://master-mind.pastebin.com/f2e525a34
Update

  • !peek nick (# | all) / !assist nick (# | all)
    Only useable by other people. Will show either the #th letter of a code or will show the last 1/4th of the code, rounded up.**
  • !time
    Will show the top time for each length of code. I think it might've overwritten a lower time once.
  • !MasterMind (# between 4 and 10) / !mm (# between 4 and 10)
    No # or something out of the range will just be 4.
    Increased the number of guesses for longer codes. Easily editable in the 'alias mastermind'

**I use this on mirc 6.17, I can think of at least one part that might not work on later versions. Hopefully everything works though.

Kinda an incomplete updated version but I'll have limited access for awhile so I figured I'd post what I have. alias -l comtime {
var %x $calc(($1 - $2) / 1000)
var %y $gettok(%x,2,46)
var %x $gettok(%x,1,46)
if (%x > 60) {
var %z $calc(%x / 60)
var %x $floor($calc($+(.,$gettok(%z,2,46)) * 60))
var %z $gettok(%z,1,46)
}
return $+($iif(%z,%z $+ :),%x,:,%y)
}
alias -l random { return $gettok($$1-,$r(1,$0),32) }
alias -l mastermind {
if (!$2) || ($2 <= 4) || ($2 > 10) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 10
}
elseif ($2 == 5) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 10
}
elseif ($2 == 6) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 10
}
elseif ($2 == 7) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 12
}
elseif ($2 == 8) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 12
}
elseif ($2 == 9) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 14
}
elseif ($2 == 10) {
set %mm. [ $+ [ $address($1,2) ] ] $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o) $random(r,b,g,y,p,o)
set %mm.guesses. [ $+ [ $address($1,2) ] ] 15
}
}
on *:TEXT:*:#: {
if (!%mm.act. [ $+ [ $address($nick,2) ] ]) {
tokenize 32 $strip($1-)
if ($istok(!MasterMind !mm,$1,32)) {
if (!%mm. [ $+ [ $address($nick,2) ] ]) {
set -u1 %mm.act. [ $+ [ $address($nick,2) ] ] 1
mastermind $nick $2
msg #  $+ $nick $+ : you have %mm.guesses. [ $+ [ $address($nick,2) ] ] guesses. Guess with !guess < $+ $numtok(%mm. [ $+ [ $address($nick,2) ] ],32) chars out of rgbyop>.
set %ticks. [ $+ [ $address($nick,2) ] ] $ticks
if (!$readini(MasterMind.ini,Players,$address($nick,2))) { writeini MasterMind.ini Players $address($nick,2) 1 }
}
}
elseif ($1 == !help) { set -u1 %mm.act. [ $+ [ $address($nick,2) ] ] 1 | notice $nick Type !Mastermind to start the (4colour crack) game and !guess to crack the code. You can use !Mastermind 5 or 6 for 5 or 6colour crack. !reset to end your game(counts as a loss) and !stats to see your stats. }
elseif ($1 == !time) {
set -u10 %mm.act. [ $+ [ $address($nick,2) ] ] 1
if ($ini(MasterTime.ini,4Time,0)) { .timer 1 1 .notice $nick 4 Letter code: $ini(MasterTime.ini,4Time,1) $+ : $readini(MasterTime.ini,4Time,$ini(MasterTime.ini,4Time,1)) }
if ($ini(MasterTime.ini,5Time,0)) { .timer 1 2 .notice $nick 5 Letter code: $ini(MasterTime.ini,5Time,1) $+ : $readini(MasterTime.ini,5Time,$ini(MasterTime.ini,5Time,1)) }
if ($ini(MasterTime.ini,6Time,0)) { .timer 1 3 .notice $nick 6 Letter code: $ini(MasterTime.ini,6Time,1) $+ : $readini(MasterTime.ini,6Time,$ini(MasterTime.ini,6Time,1)) }
if ($ini(MasterTime.ini,7Time,0)) { .timer 1 4 .notice $nick 7 Letter code: $ini(MasterTime.ini,7Time,1) $+ : $readini(MasterTime.ini,7Time,$ini(MasterTime.ini,7Time,1)) }
if ($ini(MasterTime.ini,8Time,0)) { .timer 1 5 .notice $nick 8 Letter code: $ini(MasterTime.ini,8Time,1) $+ : $readini(MasterTime.ini,8Time,$ini(MasterTime.ini,8Time,1)) }
if ($ini(MasterTime.ini,9Time,0)) { .timer 1 6 .notice $nick 9 Letter code: $ini(MasterTime.ini,9Time,1) $+ : $readini(MasterTime.ini,9Time,$ini(MasterTime.ini,9Time,1)) }
if ($ini(MasterTime.ini,10Time,0)) { .timer 1 7 .notice $nick 10 Letter code: $ini(MasterTime.ini,10Time,1) $+ : $readini(MasterTime.ini,10Time,$ini(MasterTime.ini,10Time,1)) }
}
elseif ($1 == !stats) {
set -u3 %mm.act. [ $+ [ $address($nick,2) ] ] 1
if (!$2) {
if ($readini(MasterMind.ini,Players,$address($nick,2))) {
var %mmxa $readini(MasterMind.ini,4Wins,$address($nick,2))
var %mmxb $readini(MasterMind.ini,4Fails,$address($nick,2))
var %mmya $readini(MasterMind.ini,5Wins,$address($nick,2))
var %mmyb $readini(MasterMind.ini,5Fails,$address($nick,2))
var %mmza $readini(MasterMind.ini,6Wins,$address($nick,2))
var %mmzb $readini(MasterMind.ini,6Fails,$address($nick,2))
var %mmaa $readini(MasterMind.ini,7Wins,$address($nick,2))
var %mmab $readini(MasterMind.ini,7Fails,$address($nick,2))
var %mmba $readini(MasterMind.ini,8Wins,$address($nick,2))
var %mmbb $readini(MasterMind.ini,8Fails,$address($nick,2))
var %mmca $readini(MasterMind.ini,9Wins,$address($nick,2))
var %mmcb $readini(MasterMind.ini,9Fails,$address($nick,2))
var %mmda $readini(MasterMind.ini,10Wins,$address($nick,2))
var %mmdb $readini(MasterMind.ini,10Fails,$address($nick,2))
var %mmx 4: $calc(%mmxa) $+ : $+ $calc(%mmxb) $chr(40) $+ $round($calc(%mmxa / (%mmxa + %mmxb) * 100),2) $+ % W/L $+ $chr(41)
var %mmy $+(,$str($chr(124),2),) 5: $calc(%mmya) $+ : $+ $calc(%mmyb) $chr(40) $+ $round($calc(%mmya / (%mmya + %mmyb) * 100),2) $+ % W/L $+ $chr(41)
var %mmz $+(,$str($chr(124),2),) 6: $calc(%mmza) $+ : $+ $calc(%mmzb) $chr(40) $+ $round($calc(%mmza / (%mmza + %mmzb) * 100),2) $+ % W/L $+ $chr(41)
var %mma $+(,$str($chr(124),2),) 7: $calc(%mmaa) $+ : $+ $calc(%mmab) $chr(40) $+ $round($calc(%mmaa / (%mmaa + %mmab) * 100),2) $+ % W/L $+ $chr(41)
var %mmb 8: $calc(%mmba) $+ : $+ $calc(%mmbb) $chr(40) $+ $round($calc(%mmba / (%mmba + %mmbb) * 100),2) $+ % W/L $+ $chr(41)
var %mmc $+(,$str($chr(124),2),) 9: $calc(%mmca) $+ : $+ $calc(%mmcb) $chr(40) $+ $round($calc(%mmca / (%mmca + %mmcb) * 100),2) $+ % W/L $+ $chr(41)
var %mmd $+(,$str($chr(124),2),) 10: $calc(%mmda) $+ : $+ $calc(%mmdb) $chr(40) $+ $round($calc(%mmda / (%mmda + %mmdb) * 100),2) $+ % W/L $+ $chr(41)
msg #  $+ $nick $+ 's 4stats are %mmx %mmy %mmz %mma $+(,$str($chr(124),2),) Assists: $calc($readini(MasterMind.ini,Assists,$address($nick,2)) + 0)))))
msg #  $+ $nick $+ 's 4stats are %mmb %mmc %mmd $+(,$str($chr(124),2),) Cheats: $calc($readini(MasterMind.ini,Cheats,$address($nick,2)) + 0)
}
}
else {
if ($readini(MasterMind.ini,Players,$address($2,2))) {
var %mmxa $readini(MasterMind.ini,4Wins,$address($2,2))
var %mmxb $readini(MasterMind.ini,4Fails,$address($2,2))
var %mmya $readini(MasterMind.ini,5Wins,$address($2,2))
var %mmyb $readini(MasterMind.ini,5Fails,$address($2,2))
var %mmza $readini(MasterMind.ini,6Wins,$address($2,2))
var %mmzb $readini(MasterMind.ini,6Fails,$address($2,2))
var %mmaa $readini(MasterMind.ini,7Wins,$address($2,2))
var %mmab $readini(MasterMind.ini,7Fails,$address($2,2))
var %mmba $readini(MasterMind.ini,8Wins,$address($2,2))
var %mmbb $readini(MasterMind.ini,8Fails,$address($2,2))
var %mmca $readini(MasterMind.ini,9Wins,$address($2,2))
var %mmcb $readini(MasterMind.ini,9Fails,$address($2,2))
var %mmda $readini(MasterMind.ini,10Wins,$address($2,2))
var %mmdb $readini(MasterMind.ini,10Fails,$address($2,2))
var %mmx 4: $calc(%mmxa) $+ : $+ $calc(%mmxb) $chr(40) $+ $round($calc(%mmxa / (%mmxa + %mmxb) * 100),2) $+ % W/L $+ $chr(41)
var %mmy $+(,$str($chr(124),2),) 5: $calc(%mmya) $+ : $+ $calc(%mmyb) $chr(40) $+ $round($calc(%mmya / (%mmya + %mmyb) * 100),2) $+ % W/L $+ $chr(41)
var %mmz $+(,$str($chr(124),2),) 6: $calc(%mmza) $+ : $+ $calc(%mmzb) $chr(40) $+ $round($calc(%mmza / (%mmza + %mmzb) * 100),2) $+ % W/L $+ $chr(41)
var %mma $+(,$str($chr(124),2),) 7: $calc(%mmaa) $+ : $+ $calc(%mmab) $chr(40) $+ $round($calc(%mmaa / (%mmaa + %mmab) * 100),2) $+ % W/L $+ $chr(41)
var %mmb 8: $calc(%mmba) $+ : $+ $calc(%mmbb) $chr(40) $+ $round($calc(%mmba / (%mmba + %mmbb) * 100),2) $+ % W/L $+ $chr(41)
var %mmc $+(,$str($chr(124),2),) 9: $calc(%mmca) $+ : $+ $calc(%mmcb) $chr(40) $+ $round($calc(%mmca / (%mmca + %mmcb) * 100),2) $+ % W/L $+ $chr(41)
var %mmd $+(,$str($chr(124),2),) 10: $calc(%mmda) $+ : $+ $calc(%mmdb) $chr(40) $+ $round($calc(%mmda / (%mmda + %mmdb) * 100),2) $+ % W/L $+ $chr(41)
msg #  $+ $2 $+ 's 4stats are %mmx %mmy %mmz %mma $+(,$str($chr(124),2),) Assists: $calc($readini(MasterMind.ini,Assists,$address($2,2)) + 0)))))
msg #  $+ $2 $+ 's 4stats are %mmb %mmc %mmd $+(,$str($chr(124),2),) Cheats: $calc($readini(MasterMind.ini,Cheats,$address($2,2)) + 0)
}
}
}
if ($1 == !peek) || ($1 == !assist) {
if (%mm. [ $+ [ $address($2,2) ] ]) && ($readini(MasterMind.ini,Players,$address($nick,2))) && ($2 != $nick) {
if (%mm. [ $+ [ $address($2,2) $+ [ .peek ] ] ]) { halt }
var %x %mm. [ $+ [ $address($2,2) ] ]
if (!$3) { notice $nick !peek <Nick> <1-length of code OR all>. eg. !peek askaninjask 5 or !peek dubulous all }
if ($3) {
var %y $numtok(%x,32)
if {$3 isnum 1 - $(%y)) {
if ($3 == all) {
notice $nick $2's code ends in $+(,$right($remove(%x,$chr(32)),$ceil($calc($numtok(%x,32) / 4))),) $+ . 1.0 has been added to your assists.
writeini MasterMind.ini Assists $address($nick,2) $calc($readini(MasterMind.ini,Assists,$address($nick,2)) + 1)
set %mm. [ $+ [ $address($2,2) $+ [ .peek ] ] ] 1
halt
}
notice $nick The $ord($3) letter of $2's code is $+(,$gettok(%x,$3,32),) $+ . 0.5 has been added to your assists.
writeini MasterMind.ini Assists $address($nick,2) $calc($readini(MasterMind.ini,Assists,$address($nick,2)) + 0.5)
set %mm. [ $+ [ $address($2,2) $+ [ .peek ] ] ] 1
}
}
}
}
if (%mm. [ $+ [ $address($nick,2) ] ]) {
if ($1 == !reset) {
set -u3 %mm.act. [ $+ [ $address($nick,2) ] ] 1
msg #  $+ Game over, $nick $+ . Game over.
writeini MasterMind.ini $+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Fails) $address($nick,2) $calc($readini(MasterMind.ini,$+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Fails),$address($nick,2)) + 1)
unset %mm.cheat. [ $+ [ $address($nick,2) ] ]
unset %mm. [ $+ [ $address($nick,2) $+ [ .peek ] ] ]
unset %mm. [ $+ [ $address($nick,2) ] ]
}
if ($1 == !cheat) && (!%mm.cheat [ $+ [ $address($nick,2) ] ]) { set -u1 %mm.act. [ $+ [ $address($nick,2) ] ] 1 | notice $nick %mm. [ $+ [ $address($nick,2) ] ] | set %mm.cheat. [ $+ [ $address($nick,2) ] ] 1 }
if ($1 == !infinite) && (!%mm.cheat [ $+ [ $address($nick,2) ] ]) { set -u1 %mm.act. [ $+ [ $address($nick,2) ] ] 1 | set %mm.guesses. [ $+ [ $address($nick,2) ] ] 999 | notice $nick %mm.guesses. [ $+ [ $address($nick,2) ] ] guesses | set %mm.cheat. [ $+ [ $address($nick,2) ] ] 1 }
if ($istok(!g !guess,$1,32)) && ($len($2) == $numtok(%mm. [ $+ [ $address($nick,2) ] ],32)) {
var %mmx /(r|b|g|y|p|o){ $+ $numtok(%mm. [ $+ [ $address($nick,2) ] ],32) $+ }/)
if ($regex($2,%mmx) == 1) {
var %t $numtok(%mm. [ $+ [ $address($nick,2) ] ],32)
tokenize 32 $tokenmaster($nick,$2-)
dec %mm.guesses. [ $+ [ $address($nick,2) ] ] 1
set -u1 %mm.act. [ $+ [ $address($nick,2) ] ] 1
if ($2- == %mm. [ $+ [ $address($nick,2) ] ]) {
var %t $numtok(%mm. [ $+ [ $address($nick,2) ] ],32)
var %w $iif(%t == 10,15,$iif(%t > 8,14,$iif(%t > 6,12,10)))
var %s $calc(%w - $(%mm.guesses. [ $+ [ $address($nick,2) ] ],2))
msg #  $+ Good job $nick $+ ! You cracked the code in $+(%s,/,%w) turns!
var %comtime $comtime($ticks,$(%ticks. [ $+ [ $address($nick,2) ] ]))
.notice $nick You finished in %comtime (m:s:ms)
if (%mm.cheat. [ $+ [ $address($nick,2) ] ]) { writeini MasterMind.ini Cheats $address($nick,2) $calc($readini(MasterMind.ini,Cheats,$address($nick,2)) + 1) }
writeini MasterMind.ini $+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Wins) $address($nick,2) $calc($readini(MasterMind.ini,$+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Wins),$address($nick,2)) + 1)
if (!%mm.cheat. [ $+ [ $address($nick,2) ] ]) && (!%mm. [ $+ [ $address($nick,2) $+ [ .peek ] ] ]) {
if (!$ini(MasterTime.ini,$+(%t,Time),0)) {
writeini MasterTime.ini $+(%t,Time) $address($nick,2) %comtime
}
else {
var %a $ini(MasterTime.ini,$+(%t,Time),1)
var %b $readini(MasterTime.ini,$+(%t,Time),$(%a))
if ($numtok(%comtime,58) < $numtok(%b,58)) {
remini MasterTime.ini $+(%t,Time)
writeini MasterTime.ini $+(%t,Time) $address($nick,2) %comtime
}
elseif ($numtok(%comtime,58) == $numtok(%b,58)) {
var %c $numtok(%b,58)
var %d 1
var %e %comtime
while (%d <= %c) {
if ($gettok(%e,%d,58) > $gettok(%b,%d,58)) { break }
if ($gettok(%e,%d,58) < $gettok(%b,%d,58)) {
remini MasterTime.ini $+(%t,Time)
writeini MasterTime.ini $+(%t,Time) $address($nick,2) %comtime
break
}
inc %d
}
}
}
}
unset %mm.cheat. [ $+ [ $address($nick,2) ] ]
unset %mm. [ $+ [ $address($nick,2) $+ [ .peek ] ] ]
unset %mm. [ $+ [ $address($nick,2) ] ]
unset %ticks. [ $+ [ $address($nick,2) ] ]
halt
}
var %mm.z %mm. [ $+ [ $address($nick,2) ] ]
if (%t == 10) { if ($gettok(%mm.z,10,32) == $11) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,10,32), %mm.j 1 } }
if ($istok(9 10,%t,32)) { if ($gettok(%mm.z,9,32) == $10) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,9,32), %mm.i 1 } }
if ($istok(8 9 10,%t,32)) { if ($gettok(%mm.z,8,32) == $9) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,8,32), %mm.h 1 } }
if ($istok(7 8 9 10,%t,32)) { if ($gettok(%mm.z,7,32) == $8) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,7,32), %mm.g 1 } }
if ($istok(6 7 8 9 10,%t,32)) { if ($gettok(%mm.z,6,32) == $7) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,6,32), %mm.f 1 } }
if ($istok(5 6 7 8 9 10,%t,32)) { if ($gettok(%mm.z,5,32) == $6) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,5,32), %mm.e 1 } }
if ($gettok(%mm.z,4,32) == $5) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,4,32), %mm.d 1 }
if ($gettok(%mm.z,3,32) == $4) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,3,32), %mm.c 1 }
if ($gettok(%mm.z,2,32) == $3) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,2,32), %mm.b 1 }
if ($gettok(%mm.z,1,32) == $2) { var %mm.x $calc(%mm.x + 1), %mm.z $deltok(%mm.z,1,32), %mm.a 1 }
if (%t == 10) {
if (!%mm.j) && ($11 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$11,$findtok(%mm.z,$11,0,32),32) }
}
if ($istok(9 10,%t,32)) {
if (!%mm.i) && ($10 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$10,$findtok(%mm.z,$10,0,32),32) }
}
if ($istok(8 9 10,%t,32)) {
if (!%mm.h) && ($9 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$9,$findtok(%mm.z,$9,0,32),32) }
}
if ($istok(7 8 9 10,%t,32)) {
if (!%mm.g) && ($8 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$8,$findtok(%mm.z,$8,0,32),32) }
}
if ($istok(6 7 8 9 10,%t,32)) {
if (!%mm.f) && ($7 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$7,$findtok(%mm.z,$7,0,32),32) }
}
if ($istok(5 6 7 8 9 10,%t,32)) {
if (!%mm.e) && ($6 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$6,$findtok(%mm.z,$6,0,32),32) }
}
if (!%mm.d) && ($5 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$5,$findtok(%mm.z,$5,0,32),32) }
if (!%mm.c) && ($4 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$4,$findtok(%mm.z,$4,0,32),32) }
if (!%mm.b) && ($3 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$3,$findtok(%mm.z,$3,0,32),32) }
if (!%mm.a) && ($2 isin %mm.z) { var %mm.y $calc(%mm.y + 1), %mm.z $remtok(%mm.z,$2,$findtok(%mm.z,$2,0,32),32) }
msg #  $+ $nick $+ : you guessed 00,01 $+ $replace($remove($2-,$chr(32)),r,04r,b,11b,g,09g,y,08y,p,06p,o,07o) $+ . You had 03 $+ $iif(%mm.x,%mm.x,0) $+  colours in the 09right spot && 04 $+ $iif(%mm.y,%mm.y,0) $+  colours in the 04wrong spot. You have  $+ $iif(%mm.guesses. [ $+ [ $address($nick,2) ] ],%mm.guesses. [ $+ [ $address($nick,2) ] ],0) $+  guesses remaining.
}
else { notice $nick !guess < $+ $numtok(%mm. [ $+ [ $address($nick,2) ] ],32) chars from rogypb>. Example: !guess $iif($numtok(%mm. [ $+ [ $address($nick,2) ] ],32) == 4,rbpy,$iif($numtok(%mm. [ $+ [ $address($nick,2) ] ],32) == 5,grypy,rgbbpo)) }
if (!%mm.guesses. [ $+ [ $address($nick,2) ] ]) {
msg #  $+ $nick $+ : you've run out of guesses without cracking the code. The code was 00,01 $+ $replace($remove(%mm. [ $+ [ $address($nick,2) ] ],$chr(32)),r,04r,b,11b,g,09g,y,08y,p,06p,o,07o) $+ .
writeini MasterMind.ini $+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Fails) $address($nick,2) $calc($readini(MasterMind.ini,$+($numtok(%mm. [ $+ [ $address($nick,2) ] ],32),Fails),$address($nick,2)) + 1)
unset %mm. [ $+ [ $address($nick,2) ] ]
unset %ticks. [ $+ [ $address($nick,2) ] ]
unset %mm. [ $+ [ $address($nick,2) $+ [ .peek ] ] ]
unset %mm.cheat. [ $+ [ $address($nick,2) ] ]
}
}
}
}
}
alias -l tokenmaster {
var %s $1
var %t $numtok(%mm. [ $+ [ $address(%s,2) ] ],32)
if (%t == 4) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1)
}
if (%t == 5) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1)
}
if (%t == 6) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1) $mid($2,6,1)
}
if (%t == 7) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1) $mid($2,6,1) $mid($2,7,1)
}
if (%t == 8) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1) $mid($2,6,1) $mid($2,7,1) $mid($2,8,1)
}
if (%t == 9) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1) $mid($2,6,1) $mid($2,7,1) $mid($2,8,1) $mid($2,9,1)
}
if (%t == 10) {
tokenize 32 !guess $mid($2,1,1) $mid($2,2,1) $mid($2,3,1) $mid($2,4,1) $mid($2,5,1) $mid($2,6,1) $mid($2,7,1) $mid($2,8,1) $mid($2,9,1) $mid($2,10,1)
}
return $1-
}

Comments

Sign in to comment.
Blitzjager   -  Feb 07, 2010
Updated. Was still kinda working on it but I'll be internetless for the next few weeks.
Hopefully everything works no matter the version. Either I was screwing something up or 6.17 interpreted 'all' as a number.
 Respond  
winni2   -  Apr 01, 2009
/if: '' unknown operator (line 3, master mind1)
 Respond  
Blitzjager   -  Mar 19, 2009
Yeah although I do have the nick in front of the message "nick: you guessed..."
I like the idea of decreasing the guesses but then people might have to wait 10 minutes.
I'm also going to add !turns(just another !stats but it will tell you your average turns to solve)

So I'll add turns and one game per channel hopefully sometime tomorrow.
 Respond  
MaxEvans   -  Mar 19, 2009
Wouldn't that get a bit confusing?
 Respond  
Kirby   -  Mar 19, 2009
What about adding a timer on it, so if you don't guess within a certain period of time, it uses up a guess. Just an idea. If you have a big channel, I'm sure too many people wouldn't want to wait for a long time for someone to make a guess.
Blitz's script only takes the address mask 2, so there can be multiple games in the same channel; so no timer is necessary.
 Respond  
MaxEvans   -  Mar 19, 2009
What about adding a timer on it, so if you don't guess within a certain period of time, it uses up a guess. Just an idea. If you have a big channel, I'm sure too many people wouldn't want to wait for a long time for someone to make a guess.
 Respond  
Blitzjager   -  Mar 15, 2009
Thanks.
I used to have it so that if you won after cheating it would only increase times cheated. I changed it so that it would count as both a win and a cheat. Forgot to remove a ! :S

Edit: Just made some small changes. (moved stuff around to stop * /notice: insufficient parameters)
Might've screwed something up.
 Respond  
Aucun50   -  Mar 15, 2009
I think there's an error:

<~Aucun> !cheat
<@Server> Good job Aucun! You cracked the code in 9/10 turns!
<~Aucun> !stats Aucun
<@Server> Aucun's stats for 4,5, and 6-colour Master Mind are 2:0 (100% W/L) || 0:0 (0% W/L) || 0:0 (0% W/L) || Cheats: 0
 Respond  
Prelude   -  Mar 15, 2009
9/10 BLITZ;p
 Respond  
The_Almighty_Duelist   -  Mar 15, 2009
it is a good game! i kinda made something like this, but in dialog form (so really only you can play it)... 8.0! ^_^
 Respond  
Kirby   -  Mar 15, 2009
One of my favorite "thinking" games, both in IRC and in real life.
As a tester + script suggester of this snippet, I have to say that this is very, very well made. And this is, surprisingly, a very difficult, challenging game.
What makes this special is that you can play multiple games in the same channel or in different channels; all it records is your address in mask 2 form.

Another great IRC game by Blitzjager.
/me rates 9.0.
 Respond  
Aucun50   -  Mar 15, 2009
Nice Script 8/10
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.