Re: Extended PEMDAS.

2021-03-02 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Extended PEMDAS. You can use functions and classes in Python in any order, so long as you don't do it at the top level. Something like this is fine:def a(): return b() def b(): return 5It's only a problem with variables, and only in the context in which they are defined.  Even

Re: Extended PEMDAS.

2021-03-02 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Extended PEMDAS. @Chris Norman ok so this is pretty interesting. I became a little curious of what a parser combinator library API looks like in python, so I started reading the landing page for parsita and read the following paragraph"In a technique that I think is new to P

Re: Extended PEMDAS.

2021-03-02 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Extended PEMDAS. Yeah, a parser combinator lib might play well with mypy, as long as mypy etc. don't freak out at insane operator overloading and there's a type definition for it. URL: https://forum.audiogames.net/post/619440/#p619440 -- Audiogames-reflector mailing list

Re: Extended PEMDAS.

2021-03-01 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Extended PEMDAS. @12 I think you might be interested in trying out a parser combinator library. I haven't used any in python, but I have used them for Elm and Haskell, and they are totally non-magical and one of their major strengths is their strong typing, which really helps you

Re: Extended PEMDAS.

2021-03-01 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Extended PEMDAS. @12I can't find the docs on that quickly, but with Ply the tokens list is single quoted.  Are you sure that's not single quoted as well?I get where you're coming from on wanting this to play nice with things like mypy, but you won't get what you want if you go down

Re: Extended PEMDAS.

2021-03-01 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Extended PEMDAS. @8It's not the complexity I have an issue with, it's lines like:symbols = {lparent, rparent, plus, minux, multiply, divide}I'm not sure how they're doing it, but those entries aren't defined yet, so they should raise a syntax error.Also, ply uses docstrings to give you

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Extended PEMDAS. If you have 5d6 then you have to generate 5 uniformly distributed random integers between 1 and 6, then sum.  This isn't mathematically equivalent to generating an integer between 1 and 30 because reasons that I can't do the proof for offhand anymore and also it needs

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
Re: Extended PEMDAS. @9, that's actually a good point. So you're suggesting randomizing each seperately? Probably wouldn't be that big of a deal. URL: https://forum.audiogames.net/post/619111/#p619111 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Extended PEMDAS. Hey regarding the randomization of the dice result (that is using a random number between the minimum and maximum possible dice roll), you should avoid doing that. This is because it changes the probability distribution of the results.For example say you rolled 2d6

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Extended PEMDAS. Hey regarding the randomization of the dice result (that is using a random number between the minimum and maximum possible dice roll), you should avoid doing that. This is because it changes the probability distribution of the results.For example say you rolled 2d6

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Extended PEMDAS. You may wish to check these out:This is a really good intro on parsing. I know people suggest using external libraries, but I'd implement one myself first to see how it all works. You'll learn much more doing so.The next two chapters also may give insights into how

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
Re: Extended PEMDAS. @6Don't try to fork the parser libs until you've used them in anger, and understand why they're what they are.  They're as complicated as they are for a reason.@7If this is going to be needing order of operations and your resources don't discuss things like

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Extended PEMDAS. You may wish to check these out:This is a really good intro on parsing. I know people suggest using external libraries, but I'd implement one myself first to see how it all works. You'll learn much more doing so.The next two chapters also may give insights into how

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Extended PEMDAS. You may wish to check these out:This is a really good intro on parsing. I know people suggest using external libraries, but I'd implement one myself first to see how it all works. You'll learn much more doing so.The next two chapters also may give insights into how

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
Re: Extended PEMDAS. @3In Python land, there's also Ply or Sly. Personally, they provide too much magic for my liking, and I'm considering making my own fork to address that. It might work slightly better for the OP, since you're basically talking about a mini _expression_ language anyway

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Extended PEMDAS. Yeah, for this you could use a regular _expression_, but it would be hideously complex and difficult to understand, no matter how you wrote it. You'd definitely be better off writing a full parser/lexer at this point. Parse the input into an abstract syntax tree (AST

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : thggamer via Audiogames-reflector
Re: Extended PEMDAS. You can also use eval to evaluate an _expression_, but please validate your input to see if it contains only numbers because if you're not careful it can run untrusted code.For example:>>> eval('2 * 3')6 URL: https://forum.audiogames.net/post/618928

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Extended PEMDAS. I would say this enough complexity that regex doesn't quite cut it any more. I mean you could probably still do it with regex, but it would be a mess and hard to understand.for this you need to actually parse the input into an data structure that represents the overall

Re: Extended PEMDAS.

2021-02-28 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Extended PEMDAS. I would say this enough complexity that regex doesn't quite cut it any more. I mean you could probably still do it with regex, but it would be a mess and hard to understand.for this you need to actually parse the input into an data structure that represents the overall

Re: Extended PEMDAS.

2021-02-27 Thread AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector
Re: Extended PEMDAS. I feel like the easiest way to do this would be to just do the dice calculations first, replace them with numbers and do the equation as normal in that case. I don't know the regex off the top of my head for this, but you could make a regex that singles out a number

Extended PEMDAS.

2021-02-27 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
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