jsyiek / AU2

GNU General Public License v3.0
0 stars 0 forks source link

Formula parser #31

Open jsyiek opened 2 weeks ago

jsyiek commented 2 weeks ago

Note: Only take this ticket if you experience in context-free grammars.

Problem: Umpires write different scoring formulae for open season each game. This has been done directly in a Python script, and while we could eval umpire code (what could go wrong?) I'd like to do this properly.

Requirements: A set of library code to (1) parse arbitrary arithmetic expressions (+ - / * ^) (2) recognize two dedicated variables (kills, conkers), (3) recognize arbitrary FP numbers (1.249, 581.2, etc.), and (4) to evaluate a parsed formula given the real values of kills and conkers. There are various CFGs online for this type of language (as a starting point, you could even use my Parallang grammar, but it doesn't support exponentiation). You should use pyparsing or equivalent.

NerdyNinja11 commented 2 days ago

If using attempt tracking, could have a third variable (attempts) to add a way of doing lent24 attempt points. + min(2, attempts//3)

jsyiek commented 2 days ago

If using attempt tracking, could have a third variable (attempts) to add a way of doing lent24 attempt points.

+ min(2, attempts//3)

I like the idea of including attempts. I might just include the // operator and the attempts variable though.