{"action":"created","comment":{"url":"https://api.github.com/repos/marmelab/quarto-go/pulls/comments/194452567","pull_request_review_id":127623738,"id":194452567,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDQ1MjU2Nw==","diff_hunk":"@@ -0,0 +1,82 @@\n+package game\n+\n+const GridSize = 4\n+\n+// State define data for a game state\n+type State struct {\n+\tGrid  [GridSize][GridSize]int\n+\tPiece int\n+}\n+\n+// DoAMove return the next move for given grid\n+func DoAMove(state State) State {\n+\n+\tstate = PlacePieceOnGrid(state)\n+\tstate = ChooseNewPiece(state)\n+\treturn state\n+}\n+\n+// PlacePieceOnGrid add the \"Piece\" id in an empty place of the Grid array\n+func PlacePieceOnGrid(state State) State {\n+    if state.Piece > 0 {\n+        for i := 0; i < GridSize; i++ {\n+            for j := 0; j < GridSize; j++ {\n+                if state.Grid[i][j] == 0 {\n+                    state.Grid[i][j] = state.Piece\n+                    state.Piece = 0\n+                    return state\n+                }\n+            }\n+        }\n+    }\n+\treturn state\n+}\n+\n+// ChooseNewPiece select a new piece for opponent\n+func ChooseNewPiece(state State) State {\n+\tstate.Piece = InitListOfRemainingPieces(state)[0]\n+\treturn state\n+}\n+\n+// InitListOfRemainingPieces generate a list of pieces not already in the grid\n+func InitListOfRemainingPieces(state State) []int {\n+\tvar piecesList = InitListOfAllPieces(state)\n+\n+\tfor i := 0; i < GridSize; i++ {\n+\t\tfor j := 0; j < GridSize; j++ {\n+\t\t\tvar index = indexOf(piecesList, state.Grid[i][j])\n+\t\t\tif index >= 0 {\n+\t\t\t\tpiecesList = append(piecesList[:index], piecesList[index+1:]...)\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn piecesList\n+}\n+\n+// InitListOfAllPieces generate a list of all pieces\n+func InitListOfAllPieces(state State) []int {\n+\tvar piecesList []int\n+\tfor i := 0; i < GridSize*GridSize; i++ {\n+\t\tpiecesList = append(piecesList, i+1)\n+\t}\n+\treturn piecesList\n+}\n+\n+func contains(s []int, e int) bool {","path":"src/quarto/game/game.go","position":66,"original_position":66,"commit_id":"95897011f0c903415e8b1222283849ce79c7e660","original_commit_id":"95897011f0c903415e8b1222283849ce79c7e660","user":{"login":"Kmaschta","id":1819833,"node_id":"MDQ6VXNlcjE4MTk4MzM=","avatar_url":"https://avatars2.githubusercontent.com/u/1819833?v=4","gravatar_id":"","url":"https://api.github.com/users/Kmaschta","html_url":"https://github.com/Kmaschta","followers_url":"https://api.github.com/users/Kmaschta/followers","following_url":"https://api.github.com/users/Kmaschta/following{/other_user}","gists_url":"https://api.github.com/users/Kmaschta/gists{/gist_id}","starred_url":"https://api.github.com/users/Kmaschta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kmaschta/subscriptions","organizations_url":"https://api.github.com/users/Kmaschta/orgs","repos_url":"https://api.github.com/users/Kmaschta/repos","events_url":"https://api.github.com/users/Kmaschta/events{/privacy}","received_events_url":"https://api.github.com/users/Kmaschta/received_events","type":"User","site_admin":false},"body":"Is the `contains` function really a method for the game package only ?","created_at":"2018-06-11T15:46:23Z","updated_at":"2018-06-11T15:46:47Z","html_url":"https://github.com/marmelab/quarto-go/pull/2#discussion_r194452567","pull_request_url":"https://api.github.com/repos/marmelab/quarto-go/pulls/2","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/comments/194452567"},"html":{"href":"https://github.com/marmelab/quarto-go/pull/2#discussion_r194452567"},"pull_request":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/marmelab/quarto-go/pulls/2","id":193932772,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzOTMyNzcy","html_url":"https://github.com/marmelab/quarto-go/pull/2","diff_url":"https://github.com/marmelab/quarto-go/pull/2.diff","patch_url":"https://github.com/marmelab/quarto-go/pull/2.patch","issue_url":"https://api.github.com/repos/marmelab/quarto-go/issues/2","number":2,"state":"open","locked":false,"title":"[WIP] first route ","user":{"login":"JulienMattiussi","id":39904906,"node_id":"MDQ6VXNlcjM5OTA0OTA2","avatar_url":"https://avatars2.githubusercontent.com/u/39904906?v=4","gravatar_id":"","url":"https://api.github.com/users/JulienMattiussi","html_url":"https://github.com/JulienMattiussi","followers_url":"https://api.github.com/users/JulienMattiussi/followers","following_url":"https://api.github.com/users/JulienMattiussi/following{/other_user}","gists_url":"https://api.github.com/users/JulienMattiussi/gists{/gist_id}","starred_url":"https://api.github.com/users/JulienMattiussi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulienMattiussi/subscriptions","organizations_url":"https://api.github.com/users/JulienMattiussi/orgs","repos_url":"https://api.github.com/users/JulienMattiussi/repos","events_url":"https://api.github.com/users/JulienMattiussi/events{/privacy}","received_events_url":"https://api.github.com/users/JulienMattiussi/received_events","type":"User","site_admin":false},"body":"https://trello.com/c/DvunvRew\r\n\r\nServer can start and wait calls on a given port.\r\nTests in progress","created_at":"2018-06-11T10:07:57Z","updated_at":"2018-06-11T15:46:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c64ccaa98ecbe68c082fe0243fdc7e18a57a715c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/marmelab/quarto-go/pulls/2/commits","review_comments_url":"https://api.github.com/repos/marmelab/quarto-go/pulls/2/comments","review_comment_url":"https://api.github.com/repos/marmelab/quarto-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marmelab/quarto-go/issues/2/comments","statuses_url":"https://api.github.com/repos/marmelab/quarto-go/statuses/95897011f0c903415e8b1222283849ce79c7e660","head":{"label":"marmelab:mainfunction","ref":"mainfunction","sha":"95897011f0c903415e8b1222283849ce79c7e660","user":{"login":"marmelab","id":3116319,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMTYzMTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3116319?v=4","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"repo":{"id":136892741,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY4OTI3NDE=","name":"quarto-go","full_name":"marmelab/quarto-go","owner":{"login":"marmelab","id":3116319,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMTYzMTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3116319?v=4","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marmelab/quarto-go","description":"Quarto game API in go","fork":false,"url":"https://api.github.com/repos/marmelab/quarto-go","forks_url":"https://api.github.com/repos/marmelab/quarto-go/forks","keys_url":"https://api.github.com/repos/marmelab/quarto-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marmelab/quarto-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marmelab/quarto-go/teams","hooks_url":"https://api.github.com/repos/marmelab/quarto-go/hooks","issue_events_url":"https://api.github.com/repos/marmelab/quarto-go/issues/events{/number}","events_url":"https://api.github.com/repos/marmelab/quarto-go/events","assignees_url":"https://api.github.com/repos/marmelab/quarto-go/assignees{/user}","branches_url":"https://api.github.com/repos/marmelab/quarto-go/branches{/branch}","tags_url":"https://api.github.com/repos/marmelab/quarto-go/tags","blobs_url":"https://api.github.com/repos/marmelab/quarto-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marmelab/quarto-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marmelab/quarto-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/marmelab/quarto-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marmelab/quarto-go/statuses/{sha}","languages_url":"https://api.github.com/repos/marmelab/quarto-go/languages","stargazers_url":"https://api.github.com/repos/marmelab/quarto-go/stargazers","contributors_url":"https://api.github.com/repos/marmelab/quarto-go/contributors","subscribers_url":"https://api.github.com/repos/marmelab/quarto-go/subscribers","subscription_url":"https://api.github.com/repos/marmelab/quarto-go/subscription","commits_url":"https://api.github.com/repos/marmelab/quarto-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/marmelab/quarto-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/marmelab/quarto-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/marmelab/quarto-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/marmelab/quarto-go/contents/{+path}","compare_url":"https://api.github.com/repos/marmelab/quarto-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marmelab/quarto-go/merges","archive_url":"https://api.github.com/repos/marmelab/quarto-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marmelab/quarto-go/downloads","issues_url":"https://api.github.com/repos/marmelab/quarto-go/issues{/number}","pulls_url":"https://api.github.com/repos/marmelab/quarto-go/pulls{/number}","milestones_url":"https://api.github.com/repos/marmelab/quarto-go/milestones{/number}","notifications_url":"https://api.github.com/repos/marmelab/quarto-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marmelab/quarto-go/labels{/name}","releases_url":"https://api.github.com/repos/marmelab/quarto-go/releases{/id}","deployments_url":"https://api.github.com/repos/marmelab/quarto-go/deployments","created_at":"2018-06-11T07:53:01Z","updated_at":"2018-06-11T08:49:18Z","pushed_at":"2018-06-11T15:34:27Z","git_url":"git://github.com/marmelab/quarto-go.git","ssh_url":"git@github.com:marmelab/quarto-go.git","clone_url":"https://github.com/marmelab/quarto-go.git","svn_url":"https://github.com/marmelab/quarto-go","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"Makefile","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"marmelab:master","ref":"master","sha":"555f27cd566e3cfe78e213706de8dcf0f4941608","user":{"login":"marmelab","id":3116319,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMTYzMTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3116319?v=4","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"repo":{"id":136892741,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY4OTI3NDE=","name":"quarto-go","full_name":"marmelab/quarto-go","owner":{"login":"marmelab","id":3116319,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMTYzMTk=","avatar_url":"https://avatars1.githubusercontent.com/u/3116319?v=4","gravatar_id":"","url":"https://api.github.com/users/marmelab","html_url":"https://github.com/marmelab","followers_url":"https://api.github.com/users/marmelab/followers","following_url":"https://api.github.com/users/marmelab/following{/other_user}","gists_url":"https://api.github.com/users/marmelab/gists{/gist_id}","starred_url":"https://api.github.com/users/marmelab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marmelab/subscriptions","organizations_url":"https://api.github.com/users/marmelab/orgs","repos_url":"https://api.github.com/users/marmelab/repos","events_url":"https://api.github.com/users/marmelab/events{/privacy}","received_events_url":"https://api.github.com/users/marmelab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marmelab/quarto-go","description":"Quarto game API in go","fork":false,"url":"https://api.github.com/repos/marmelab/quarto-go","forks_url":"https://api.github.com/repos/marmelab/quarto-go/forks","keys_url":"https://api.github.com/repos/marmelab/quarto-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marmelab/quarto-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marmelab/quarto-go/teams","hooks_url":"https://api.github.com/repos/marmelab/quarto-go/hooks","issue_events_url":"https://api.github.com/repos/marmelab/quarto-go/issues/events{/number}","events_url":"https://api.github.com/repos/marmelab/quarto-go/events","assignees_url":"https://api.github.com/repos/marmelab/quarto-go/assignees{/user}","branches_url":"https://api.github.com/repos/marmelab/quarto-go/branches{/branch}","tags_url":"https://api.github.com/repos/marmelab/quarto-go/tags","blobs_url":"https://api.github.com/repos/marmelab/quarto-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marmelab/quarto-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marmelab/quarto-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/marmelab/quarto-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marmelab/quarto-go/statuses/{sha}","languages_url":"https://api.github.com/repos/marmelab/quarto-go/languages","stargazers_url":"https://api.github.com/repos/marmelab/quarto-go/stargazers","contributors_url":"https://api.github.com/repos/marmelab/quarto-go/contributors","subscribers_url":"https://api.github.com/repos/marmelab/quarto-go/subscribers","subscription_url":"https://api.github.com/repos/marmelab/quarto-go/subscription","commits_url":"https://api.github.com/repos/marmelab/quarto-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/marmelab/quarto-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/marmelab/quarto-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/marmelab/quarto-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/marmelab/quarto-go/contents/{+path}","compare_url":"https://api.github.com/repos/marmelab/quarto-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marmelab/quarto-go/merges","archive_url":"https://api.github.com/repos/marmelab/quarto-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marmelab/quarto-go/downloads","issues_url":"https://api.github.com/repos/marmelab/quarto-go/issues{/number}","pulls_url":"https://api.github.com/repos/marmelab/quarto-go/pulls{/number}","milestones_url":"https://api.github.com/repos/marmelab/quarto-go/milestones{/number}","notifications_url":"https://api.github.com/repos/marmelab/quarto-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marmelab/quarto-go/labels{/name}","releases_url":"https://api.github.com/repos/marmelab/quarto-go/releases{/id}","deployments_url":"https://api.github.com/repos/marmelab/quarto-go/deployments","created_at":"2018-06-11T07:53:01Z","updated_at":"2018-06-11T08:49:18Z","pushed_at":"2018-06-11T15:34:27Z","git_url":"git://github.com/marmelab/quarto-go.git","ssh_url":"git@github.com:marmelab/quarto-go.git","clone_url":"https://github.com/marmelab/quarto-go.git","svn_url":"https://github.com/marmelab/quarto-go","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"Makefile","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/2"},"html":{"href":"https://github.com/marmelab/quarto-go/pull/2"},"issue":{"href":"https://api.github.com/repos/marmelab/quarto-go/issues/2"},"comments":{"href":"https://api.github.com/repos/marmelab/quarto-go/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marmelab/quarto-go/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/marmelab/quarto-go/statuses/95897011f0c903415e8b1222283849ce79c7e660"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Kmaschta"}}