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

Give view a limited broadcast range #17

Closed
byorgey opened this issue Sep 20, 2021 · 10 comments · Fixed by #1110
Closed

Give view a limited broadcast range #17

byorgey opened this issue Sep 20, 2021 · 10 comments · Fixed by #1110
Assignees
Labels
C-Moderate Effort Should take a moderate amount of time to address. G-Design An issue having to do with game design. 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 Sep 20, 2021

This issue used to be about adding an antenna entity to enable view, but see comments below for some reasons why I no longer think we should do that.

I'm thinking there can be an "Antenna" entity.

  • An antenna provides a broadcast capability, with a corresponding broadcast command.
  • Only robots (besides base) which have executed broadcast can be viewed with the view command.
  • The recipe for an antenna could involve, say, 5 copper wires, + maybe something else? Depends on how hard it should be to obtain early in the game. It would probably be pretty helpful for debugging etc. so probably shouldn't be too hard to get.
  • Perhaps later, an antenna can have a limited broadcast range, and there can be more difficult ways to craft more powerful antennas. But probably for a first crack we can just make antennas have an unlimited range.
@byorgey byorgey added Z-Feature A new feature to be added to the game. C-Low Hanging Fruit Ideal issue for new contributors. G-Design An issue having to do with game design. G-Entities An issue having to do with game entities. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. labels Sep 20, 2021
@Anrock
Copy link

Anrock commented Sep 26, 2021

Would also be nice to have API for antenna to allow some semi-autonomous robots maybe.

@byorgey
Copy link
Member Author

byorgey commented Sep 26, 2021

Hi @Anrock , thanks for the idea! However, I'm not sure I understand what you mean. What kind of API do you imagine? And can you explain what you mean by "semi-autonomous"?

@Anrock
Copy link

Anrock commented Sep 27, 2021

What kind of API do you imagine?

In Colobot there were "Exchange posts" buildings, where robots could store/retrieve info. API was basically a wrapper for string-string map, like store("topic", "some value", distance). When executed it would put "some value" as value for "topic" key in all exchange posts in distance radius. Same for retrieve command.

So if we replace "exchange post" with "any entity with antenna" that would go as API for swarm. Distance argument in Colobot was there since every robot had depletable battery and distance affected how much energy was spent for a broadcast, we can drop that since bots seems to have indefinite batteries in swarm.

Further improvement of API could include storing something more interesting than strings for values, for example scan data or functions. Some kind of callback/notification mechanism when some broadcast is received seems to be good to have too.

And can you explain what you mean by "semi-autonomous"?

If understand correctly, in Swarm once robot is built it will execute its program and there is no way to alter it or control robot dynamically. With antennas you can write something like that by broadcasting commands from base and writing an interpreter on bot side to execute those commands. Using base REPL it can be done interactively.

@byorgey
Copy link
Member Author

byorgey commented Sep 27, 2021

Ah, now I see what you mean. Yes, inter-robot communication is absolutely something we want! It should definitely require an antenna but probably more stuff as well. The antenna described in this issue is for a capability you should be able to get pretty early on, whereas inter-robot communication seems like a much more powerful feature that should only be obtained deeper into the game. Anyway, I've created a new issue to track this idea: #94.

@byorgey
Copy link
Member Author

byorgey commented Oct 8, 2021

Note, I think we need to implement #35 before we implement this. Without the initial use of the view command, it would be impossible to see and read about the devices that get automatically installed on robots.

@byorgey
Copy link
Member Author

byorgey commented Oct 8, 2021

For limited broadcast ranges, I had a fun idea: instead of just being a sharp cutoff at a specific distance, there could be a gradual falloff in signal strength, such that when you view a robot, the farther away it is, the fewer grid cells you can see. Like each grid cell has a probability of being visible, with the probability depending on the distance. Invisible grid cells would just be rendered as blank. So an antenna would have two critical distances d1 and d2: closer than distance d1, everything is visible with 100% probability; outside d2, cells are visible with 0% probability; between d1 and d2 the probability falls off according to some function. So if you view a robot and it is moving away from you, you would see your view of the world develop more and more "holes" or "static" until you finally can't see anything.

Concretely, for each cell we could generate a pseudorandom number which is a deterministic function of its coordinates, uniformly distributed between 0 and 1 (i.e. via some kind of hash function on the coordinates); we display the cell or not depending on how its number compares to the visibility probability. This means the pattern of visible and invisible cells would remain stable as the robot moves around etc. Or, if we want to simulate more dynamic "static", we could e.g. have a counter which goes up once per second or something like that, and include the current counter value as an input to the hash function along with the coordinates, so that the pattern changes every second (having the static pattern change every frame would probably be too much).

mergify bot pushed a commit that referenced this issue Oct 8, 2021
…e logs (#128)

The original main goals of this PR are to (1) solve #36 , that is, make the bottom-left info area fully wrapped and scrollable; and (2) solve #40 , that is, persist the info in that bottom-left info area even when switching to other panels.  In order to address those I ended up making a rather large constellation of related changes, which in the end I hope work well with each other.  Eager to hear others' feedback either from looking at the code or just trying out the game with this PR.

- In order to make the bottom-left area scrollable, split it out into its own panel.  Now we can focus it and then use normal keybindings to scroll it.
- The bottom-left info panel now indicates whether it has additional content scrolled off the top or bottom.
- The bottom-left panel used to display a global list of log/error messages when the inventory was not focused.  So where will those messages be viewable now, if the information displayed in the bottom-left panel persists?  My answer: there is a special `logger` device (#39) which, when focused, now displays the log messages.
    - This means that logs are now per-robot instead of global.
    - The base starts with a `logger` installed.
    - A `log` command can be used to write to a logger.
    - Uncaught exceptions also now write to a logger (instead of using `say`), or are simply discarded if there is no `logger` device installed.
    - The first time a robot's inventory is viewed after a message has been appended to its log, the `logger` device will be automatically focused and the log scrolled all the way to the bottom to show the new entry.  This means that e.g. typing `move` at the REPL will immediately show an exception in the lower left.
- Add a `salvage` command, making it possible to access the log of a dead robot after the fact, once we implement #17 .

There are still a few issues to address which I think can be done in separate PRs:

- The global message log still exists, and the `say` command still appends to it, but there is no way to view it.  Obviously we need to do something with this --- either get rid of it, or figure out a sensible way to view it, etc.
- Exception messages should probably be reformatted to not include any newlines, now that we know they will be wrapped.

Closes #36.  Closes #40.  Closes #39.  Closes #21.
@byorgey
Copy link
Member Author

byorgey commented Mar 16, 2022

I intentionally did not include this issue in the roadmap for an alpha release (https://github.com/orgs/swarm-game/projects/1) --- I don't think it's critical, and it would actually make the game harder. Perhaps we might consider having this be part of some kind of "hardcore" mode.

@byorgey byorgey added C-Moderate Effort Should take a moderate amount of time to address. and removed C-Low Hanging Fruit Ideal issue for new contributors. labels May 11, 2022
@byorgey byorgey changed the title Antenna entity + broadcast capability Give view a limited broadcast range Jun 27, 2022
@byorgey
Copy link
Member Author

byorgey commented Jun 27, 2022

So as of #483 we have a robot list panel. At this point I think we should just say that standard robot chassis have a basic antenna built in, and not require installing them separately for purposes of viewing robots in the list or executing view. However, I do still think view should have a range limit (just as the robot list does). And perhaps one can construct more powerful antennas to get a bigger range.

@byorgey byorgey removed the G-Entities An issue having to do with game entities. label Sep 24, 2022
@byorgey byorgey self-assigned this Feb 15, 2023
@byorgey
Copy link
Member Author

byorgey commented Feb 15, 2023

This is now the least-recently-edited issue, and also one of our oldest, and I think it shouldn't be too hard to tackle now. Here's my current plan: (1) make visibility drop off with distance when viewing. (2) When an antenna is installed somewhere, make the viewing range larger. Maybe installing an antenna on both the base and the robot being viewed makes the range even bigger than just having one antenna.

@kostmo
Copy link
Member

kostmo commented Feb 18, 2023

Terminology for reference: Fog of war

@mergify mergify bot closed this as completed in #1110 Mar 6, 2023
mergify bot pushed a commit that referenced this issue Mar 6, 2023
The basic principle here is that you cannot communicate with robots that are too far away.  We also want to uphold the principle that it is not possible to instantly communicate information over arbitrary distances.

Concretely, there is now an "inner radius" (16 by default) and an "outer radius" (64 by default).
* Inside of the inner radius, communication is perfect.
* Between the inner and outer radius, the `view` becomes increasingly covered with "static".
* Outside the outer radius, the view is completely static, *and* it is impossible to see a viewed robot's inventory.

In particular there should be absolutely no difference between trying to `view` a robot that is deceased vs a robot that is too far away.  A nice bonus feature is that if you are `view`ing a robot that is suddenly destroyed, e.g. by driving into the water, the entire view instantly turns to static, which looks cool.

The static is based on a hash of the offset from the view center to the cell + the current tick count / 16.  That means that the static pattern (1) doesn't shift when the viewed robot moves around, and (2) randomly changes every second or so.

[See this asciinema cast](https://asciinema.org/a/564988) for a demo of it in action.

Closes #17 .

- [x] update `antenna` description
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-Design An issue having to do with game design. 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.

3 participants