{"action":"created","issue":{"url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/24","labels_url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/24/comments","events_url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/24/events","html_url":"https://github.com/ayai-ai/ayai-backend/pull/24","id":73752051,"number":24,"title":"Implement A* pathfinding","user":{"login":"roryokane","id":79168,"avatar_url":"https://avatars.githubusercontent.com/u/79168?v=3","gravatar_id":"","url":"https://api.github.com/users/roryokane","html_url":"https://github.com/roryokane","followers_url":"https://api.github.com/users/roryokane/followers","following_url":"https://api.github.com/users/roryokane/following{/other_user}","gists_url":"https://api.github.com/users/roryokane/gists{/gist_id}","starred_url":"https://api.github.com/users/roryokane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roryokane/subscriptions","organizations_url":"https://api.github.com/users/roryokane/orgs","repos_url":"https://api.github.com/users/roryokane/repos","events_url":"https://api.github.com/users/roryokane/events{/privacy}","received_events_url":"https://api.github.com/users/roryokane/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-06T22:12:09Z","updated_at":"2015-05-16T21:26:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ayai-ai/ayai-backend/pulls/24","html_url":"https://github.com/ayai-ai/ayai-backend/pull/24","diff_url":"https://github.com/ayai-ai/ayai-backend/pull/24.diff","patch_url":"https://github.com/ayai-ai/ayai-backend/pull/24.patch"},"body":"The code compiles but does not pass all of the new tests like this. I still have more work to do.\r\n\r\nThe actual `AStarPathfinder` class is, I think, complete. It’s the glue code that I’m still working on.\r\n\r\nI have made the design more complex by adding abstractions for the different possible ways to move on a grid: only horizontally and vertically, diagonally too, or diagonally but not allowing cutting through walls on corners. Those are the `GridMovementStyle`s, each of which contains an appropriate `DistanceHeuristic` and `NeighboringPositionFinder` for that style of movement. I needed a wrapper class because two movement styles share the same `DistanceHeuristic` but have different `NeighboringPositionFinder`s.\r\n\r\nMy next steps are implementing my TODO comments in [`NeighboringPositionFinder.scala`](https://github.com/ayai-ai/ayai-backend/blob/implement-pathfinder/src/main/scala/ayai/components/pathfinding/NeighboringPositionFinder.scala#L26-L38):\r\n\r\n> ```scala\r\n}).filterNot(position => ??? /* map(position) == NodeState.IMPASS */)\r\n```\r\n> \r\n> * Should this take a map or a graph?\r\n> * I do want to be able to look up the position just by a `Position`. That means it should define `apply()`.\r\n> * But I can't use the `NodeMatrixGraphView` view for that, because that needs to call this to find neighbors.\r\n> * So the object with an `apply()` definition will need to be an intermediate value between an `Array[Array[Node]]` and a `NodeMatrixGraphView`.\r\n> * I think I will make a `NodeMatrix` class, and make `GraphFactory` return it.\r\n> * There is one thing to check before I do: is it okay that we use `Position`s to index the grid? `GraphFactory` seems to avoid it, but I’m not sure whether that is because they thought it would be confusing to convert scaled positions to unscaled positions, or because a `Position` is only supposed to represent something specific to the game map, and should not be generic.\r\n> * Look at the places `Position` is used in the code to see if it is ever used differently,\r\nor if there are any comments saying not to.\r\n"},"comment":{"url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/comments/102699697","html_url":"https://github.com/ayai-ai/ayai-backend/pull/24#issuecomment-102699697","issue_url":"https://api.github.com/repos/ayai-ai/ayai-backend/issues/24","id":102699697,"user":{"login":"chrisbenincasa","id":1640671,"avatar_url":"https://avatars.githubusercontent.com/u/1640671?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisbenincasa","html_url":"https://github.com/chrisbenincasa","followers_url":"https://api.github.com/users/chrisbenincasa/followers","following_url":"https://api.github.com/users/chrisbenincasa/following{/other_user}","gists_url":"https://api.github.com/users/chrisbenincasa/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisbenincasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisbenincasa/subscriptions","organizations_url":"https://api.github.com/users/chrisbenincasa/orgs","repos_url":"https://api.github.com/users/chrisbenincasa/repos","events_url":"https://api.github.com/users/chrisbenincasa/events{/privacy}","received_events_url":"https://api.github.com/users/chrisbenincasa/received_events","type":"User","site_admin":false},"created_at":"2015-05-16T21:26:36Z","updated_at":"2015-05-16T21:26:36Z","body":"So..from what I can tell, the server only sends JSON messages to the front-end in certain situations (initialization, room switch, etc). It looks like to get pathfinding to work, we'd have to setup a new message that gets sent over the WebSocket from the server to the client which indicates that the NPC should begin following a path. "}}