Straw picking game

By noMen on Jan 21, 2006

Load this snippet in your bot's remote and start the game with !straws. Your bot will hold 15 straws and you and the bot have to pick 1, 2 or 3 of them. You loose when you have to pick the last one. All instructions are in the game. You can stop the game before it has ended with !stopstraws. Beat it!

on *:TEXT:*:#channel: {
  if ($1 == !straws) && (!%strawleft) {
    set %strawleft 15
    msg # I have 15 straws; each one of us can take 1, 2 or 3 of them; you loose if you have to take the last one
    var %strawstart = $rand(0, 2)
    if (%strawstart == 0) {
      var %strawtaken = $calc((%strawleft - 1) % 4)
      dec %strawleft %strawtaken
      msg # I start and I take %strawtaken straw $+ $iif(%strawtaken > 1, s) $+ , %strawleft are left
      msg # Your turn, type !1, !2 or !3
    }
    elseif (%strawstart == 1) {
      msg # You may start, enter !1, !2 or !3
    }
    elseif (%strawstart == 2) {
      set %strawwho 1
      msg # Who is going to start: you (type !me) or me (type !you)
    }
  }
  elseif ($1 == !you) && (%strawleft == 15) {
    var %strawtaken = $calc((%strawleft - 1) % 4)
    dec %strawleft %strawtaken
    msg # I start and I take %strawtaken straw $+ $iif(%strawtaken > 1, s) $+ , %strawleft are left
    msg # Your turn, type !1, !2 or !3
    unset %strawwho
  }
  elseif ($1 == !me) && (%strawleft == 15) {
    msg # You want to start, enter !1, !2 or !3
    unset %strawwho
  }
  elseif (%strawleft) {
    if ($1 == !stopstraws) {
      unset %strawleft
      msg # Straw picking stopped
    }
    elseif ($left($1, 1) == !) && (!%strawwho) {
      if ($mid($1, 2) isnum 1-3) && ($mid($1, 2) <= %strawleft) {
        takestraw $mid($1, 2)
      }
      else {
        msg # Error, !1, !2 $iif(%strawleft > 2, or !3)
      }
    }
  }
}

alias takestraw {
  dec %strawleft $1
  msg # You took $1 straw $+ $iif($1 > 1, s) $+ , %strawleft $iif(%strawleft = 0, left and YOU LOOSE, $iif(%strawleft = 1, is left, are left))
  if (%strawleft == 0) {
    unset %strawleft
  }
  elseif (%strawleft == 1) {
    unset %strawleft
    msg # One left for me, YOU WIN!
  }
  else {
    var %strawtaken = $calc((%strawleft - 1) % 4) 
    if (%strawtaken == 0) {
      var %strawtaken = $rand(1, 3)
    }
    dec %strawleft %strawtaken
    msg # I take %strawtaken straw $+ $iif(%strawtaken > 1, s) $+ , %strawleft $iif(%strawleft = 1, is, are) left 
    if (%strawleft == 1) {
      unset %strawleft
      msg # One left for you, YOU LOOSE!
    }
    else {
      msg # Your turn, type !1, !2 $iif(%strawleft > 2, or !3)
    }
  }
}

Comments

Sign in to comment.
b0sse   -  Aug 30, 2009

Real nice, i remember this game from school when i was a kid :D

it would be neat if you could make it into 2 player game instead of against the bot.
can you do it?

 Respond  
wizard38   -  Oct 12, 2008

it don't work....

 Respond  
Conipto   -  Mar 09, 2007

This just plain doesn\'t work for me. Did you double check this script?

 Respond  
destind dule   -  Oct 28, 2006

it don\'t work for me :(

 Respond  
Sasuke   -  Jul 05, 2006

Never mind.

 Respond  
Sasuke   -  Jul 05, 2006

How does it work?

 Respond  
No0ne   -  Jan 26, 2006

Neat game.

 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.