Monty Hall Game

By Vegito on Nov 01, 2013

Type !play to start the game.
You will be asked to choose between !door1, !door2 and !door3. Behind one of the doors is a car other two contain goats.
When you've picked a door host will open a door which always contains a goat.
Then you will be asked if you want to !swap from door or !stay to stick with your first choice.

on *:TEXT:*:#: {
  if ($1 = !play) {
    hmake $nick
    hadd $nick prize $r(1,3)
    msg # 12There's 04 $+ 3 doors 12and behind one of these doors is a car!
    msg # 12Make your selection: 04!door1, 04!door2, or 04!door3 $+ 12.
  }
  if ($regex($1,/^!door(1|2|3)$/Si)) && !$hget($nick, door) {
    hadd $nick getDoor $hget($nick, prize) 
    hadd $nick door $regml(1)
    while (($hget($nick, getDoor) = $hget($nick, prize)) || ($hget($nick, getDoor) = $hget($nick, door))) { hadd $nick getDoor $r(1,3) }
    msg # 12Host opens 4door $hget($nick, getDoor) 12and reveals a goat! Do you want to 4!switch 12or 4!stay $+ 12.
  }
  if ($regex($1,/^!s(witch|tay)$/Si)) && !$hget($nick, switch) {
    if ($regml(1) = witch) {
      hadd $nick switch $hget($nick, door)
      while (($hget($nick, switch) = $hget($nick, door)) || ($hget($nick, switch) = $hget($nick, getDoor))) { hadd $nick switch $r(1,3) }
      hadd $nick door $hget($nick, switch)
    }
    msg # 04 $+ $nick 12won a 4 $+ $iif($hget($nick, door) = $hget($nick, prize),CAR,GOAT) 
    hfree $nick
  }
}

Comments

Sign in to comment.
Arigateaux   -  Nov 01, 2013

You need to get rid of lines 6, 12, and 19 since they're your debug lines. There's also a bug where it will sometimes open a door you pick.

Image
Image

Vegito  -  Nov 02, 2013

Haha, right I forgot to remove them.

Ok I also fixed bug.
Now host won't open same door you choose.

Sign in to comment

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.