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

Commands to meet other robots #306

Closed
byorgey opened this issue Feb 16, 2022 · 7 comments · Fixed by #920
Closed

Commands to meet other robots #306

byorgey opened this issue Feb 16, 2022 · 7 comments · Fixed by #920
Assignees
Labels
C-Low Hanging Fruit Ideal issue for new contributors. G-Robots An issue having to do with robots. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Feature A new feature to be added to the game.

Comments

@byorgey
Copy link
Member

byorgey commented Feb 16, 2022

This is an idea that came out of the discussion on #212 . The basic version would be to have a command like meet : cmd (() + robot) which gives you a reference to another robot in the same cell as you (or perhaps up to a certain distance away), if there is one. With lists (see #97 and #154), there could also be some kind of meetAll : cmd (list robot).

@byorgey byorgey added Z-Feature A new feature to be added to the game. C-Low Hanging Fruit Ideal issue for new contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. labels Feb 16, 2022
@byorgey byorgey mentioned this issue Jun 18, 2022
@byorgey byorgey added G-Robots An issue having to do with robots. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. labels Jun 21, 2022
@byorgey
Copy link
Member Author

byorgey commented Jul 15, 2022

Instead of a function that returns a list, we could have a function that lets you fold over the robots nearby. This is just as good as having a list but without requiring any special data structures. Something like meetAll : (robot -> b -> b) -> b -> cmd b, or maybe meetAll : (robot -> b -> cmd b) -> b -> cmd b.

byorgey added a commit that referenced this issue Jul 15, 2022
Part of #306.  `meet : cmd (() + robot)` returns `inl ()` if no other
robot is on the same cell as you, and `inr r` if one of the other
robots is `r`.
@xsebek
Copy link
Member

xsebek commented Jul 18, 2022

@byorgey I like the second meetAll that takes the function (robot -> b -> cmd b).

I take it will not be possible to use it with atomic? 😄

@byorgey
Copy link
Member Author

byorgey commented Jul 18, 2022

@byorgey I like the second meetAll that takes the function (robot -> b -> cmd b).

Yes, I agree.

I take it will not be possible to use it with atomic? 😄

Haha, definitely not!

@byorgey
Copy link
Member Author

byorgey commented Oct 20, 2022

I had almost convinced myself that the version with robot -> b -> b is better, but after playing with things for a while I'm convinced that the robot -> b -> cmd b version is superior.

  • It is easy to implement the robot -> b -> b version in terms of the robot -> b -> cmd b version:
    def meetAllPure : (robot -> b -> b) -> b -> cmd b = \f. meetAll (\r. \b. return (f r b)) end
    
    Going the other direction is also possible but not as nice.
  • The version with cmd will often be convenient when you want to run some command for each nearby robot, e.g. give each one a bitcoin:
    def makeItRain : cmd unit = meetAll (\r. \b. give r "bitcoin") () end
    
  • The version with cmd is implicitly running the resulting commands in some particular order under the hood, but since it's going to iterate through the nearby robots in some arbitrary order anyway, you can't really complain about that.
  • If you want complete control over the order in which the resulting commands get run or anything more fancy, you can always use b = cmd unit. (You just might have to throw in a call to join or two.)

@byorgey byorgey self-assigned this Dec 15, 2022
@byorgey
Copy link
Member Author

byorgey commented Dec 21, 2022

Any ideas for what device could provide the meet capability? Currently I added it to scanner just to put it somewhere but scanner is already rather overloaded...

@xsebek
Copy link
Member

xsebek commented Dec 21, 2022

I would suggest something made out of mid game material like iron or silver.

  • shaky iron arm (for handshakes)
  • antenna (for communication)
  • radar (to scan around for robots)

@byorgey
Copy link
Member Author

byorgey commented Dec 21, 2022

Good idea. We've talked about adding antenna before for other things, so I added it. Current recipe is 2 silver + 2 copper wire but I'm open to other ideas.

@mergify mergify bot closed this as completed in #920 Dec 22, 2022
mergify bot pushed a commit that referenced this issue Dec 22, 2022
Closes #306. Closes #931.

- Renamed `robot` type to `actor` in anticipation of meeting other things besides robots.
- `meet : cmd (unit + actor)` returns an arbitrary actor within Manhattan distance 1, if any.
- `meetAll : (b -> actor -> cmd b) -> b -> cmd b` will run on every nearby actor.
- Added `antenna` device to provide the commands.
- Added "make a friend" challenge that requires the use of `meet`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Low Hanging Fruit Ideal issue for new contributors. G-Robots An issue having to do with robots. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants