-
Notifications
You must be signed in to change notification settings - Fork 557
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
Manhattan distance (see Wikipedia) #3
Comments
I'm never using Manhattan distance for the diagonal directions. I'm just creating a PVector from the snakes head and moving it in a certain angular direction until it reaches either the food, snake body or a wall. Once it reaches any of those obstacles I just record how many places it moved to reach it. There's no difference in how this distance is calculated for diagonal directions versus horizontal or vertical, the code is the same all that changes is the angular direction to move the vector. |
@greerviau Yes, I understood that. The point is that the snake is not allowed to move that way, so the distance is understated. Let's suppose there are 100 x 100 meter city-blocks in Manhattan, getting to the opposite corner [of a block] will take you 200 m to walk (as you cannot go through the city block), for a bird it will (if the skyscraper is not too high ;-) ) be 141 meter. |
I know the difference between Manhattan and euclidean distance, I still don't understand your point. The snake isn't limited on how it can move, it may seem that way because the evolution in the video didn't tend to attack the food from diagonals but that's just an evolutionary behavior, I've trained other versions that use a diagonal strategy. |
@greerviau Sure, I did not realize [and did not observe that in the video/gif] that you considered changing the 'rules' of snake (don't see what it has to do with evolution, though, classic snake does not move diagonally IIRC), in that case you're obviously right. |
There is a clear difference in probability that the snake approaches the food vertically or horizontally or diagonally. I think this difference is not due to how the distance is calculated. The diagonal distance, even if it is wrong, will still influence the snake. On the other hand, the snake can move towards its prey without leaving it from sight only in the horizontal and verticals. Diagonally, it is impossible for him to keep an eye on his food during the trip.If he wants the apple he sees in a diagonal, he is obliged to move horizontally or vertically and therefore loses the food of The solution is, I think to calculate the distance and the direction of the food even if it is not aligned. Two input neurons would then be enough instead of eight in the current version. (distance and heading) |
Two input neurons wouldn't be enough because the distance to the walls are also important for survival. But yes, I do agree that the location of the food should always be available as distance and bearing/heading. |
I'm talking about 2 neurons to find food, distance and bearing/heading instead of 8 (north, northeast, East, Southeast, South, southwest, west and northwest). Obviously the other neurons must remain, as well the 8 nessaire for the detection of the walls as well as the 8 for the detection of the tail of the oath. |
For the diagonal directions, it seems your distance calculation is wrong, it might be the correct distance as the crow flies, but you cannot walk like that in Manhattan (nor in Snake). The distance is the sum of the absolute differences of the x's and the y's (whether you go zig-zag or not makes no difference).
The text was updated successfully, but these errors were encountered: