It's a simple little application that solves any basic expression that contains variables. I created this with video game algorithms in mind. I figured that this may be useful for people who want to use a certain algorithm to calculate the success of an attack, etc. However, considering my limited knowledge in Love2D and Lua in general, this file is an unoptimized mess. The way it does its job is also pretty horrible:
1. Store a formula into a string
2. Separate each constant and symbol and fit them (in order) into a table by reading each character's byte code.
3. Find the positions for each variable.
4. Ask the user to enter a number for each variable in the formula.
5. Using the positions of the variables in the formula, replace the variables in the table one by one with the inputs.
6. Combine the table into a string.
7. Turn the string into a number and solve it.
Because of this process, each variable is independent. Which means that in "2X+X", the X's are separate and you must enter a value for each one. Other things to note is the the variables have to be capital letters, since I didn't tell the program to check for their byte codes (because I can't find a dang chart or list for their byte codes).
I would very much appreciate it if you guys could help me with optimizing this application. Any other feedback is also appreciated. Thanks.
P.S. Bonus points to those who know where the first algorithm in the application is from.
P.S.S. Does anybody know why the text you input seems to be getting thicker each time it asks you to input a number?
Basic Formula Solver
Basic Formula Solver
- Attachments
-
- formulasolver.love
- (1.03 KiB) Downloaded 132 times
Who is online
Users browsing this forum: No registered users and 1 guest