schlangenprogrammiernacht / gameserver

The part of SPN doing all the work
GNU Affero General Public License v3.0
9 stars 10 forks source link

Make x and y of IpcFoodInfo and IpcSegmentInfo useful #4

Open dobragab opened 3 years ago

dobragab commented 3 years ago

Before this change, x and y were given in "world orientation", meaning that they were translated to a coordinate system where the origin is the bot's head, but the x and y axes are parallel to the world coordinate's axes.

This basically rendered x and y useless, because nothing else is given in that coordinate system, and the bot has no idea about its own rotation.

Modify the values of x and y (i.e. rotate them) to match the coordinate system of all other values, i.e. where the y axis is the bot's direction.

Note: I didn't actually validate my changes, it's more of a discussion starter.

cfr34k commented 3 years ago

Thank you for your suggestion. Our idea behind x and y was to give the bot a fixed-orientation view of the world. The coordinate system is centered on the snake’s head and the axes are aligned with the world coordinate system.

Using these coordinates, the bot could, for example, determine whether it is moving upwards on the map (by comparing the x and y coordinates of its head and the following segments). Not sure how this would be useful, but we only provide the tools here, it is up to the players to use them to their advantage.

Note that the bot also receives polar coordinates relative to its heading: direction and distance. Here, dir=0 always means “straight ahead”. The bot can easily convert those into x and y coordinates relative to its heading.

So from my point of view, the information about the world orientation would be lost with heading-aligned x/y and no new information is gained.

Why do you think that the rotated coordinates would be more useful?