Brand MU Day
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Code Question: Rock, Paper, Scissors

    Scheduled Pinned Locked Moved Helping Hands
    10 Posts 8 Posters 729 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MisterBoringM
      MisterBoring
      last edited by

      So I brought up using OWoD LARP mechanics in a MU in another thread, and I had a question for the code savvy folks out there:

      How would you go about coding RPS into a MU?

      For an example, I want to play RPS with Mary.

      I should be able to do “RPS Mary” or “+RPS Mary” and get some output that looks like:

      You throw rock, paper, scissors with Mary. 
      You throw PAPER!
      Mary throws SCISSORS!
      You lose!
      

      Under the hood, in an effort to streamline the process, the game chooses an RPS value for both me and Mary at random, then figures out which one wins. If they are randomly the same, it’s declared a draw.

      Proud Member of the Pro-Mummy Alliance

      RozR 1 Reply Last reply Reply Quote 0
      • JennkrystJ
        Jennkryst
        last edited by

        This is Lizard Spock erasure.

        Mummy Pun? MUMMY PUN!
        She/her

        1 Reply Last reply Reply Quote 2
        • RozR
          Roz @MisterBoring
          last edited by

          @MisterBoring It might help to include what codebase/language you’re looking for!

          she/her | playlist

          FaradayF 1 Reply Last reply Reply Quote 1
          • FaradayF
            Faraday @Roz
            last edited by

            I’m confused. If you’re just going to draw straws at random, why not just do a coin flip or roll a die? A big part of RPS is the strategy of “oh they picked rock last time so I’ll pick scissors” or whatever.

            That would be more complicated because you’d need a command that would store state until both characters had entered their thing.

            1 Reply Last reply Reply Quote 2
            • MourneM
              Mourne
              last edited by

              You could have it be determined completely randomly, or, you could have it be that the controller has to set what they are going to throw before hand.

              1 Reply Last reply Reply Quote 0
              • SolsticeS
                Solstice
                last edited by Solstice

                I started typing it in pseudo code and got very tired because I am not a real coder.

                But yes. Store some variables and compare the results, or 1d3.

                FaradayF 1 Reply Last reply Reply Quote 2
                • FaradayF
                  Faraday @Solstice
                  last edited by Faraday

                  If you remove the strategy from RPS by just picking randomly (which, as stated previously, I wouldn’t recommend), there’s an equivalent chance of win, loss, or tie. So just rand(1,6) (or whatever the equivalent is in your codebase) and emit “You play rock paper scissors with Mary and <result>!” Win on 1-2, Lose on 3-4, and Tie on 5-6.

                  If you want strategy, then you need each player to enter the commands as a multi-part sequence:

                  • I do rps Mary=scissors and the system stores “scissors” for Faraday v Mary.
                  • Mary does rps Faraday=rock and the system recognizes that this is the second piece of the Faraday v Mary game.
                  • The system compares rock vs scissors and says Mary wins. There are only 9 possible scenarios so it’s not too involved to figure out the outcome.

                  How precisely you do this will of course vary by codebase.

                  1 Reply Last reply Reply Quote 2
                  • W
                    Warma Sheen
                    last edited by

                    Definitely don’t take the player option of of RPS, otherwise there’s no reason to use RPS. That would turn people away.

                    1 Reply Last reply Reply Quote 5
                    • MisterBoringM
                      MisterBoring
                      last edited by

                      Well, I’m most familiar with TinyMUX, with PennMUSH a close second, so those would be the ones I’d understand the quickest.

                      To @Faraday @Warma-Sheen : You do have a point about RPS strategy that I hadn’t considered, so perhaps having the command be a bit more interactive so that each player inputs their choice.

                      Also, @Jennkryst : That’s right, we don’t want your funny signs here. 😛

                      Proud Member of the Pro-Mummy Alliance

                      KarmaBumK 1 Reply Last reply Reply Quote 0
                      • KarmaBumK
                        KarmaBum @MisterBoring
                        last edited by

                        @MisterBoring said in Code Question: Rock, Paper, Scissors:

                        You do have a point about RPS strategy that I hadn’t considered, so perhaps having the command be a bit more interactive so that each player inputs their choice.

                        If it only ever runs one game at a time, you can run it so you rps <choice> and it creates a data attribute on an object. If you’re the first player, it stores your data and emits something about “waiting for 2nd player…”

                        If it already has one DATA-* attribute, then it knows you’re the second player, and it resolves the match, emits the resolution, and wipes the data.

                        If it already has two DATA-* attributes, then it is broken. 😄

                        On Dragon Wings · https://pern.gaslightswitch.com · pern.gaslightswitch.com port 4201

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post