• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
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 734 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.
  • M
    MisterBoring
    last edited by 3 Aug 2022, 21:37

    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

    R 1 Reply Last reply 3 Aug 2022, 22:20 Reply Quote 0
    • J
      Jennkryst
      last edited by 3 Aug 2022, 22:17

      This is Lizard Spock erasure.

      Mummy Pun? MUMMY PUN!
      She/her

      1 Reply Last reply Reply Quote 2
      • R
        Roz @MisterBoring
        last edited by 3 Aug 2022, 22:20

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

        she/her | playlist

        F 1 Reply Last reply 3 Aug 2022, 22:35 Reply Quote 1
        • F
          Faraday @Roz
          last edited by 3 Aug 2022, 22:35

          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
          • M
            Mourne
            last edited by 3 Aug 2022, 23:40

            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
            • S
              Solstice
              last edited by Solstice 8 Mar 2022, 23:49 3 Aug 2022, 23:44

              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.

              F 1 Reply Last reply 4 Aug 2022, 00:28 Reply Quote 2
              • F
                Faraday @Solstice
                last edited by Faraday 8 Apr 2022, 01:59 4 Aug 2022, 00:28

                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 4 Aug 2022, 00:57

                  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
                  • M
                    MisterBoring
                    last edited by 4 Aug 2022, 16:02

                    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

                    K 1 Reply Last reply 4 Aug 2022, 17:21 Reply Quote 0
                    • K
                      KarmaBum @MisterBoring
                      last edited by 4 Aug 2022, 17:21

                      @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
                      5 out of 10
                      • First post
                        5/10
                        Last post