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

Add isempty : cmd bool to check whether current cell has an entity #968

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Jan 6, 2023

As I've been playing around in classic mode I've found it a bit annoying/unbalanced that although you can use ishere : text -> cmd bool to check for the presence of a specific entity, the only way to check whether a cell is empty is to write something like

def is_empty : cmd bool =
  s <- scan down;
  return (s == inl ())
end

However, this requires having a comparator and an ADT calculator --- the latter in particular is quite difficult to construct. So, I propose adding a primitive isempty : cmd bool. Note this doesn't make scan useless --- it's more powerful still since it lets you find out the name of anything (even stuff not in the current cell).

An alternative might be to get rid of ishere as well (since it can also be programmed in terms of scan), but tons of obvious early-game automation (e.g. harvesting a tree plantation) depends on being able to have conditionals based on the presence or absence of certain entities, and it would be unreasonable to have that depend on making an ADT calculator.

The scanner now provides quite a few commands; I think that's OK but chime in if you think we ought to split it into multiple devices. I think it makes sense to have scan, ishere, and isempty all provided by scanner since it's just providing several interfaces to the same "service", one general and several simpler but easier-to-use versions. If we split anything out it could make sense to split out blocked (laser range finder, perhaps?) and/or upload.

@byorgey byorgey requested review from xsebek and kostmo January 6, 2023 14:20
@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Jan 6, 2023
@mergify mergify bot merged commit dd28529 into main Jan 6, 2023
@mergify mergify bot deleted the feature/isempty branch January 6, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants