Open ameenross opened 2 years ago
(Sorry for taking so long to respond, my repository notifications were apparently disabled)
This is the section of the code that calculates the score: https://github.com/phikal/ReGeX/blob/b2d3563f6528692d1cd8ab30c9293a0a7c7b6b99/app/src/main/java/com/phikal/regex/Utils/Calc.java#L38
There is nothing to understand, I just experimented with a few constants and functions to get something approximating a sensible score. What actually has to be done, is to parse the regular expression into a tree, then compare the size of the regular expression to the smallest expression (that should also be calculated beforehand), and using the difference to determine how many points you get for each problem.
the smallest expression (that should also be calculated beforehand)
That seems like a tough job in and of itself.
So what I understand from the code is this:
(charactersSaved / 2 + 1) * (gameDependentConstant + 3 * regexValue)
Where regexvalue is calculated by counting meta characters, and a \
counts for 2. So using meta characters positively influences the score, is that correct?
That seems like a tough job in and of itself.
The algorithms might be non-trivial, but is would essentially build a random regular expression depending on the difficulty, check if can be minimised, then use this to generate a number of words that are in and outside of the described language (again, the number and length depends on the level).
Is it just length? I notice sometimes that I get a score of 200+ for regex's that aren't particularly short, although I liked the solution better than a
[xyz].+
type solution. Is there any weight given to the use of certain solutions / meta characters in scoring?