-
Notifications
You must be signed in to change notification settings - Fork 53
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
Getting references to already-built robots #506
Comments
Thanks for writing all this @byorgey 👍 I will have to think about this a bit, but the issue that strikes me with robot numbers is that they allow instantaneous communication. As a side note, I like how the proposed functions are pure, so why the cmd in |
Ah, very good point re: allowing instantaneous communication via robot numbers. Maybe we could use the
Just an oversight. I think I had |
So concretely, here's what I propose:
Edited to add: Well, once again I forgot about comments like #462 (comment) . I still think my above concrete suggestion is simple and will improve things, but I agree perhaps it is too god-like to know about all the robots ever built by anything that built you and so on. Maybe we should continue thinking about this. Or another approach might be to implement the above simple system but then refine it later with a more restricted "knowledge graph". |
@byorgey that sounds like an easy enough objective improvement. 👍 One slight wrinkle is that we do not currently have any pure functions to serve as predicates on robots, only Also, it would be great to have the robot IDs in the F2 panel so that I can view them more easily. 👀 |
Agreed! |
One potential issue is efficiency --- something specific like |
This is a problem that has been talked about in various places. This is intended to be a sort of omnibus issue bringing together all the previous discussions and also offering a concrete proposal.
The problem
There are lots of robots in the world, and sometimes you need to refer to them (in order to tell them to halt, to communicate with them, to
give
them something, to program another robot togive
them something, toview
them...). The status quo is "if you ever want to refer to a robot in the future, or even think you might, you must bind it to a variable at the REPL; otherwise you're out of luck". This is, of course, ridiculously limiting and annoying, for many reasons:We need a more general solution for referring to robots after the fact.
Related discussions/partial solutions
build
, and you wanted/intended to bind the result to a variable, but forgot. However, it doesn't really solve the problem (though it's a nice idea on its own merits and we should definitely implement it).itN
, but without being able to scroll the REPL panel you can only see the past few results.build
s multiple robots? What if you build a robot that builds other robots? In these cases you would never see the robot value printed at the REPL, so you would not know how to refer to them. I actually now think we should not implement a robot registry as described in "Robot registry" allowing access to built/known robots by index #462 , but something more general instead (see below).What robots do you "know about"?
I think in the past I had some kind of idea that you would be limited in the amount of information you would be able to get about other robots unless you had taken specific steps to remember them or be able to communicate with them. However, I'm coming to realize how utterly frustrating that can be, and in any case it doesn't seem to be the direction the game has been moving in. Of course, you can literally see all the robots in a top-down view; and now that we have the robots list view (F2), it is apparently possible for the base to receive signals from nearby robots with various basic status information. I love the robot list view and do not want it to go away, so we just have to figure out a consistent story to tell about it.
My current idea is to say that every robot chassis has a basic antenna built in (see #17), which it can use to communicate status information up to some radius (robot list view is 32). You should "know about", and thus be able to get status information updates from, and be able to get a reference to, any robots you built (transitively). Of course this does not include system robots or (in a multiplayer scenario) another player's robots.
What if you build two robots, call them A and B. Should robot A "know about" robot B, and vice versa? Well, sure, why not --- presumably they could send a request for information to the base. It's supposed to be a swarm of robots that all work together, right? 😄
System robots, of course, should "know about" all robots. Eventually, when we start adding other robots for you to interact with (representing e.g. animals, aliens, etc.) we might need more categories than just system/non-system robot, but we can deal with that when we come to it.
A general method for getting robot references
Since the robot list view implies that we can apparently find out lots of details about other robots through some basic communication, why not be able to use any of those details to select robots we want to reference?
Specifically, I propose adding a command something like
robotWhich : (robot -> bool) -> robot
.robotNamed
,robotNumbered
, etc. since it seemed like they would give you a god-like ability to get a reference to any robot. (See the discussion on Robot to name or id and back #343.) But of course they don't have to work that way. I think the idea of having them be partial functions, throwing an exception in the case of a "permissions error", solves this problem in a simple way.robotID : robot -> int
,hasID : int -> robot -> bool
,robotName : robot -> string
,hasName : string -> robot -> bool
, etc.hasXX
versions is so that you don't need to use acomparator
to implement them yourself in terms of the getters.robotNamed : string -> cmd robot
androbotNumbered : int -> cmd robot
no longer need to be restricted togod
capability, and in fact we could get rid of them altogether as primitives since they can just be implemented in terms ofrobotWhich
.robot index
device, or something of the sort (see "Robot registry" allowing access to built/known robots by index #462) provide therobotWhich
command, but this should be a default device / we should have a bunch of these devices to start (Starting base with a large but finite supply of basic robot parts #35).robot
, we can print it as e.g.robotWhich (hasID 45) : robot
. Or if that's too verbose we can providerobot : int -> robot = \i. robotWhich (hasID i)
as a primitive and printrobot 45 : robot
.We might also consider adding something like
robotsWhich : (robot -> bool) -> (robot -> b -> b) -> b -> b
which lets you fold over all robots you know about that satisfy a predicate.Related issues
Entities have a similar problem; see #455 for a discussion and links to related issues. Hopefully we may be able to use similar techniques there as well.
The text was updated successfully, but these errors were encountered: