Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Your snake (You) is sent twice #5

Closed
exzizt opened this issue Feb 7, 2018 · 2 comments
Closed

Your snake (You) is sent twice #5

exzizt opened this issue Feb 7, 2018 · 2 comments

Comments

@exzizt
Copy link

exzizt commented Feb 7, 2018

From: battle-snake#31

Since this year your snake (You) is sent over as a Snake object (and not an id used to identify your snake in the Snakes list), I don't think it is necessary to send over your snake again in the Snakes list.

``interface World {
  object: 'world';
  id: number;
  you: Snake; # Your snake
  snakes: List<Snake>; # Contains your snake again
  height: number;
  width: number;
  turn: number;
  food: List<Point>;
}``

This is a minor optimization, but it will be removing redundancy and therefore reducing the size of the JSON string.

Edit: Maybe "snakes" could be called "other_snakes".

@robbles
Copy link

robbles commented Feb 8, 2018

It'll be easier to write logic that avoids snake bodies if your snake is kept in the list.

You do need to avoid your own body as well as the other snakes.

@daniel-swu
Copy link

Yeah you are correct this it is redundant, but it's also helpful, because you don't need to parse your own snake out of the list based on an id. Also we're not worried about the extra size in the payload, so we will be leaving this in for this year.

Again thanks for the issue, and keep bringing up anything you think of in relation to the server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants