Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding definitions to the base before starting the scenario (e.g. to implement a DSL) #838

Open
kostmo opened this issue Nov 6, 2022 · 6 comments
Labels
C-Moderate Effort Should take a moderate amount of time to address. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). G-Robots An issue having to do with robots. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. S-Critical This is an issue that seriously affects playability or user experience. T-Challenges Involves the challenge scenarios - shorter games with objectives. Z-Feature A new feature to be added to the game.

Comments

@kostmo
Copy link
Member

kostmo commented Nov 6, 2022

These would be placed in the program field of a player's robot in a Scenario.

@kostmo kostmo added the Z-Feature A new feature to be added to the game. label Nov 6, 2022
@byorgey
Copy link
Member

byorgey commented Nov 6, 2022

To clarify, this is already supported in theory, but in practice it seems like attempting this leads to Fatal error: Reference to unknown memory cell 0, aka The Bug That Would Not Die: #299 #333 .

@byorgey byorgey added Bug The observed behaviour is incorrect or unexpected. C-Moderate Effort Should take a moderate amount of time to address. S-Critical This is an issue that seriously affects playability or user experience. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). T-Challenges Involves the challenge scenarios - shorter games with objectives. and removed Z-Feature A new feature to be added to the game. labels Nov 6, 2022
@byorgey
Copy link
Member

byorgey commented Nov 8, 2022

Fixed the bug, but now I realized there's another issue: solutions cannot use commands defined in the base program since solutions are parsed/typechecked in an empty context. Considering what a good solution to that would be. Options include (1) parse any base program first and make its context available when parsing/processing solution; (2) make a separate top-level scenario field called definitions which will consist of an arbitrary Swarm term (typically consisting of definitions). This would be similar to specifying a program for the base robot but maybe simpler to deal with/reason about if it is a distinguished top-level thing.

See the feature/base-defs branch.

mergify bot pushed a commit that referenced this issue Nov 8, 2022
Part of #838.  It should now work to specify a `program` for the base robot with definitions, which the player can subsequently use.  Unfortunately we still cannot *test* such a scenario since any `solution` is typechecked in an empty context instead of in a context generated by the base `program`.
@xsebek
Copy link
Member

xsebek commented Nov 9, 2022

@byorgey Is there a reason we can not just concatenate program and solution?

All normal bugs and limitations of swarm terms would of course apply, but I don’t see much benefit to solving them here separately. 🤷

@byorgey
Copy link
Member

byorgey commented Nov 9, 2022

You mean when checking the solution, we first just prepend any base program to the beginning of it (with a semicolon in between)? Yes, that would probably work, and is simpler (though perhaps more "hackish") than what I had in mind.

@xsebek
Copy link
Member

xsebek commented Nov 9, 2022

@byorgey Or we could do it after parsing and "concatenate" using the TBind. 🙂

@kostmo
Copy link
Member Author

kostmo commented May 30, 2023

This issue may overlap with #778.

@byorgey byorgey added G-Robots An issue having to do with robots. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. Z-Feature A new feature to be added to the game. and removed Bug The observed behaviour is incorrect or unexpected. labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. G-CESK machine This issue has to do with the CESK machine (the Swarm language interpreter). G-Robots An issue having to do with robots. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. S-Critical This is an issue that seriously affects playability or user experience. T-Challenges Involves the challenge scenarios - shorter games with objectives. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

3 participants