Extended PEMDAS.

This has been a thought in the back of my mind for quite a while: I see Discord bots for dice rolling and such that have the advanced dicerolling, but also support the entirety of PEMDAS. I've sat down and tried to do it a few times, but I'm imagining this would take some RegEx and or Recursion skills that I definitely don't have. Let's take a few examples.

First, let's say that I pass in:
(1*8)*(3+3)**3
Solve all of the parenthases first, so the equation ends up to be:
8*6**3
In this instance, ** is exponent, so the equation then becomes:
8*216
And then, we solve, to 1728. It would be really funny if I totally did this all wrong. It's actually been a minute sense I've had to use that stuff.
Example 2: Original, but replace the original 1 with 2d6, which would mean 2 dice with six sides.
(2d6*8)*(3+3)**3
The difficulty here: I know how to do dice, just get a random number between amount of dice and amount * sides. The issue is how do we do all of this in a way that you can easily parse all of this. Let's just do the quick example, saying that 2d6 turned into 4.
(2d6*8)*(3+3)**3 =
32*216 =
6912
Any general logic will work if anyone wants to try their hand at this. My luck, it's super simple and I'm just dumb.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : thggamer via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector

Reply via email to