{"action":"created","issue":{"url":"https://api.github.com/repos/ASPP/pelita/issues/398","repository_url":"https://api.github.com/repos/ASPP/pelita","labels_url":"https://api.github.com/repos/ASPP/pelita/issues/398/labels{/name}","comments_url":"https://api.github.com/repos/ASPP/pelita/issues/398/comments","events_url":"https://api.github.com/repos/ASPP/pelita/issues/398/events","html_url":"https://github.com/ASPP/pelita/issues/398","id":181896571,"number":398,"title":"Simulate next state","user":{"login":"DoriekeG","id":15670245,"avatar_url":"https://avatars.githubusercontent.com/u/15670245?v=3","gravatar_id":"","url":"https://api.github.com/users/DoriekeG","html_url":"https://github.com/DoriekeG","followers_url":"https://api.github.com/users/DoriekeG/followers","following_url":"https://api.github.com/users/DoriekeG/following{/other_user}","gists_url":"https://api.github.com/users/DoriekeG/gists{/gist_id}","starred_url":"https://api.github.com/users/DoriekeG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoriekeG/subscriptions","organizations_url":"https://api.github.com/users/DoriekeG/orgs","repos_url":"https://api.github.com/users/DoriekeG/repos","events_url":"https://api.github.com/users/DoriekeG/events{/privacy}","received_events_url":"https://api.github.com/users/DoriekeG/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-09T16:33:32Z","updated_at":"2016-10-09T17:15:46Z","closed_at":null,"body":"During the programming of our bot we ran into the problem that there was no method that would simulate a move for a player. @Debilski said that due to the way it is programmed, it is hard to simulate the next state completely (including food eaten etc). A very simple method in pelita.player which takes a move and returns the current position plus that move would already be a good step in the right direction, and this is easy to implement on the short-term. It would however save a lot of fuss with manually checking all things that change in the next state (position, whether bot is harvester, if food is eaten, points) if the entire next state is available. What do you think?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ASPP/pelita/issues/comments/252499028","html_url":"https://github.com/ASPP/pelita/issues/398#issuecomment-252499028","issue_url":"https://api.github.com/repos/ASPP/pelita/issues/398","id":252499028,"user":{"login":"Debilski","id":216179,"avatar_url":"https://avatars.githubusercontent.com/u/216179?v=3","gravatar_id":"","url":"https://api.github.com/users/Debilski","html_url":"https://github.com/Debilski","followers_url":"https://api.github.com/users/Debilski/followers","following_url":"https://api.github.com/users/Debilski/following{/other_user}","gists_url":"https://api.github.com/users/Debilski/gists{/gist_id}","starred_url":"https://api.github.com/users/Debilski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Debilski/subscriptions","organizations_url":"https://api.github.com/users/Debilski/orgs","repos_url":"https://api.github.com/users/Debilski/repos","events_url":"https://api.github.com/users/Debilski/events{/privacy}","received_events_url":"https://api.github.com/users/Debilski/received_events","type":"User","site_admin":false},"created_at":"2016-10-09T17:15:46Z","updated_at":"2016-10-09T17:15:46Z","body":"Simulating a move is roughly possible already, if you make a copy of the universe before setting the next move:\r\n\r\n    # .. in some AbstractPlayer subclass\r\n    def get_move():\r\n        uni = self.current_uni.copy()\r\n        uni.move_bot(self._index, test_move)\r\n        # if test_move eats a food pellet or kills an enemy,\r\n        # uni will have changed accordingly\r\n\r\nThe problem is of course, that all the helper methods in AbstractPlayer will not work anymore so that you will have to use the Universe methods directly.\r\n\r\nBut you’re right that we could should possibly add something like this as a helper to AbstractPlayer:\r\n\r\n    def simulate_move(self, move):\r\n        uni = self.current_uni.copy()\r\n        new_state = uni.move_bot(self._index, test_move)\r\n        return (new_state, universe)\r\n\r\nOr, we just get around to finally implementing #52.\r\n\r\n---\r\n\r\nThis may be a little far out but I wonder if we could also have the following syntax working:\r\n\r\n    def get_move(self):\r\n        move = ... # some_move\r\n        with self.simulated_move(move) as moved_self:\r\n            # moved_self is now self but at the new position\r\n            if len(moved_self.enemy_food) < len(self.enemy_food):\r\n                # seems like we ate something. let’s accept this move\r\n                return move\r\n\r\nWon’t probably work in the general case though unless we drop inheritance."}}
{"actor":{"display_login":"Debilski"}}