Closed kostmo closed 1 year ago
symbol count
Or number of AST nodes.
Personally, I enjoy trying to optimize character count, but tastes vary.
trying to optimize character count
That can be fun, but I think there's more challenge in crafting a parsimonious program structure than shrinking variable names. I recognize appeal of finding out in which circumstances whitespace or semicolons are optional as well.
Perhaps we can track both AST node count and character count as metrics?
Perhaps we can track both AST node count and character count as metrics?
Sure, why not? :smile: I agree, both are fun for different reasons. One is about finding elegant program structures, as you say, and one is about pushing a language to its limits.
This sounds fun and should be easy to add to current best score. đź‘Ť
I think it needs an “automated mode” where you can not cancel your solution and start writing in REPL. 🤔 Once that computation finishes you have either won or failed (new state) and can leave or continue experimenting, now with REPL.
I think it needs an “automated mode” where you can not cancel your solution and start writing in REPL.
I don't think I understand - what's the motivation?
@byorgey well if you could continue in REPL, then an empty solution would be always shortest and then just finish it in REPL.
I thought the idea was to count all things typed at the REPL plus anything run.
But that way its always more efficient to type in REPL and step through.
For example the sheep solution would not have to wait for wool to drop, if the player waits for it.
I.e. the “solution” would not have to be full, which is OK, but different from other code golf challenges.
Also if you wanted to count REPL, you would have to do it at each command because of run
.
Counting once is much simpler and would not litter the codebase.
Ah, I think I see your point now. It's also harder to share short solutions if they require typing multiple things at the REPL. I agree, to keep things simple and consistent we should probably just score a single .sw
file (+ transitive imports) when counting length.
Perhaps for now, one shall only be qualified for code golf scoring when using the --run
CLI option. Any repl commands entered before the goal is reached shall disqualify the attempt.
Maybe we could allow either —run
or one REPL entry. 🤔
Then we could have states NoEntry, EntryWithLength and MoreEntries. If you finish the game with second state, it’s considered for shortest solution.
I wonder if it might be interesting to have constraints on the "stored code size" of a robot for a challenge. Perhaps by default all built robots have an "infinite memory bank", but we could define a "finite memory bank" entity. Perhaps possessing many of these entities avails the robot to some multiple of AST nodes.
It would be fun to keep track of the "best" solution in terms of code size.
The code size might be determined by summing all of the REPL executions plus all transitive inclusions of code (
include
orrun
).To discourage short variable names, it may be best to use "symbol count" rather than "character count" as the metric.