{"action":"created","comment":{"url":"https://api.github.com/repos/carmelre/python_training/pulls/comments/173174671","pull_request_review_id":102286874,"id":173174671,"diff_hunk":"@@ -0,0 +1,170 @@\n+import random\n+\n+\n+class XOGame:\n+    \"\"\"\n+    Creates a XO game for two players, in any wanted board size (n>2).\n+    \"\"\"\n+\n+    def __init__(self, player1, player2, board_size):\n+        \"\"\"\n+        Initiates the class and prepares all the necessary data.\n+\n+        :param player1: The name of the first player\n+        :param player2: The name of the second player\n+        :param board_size: The length of the boards rows and columns.\n+        \"\"\"\n+        # Create a mapping between the player representation and name\n+        self.players = {0: player1, 1: player2}\n+        # Create mapping between player representation and printable symbol\n+        self.symbols_mapping = {0: \"X\", 1: \"O\", None: \" \"}\n+        self.board_size = board_size\n+        # Range is used so each row would create a different list in the memory\n+        self.board = [[None] * board_size for row in range(self.board_size)]\n+        self.turns_counter = 0\n+        self.current_player = random.choice(list(self.players.keys()))\n+\n+    def start_game(self):\n+        \"\"\"\n+        Calls for turns to be taken until the game is over.\n+        \"\"\"\n+        self.print_board()\n+        while not self.has_game_ended():\n+            self.take_turn()\n+            self.print_board()\n+\n+    def print_board(self):\n+        \"\"\"\n+        Prints the current board of the game.\n+        \"\"\"\n+        # Prints the first line that looks like this (for n = 3):\n+        #   0 1 2\n+        print('   ' + ' '.join([str(num) for num in range(self.board_size)]))\n+        # Creates a line that separates the board rows (calculated according to the number of slots)\n+        # Eventually the line would look like this -------------\n+        separator_line = '  ' + '-' * (3 * self.board_size - (self.board_size - 1))","path":"python_training/XO.py","position":45,"original_position":45,"commit_id":"ec27ea250aedd6a047ab183b66639cf842e0a3ef","original_commit_id":"ec27ea250aedd6a047ab183b66639cf842e0a3ef","user":{"login":"ofir123","id":4647811,"avatar_url":"https://avatars1.githubusercontent.com/u/4647811?v=4","gravatar_id":"","url":"https://api.github.com/users/ofir123","html_url":"https://github.com/ofir123","followers_url":"https://api.github.com/users/ofir123/followers","following_url":"https://api.github.com/users/ofir123/following{/other_user}","gists_url":"https://api.github.com/users/ofir123/gists{/gist_id}","starred_url":"https://api.github.com/users/ofir123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ofir123/subscriptions","organizations_url":"https://api.github.com/users/ofir123/orgs","repos_url":"https://api.github.com/users/ofir123/repos","events_url":"https://api.github.com/users/ofir123/events{/privacy}","received_events_url":"https://api.github.com/users/ofir123/received_events","type":"User","site_admin":false},"body":"New style here as well.","created_at":"2018-03-08T14:33:52Z","updated_at":"2018-03-08T14:42:13Z","html_url":"https://github.com/carmelre/python_training/pull/2#discussion_r173174671","pull_request_url":"https://api.github.com/repos/carmelre/python_training/pulls/2","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/carmelre/python_training/pulls/comments/173174671"},"html":{"href":"https://github.com/carmelre/python_training/pull/2#discussion_r173174671"},"pull_request":{"href":"https://api.github.com/repos/carmelre/python_training/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/carmelre/python_training/pulls/2","id":173463302,"html_url":"https://github.com/carmelre/python_training/pull/2","diff_url":"https://github.com/carmelre/python_training/pull/2.diff","patch_url":"https://github.com/carmelre/python_training/pull/2.patch","issue_url":"https://api.github.com/repos/carmelre/python_training/issues/2","number":2,"state":"open","locked":false,"title":"Completed the XO exercise!","user":{"login":"carmelre","id":33458504,"avatar_url":"https://avatars2.githubusercontent.com/u/33458504?v=4","gravatar_id":"","url":"https://api.github.com/users/carmelre","html_url":"https://github.com/carmelre","followers_url":"https://api.github.com/users/carmelre/followers","following_url":"https://api.github.com/users/carmelre/following{/other_user}","gists_url":"https://api.github.com/users/carmelre/gists{/gist_id}","starred_url":"https://api.github.com/users/carmelre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carmelre/subscriptions","organizations_url":"https://api.github.com/users/carmelre/orgs","repos_url":"https://api.github.com/users/carmelre/repos","events_url":"https://api.github.com/users/carmelre/events{/privacy}","received_events_url":"https://api.github.com/users/carmelre/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-03-07T14:12:42Z","updated_at":"2018-03-08T14:42:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8f0f789d57cf03f240d770507da172d9a010d6c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/carmelre/python_training/pulls/2/commits","review_comments_url":"https://api.github.com/repos/carmelre/python_training/pulls/2/comments","review_comment_url":"https://api.github.com/repos/carmelre/python_training/pulls/comments{/number}","comments_url":"https://api.github.com/repos/carmelre/python_training/issues/2/comments","statuses_url":"https://api.github.com/repos/carmelre/python_training/statuses/ec27ea250aedd6a047ab183b66639cf842e0a3ef","head":{"label":"carmelre:XO","ref":"XO","sha":"ec27ea250aedd6a047ab183b66639cf842e0a3ef","user":{"login":"carmelre","id":33458504,"avatar_url":"https://avatars2.githubusercontent.com/u/33458504?v=4","gravatar_id":"","url":"https://api.github.com/users/carmelre","html_url":"https://github.com/carmelre","followers_url":"https://api.github.com/users/carmelre/followers","following_url":"https://api.github.com/users/carmelre/following{/other_user}","gists_url":"https://api.github.com/users/carmelre/gists{/gist_id}","starred_url":"https://api.github.com/users/carmelre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carmelre/subscriptions","organizations_url":"https://api.github.com/users/carmelre/orgs","repos_url":"https://api.github.com/users/carmelre/repos","events_url":"https://api.github.com/users/carmelre/events{/privacy}","received_events_url":"https://api.github.com/users/carmelre/received_events","type":"User","site_admin":false},"repo":{"id":123942220,"name":"python_training","full_name":"carmelre/python_training","owner":{"login":"carmelre","id":33458504,"avatar_url":"https://avatars2.githubusercontent.com/u/33458504?v=4","gravatar_id":"","url":"https://api.github.com/users/carmelre","html_url":"https://github.com/carmelre","followers_url":"https://api.github.com/users/carmelre/followers","following_url":"https://api.github.com/users/carmelre/following{/other_user}","gists_url":"https://api.github.com/users/carmelre/gists{/gist_id}","starred_url":"https://api.github.com/users/carmelre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carmelre/subscriptions","organizations_url":"https://api.github.com/users/carmelre/orgs","repos_url":"https://api.github.com/users/carmelre/repos","events_url":"https://api.github.com/users/carmelre/events{/privacy}","received_events_url":"https://api.github.com/users/carmelre/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/carmelre/python_training","description":"Exercises:)","fork":false,"url":"https://api.github.com/repos/carmelre/python_training","forks_url":"https://api.github.com/repos/carmelre/python_training/forks","keys_url":"https://api.github.com/repos/carmelre/python_training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/carmelre/python_training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/carmelre/python_training/teams","hooks_url":"https://api.github.com/repos/carmelre/python_training/hooks","issue_events_url":"https://api.github.com/repos/carmelre/python_training/issues/events{/number}","events_url":"https://api.github.com/repos/carmelre/python_training/events","assignees_url":"https://api.github.com/repos/carmelre/python_training/assignees{/user}","branches_url":"https://api.github.com/repos/carmelre/python_training/branches{/branch}","tags_url":"https://api.github.com/repos/carmelre/python_training/tags","blobs_url":"https://api.github.com/repos/carmelre/python_training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/carmelre/python_training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/carmelre/python_training/git/refs{/sha}","trees_url":"https://api.github.com/repos/carmelre/python_training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/carmelre/python_training/statuses/{sha}","languages_url":"https://api.github.com/repos/carmelre/python_training/languages","stargazers_url":"https://api.github.com/repos/carmelre/python_training/stargazers","contributors_url":"https://api.github.com/repos/carmelre/python_training/contributors","subscribers_url":"https://api.github.com/repos/carmelre/python_training/subscribers","subscription_url":"https://api.github.com/repos/carmelre/python_training/subscription","commits_url":"https://api.github.com/repos/carmelre/python_training/commits{/sha}","git_commits_url":"https://api.github.com/repos/carmelre/python_training/git/commits{/sha}","comments_url":"https://api.github.com/repos/carmelre/python_training/comments{/number}","issue_comment_url":"https://api.github.com/repos/carmelre/python_training/issues/comments{/number}","contents_url":"https://api.github.com/repos/carmelre/python_training/contents/{+path}","compare_url":"https://api.github.com/repos/carmelre/python_training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/carmelre/python_training/merges","archive_url":"https://api.github.com/repos/carmelre/python_training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/carmelre/python_training/downloads","issues_url":"https://api.github.com/repos/carmelre/python_training/issues{/number}","pulls_url":"https://api.github.com/repos/carmelre/python_training/pulls{/number}","milestones_url":"https://api.github.com/repos/carmelre/python_training/milestones{/number}","notifications_url":"https://api.github.com/repos/carmelre/python_training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/carmelre/python_training/labels{/name}","releases_url":"https://api.github.com/repos/carmelre/python_training/releases{/id}","deployments_url":"https://api.github.com/repos/carmelre/python_training/deployments","created_at":"2018-03-05T15:50:01Z","updated_at":"2018-03-07T13:55:02Z","pushed_at":"2018-03-08T12:13:48Z","git_url":"git://github.com/carmelre/python_training.git","ssh_url":"git@github.com:carmelre/python_training.git","clone_url":"https://github.com/carmelre/python_training.git","svn_url":"https://github.com/carmelre/python_training","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":null,"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":"carmelre:master","ref":"master","sha":"0ef37904fcdc4448d57370a2280fca71d35ff680","user":{"login":"carmelre","id":33458504,"avatar_url":"https://avatars2.githubusercontent.com/u/33458504?v=4","gravatar_id":"","url":"https://api.github.com/users/carmelre","html_url":"https://github.com/carmelre","followers_url":"https://api.github.com/users/carmelre/followers","following_url":"https://api.github.com/users/carmelre/following{/other_user}","gists_url":"https://api.github.com/users/carmelre/gists{/gist_id}","starred_url":"https://api.github.com/users/carmelre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carmelre/subscriptions","organizations_url":"https://api.github.com/users/carmelre/orgs","repos_url":"https://api.github.com/users/carmelre/repos","events_url":"https://api.github.com/users/carmelre/events{/privacy}","received_events_url":"https://api.github.com/users/carmelre/received_events","type":"User","site_admin":false},"repo":{"id":123942220,"name":"python_training","full_name":"carmelre/python_training","owner":{"login":"carmelre","id":33458504,"avatar_url":"https://avatars2.githubusercontent.com/u/33458504?v=4","gravatar_id":"","url":"https://api.github.com/users/carmelre","html_url":"https://github.com/carmelre","followers_url":"https://api.github.com/users/carmelre/followers","following_url":"https://api.github.com/users/carmelre/following{/other_user}","gists_url":"https://api.github.com/users/carmelre/gists{/gist_id}","starred_url":"https://api.github.com/users/carmelre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carmelre/subscriptions","organizations_url":"https://api.github.com/users/carmelre/orgs","repos_url":"https://api.github.com/users/carmelre/repos","events_url":"https://api.github.com/users/carmelre/events{/privacy}","received_events_url":"https://api.github.com/users/carmelre/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/carmelre/python_training","description":"Exercises:)","fork":false,"url":"https://api.github.com/repos/carmelre/python_training","forks_url":"https://api.github.com/repos/carmelre/python_training/forks","keys_url":"https://api.github.com/repos/carmelre/python_training/keys{/key_id}","collaborators_url":"https://api.github.com/repos/carmelre/python_training/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/carmelre/python_training/teams","hooks_url":"https://api.github.com/repos/carmelre/python_training/hooks","issue_events_url":"https://api.github.com/repos/carmelre/python_training/issues/events{/number}","events_url":"https://api.github.com/repos/carmelre/python_training/events","assignees_url":"https://api.github.com/repos/carmelre/python_training/assignees{/user}","branches_url":"https://api.github.com/repos/carmelre/python_training/branches{/branch}","tags_url":"https://api.github.com/repos/carmelre/python_training/tags","blobs_url":"https://api.github.com/repos/carmelre/python_training/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/carmelre/python_training/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/carmelre/python_training/git/refs{/sha}","trees_url":"https://api.github.com/repos/carmelre/python_training/git/trees{/sha}","statuses_url":"https://api.github.com/repos/carmelre/python_training/statuses/{sha}","languages_url":"https://api.github.com/repos/carmelre/python_training/languages","stargazers_url":"https://api.github.com/repos/carmelre/python_training/stargazers","contributors_url":"https://api.github.com/repos/carmelre/python_training/contributors","subscribers_url":"https://api.github.com/repos/carmelre/python_training/subscribers","subscription_url":"https://api.github.com/repos/carmelre/python_training/subscription","commits_url":"https://api.github.com/repos/carmelre/python_training/commits{/sha}","git_commits_url":"https://api.github.com/repos/carmelre/python_training/git/commits{/sha}","comments_url":"https://api.github.com/repos/carmelre/python_training/comments{/number}","issue_comment_url":"https://api.github.com/repos/carmelre/python_training/issues/comments{/number}","contents_url":"https://api.github.com/repos/carmelre/python_training/contents/{+path}","compare_url":"https://api.github.com/repos/carmelre/python_training/compare/{base}...{head}","merges_url":"https://api.github.com/repos/carmelre/python_training/merges","archive_url":"https://api.github.com/repos/carmelre/python_training/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/carmelre/python_training/downloads","issues_url":"https://api.github.com/repos/carmelre/python_training/issues{/number}","pulls_url":"https://api.github.com/repos/carmelre/python_training/pulls{/number}","milestones_url":"https://api.github.com/repos/carmelre/python_training/milestones{/number}","notifications_url":"https://api.github.com/repos/carmelre/python_training/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/carmelre/python_training/labels{/name}","releases_url":"https://api.github.com/repos/carmelre/python_training/releases{/id}","deployments_url":"https://api.github.com/repos/carmelre/python_training/deployments","created_at":"2018-03-05T15:50:01Z","updated_at":"2018-03-07T13:55:02Z","pushed_at":"2018-03-08T12:13:48Z","git_url":"git://github.com/carmelre/python_training.git","ssh_url":"git@github.com:carmelre/python_training.git","clone_url":"https://github.com/carmelre/python_training.git","svn_url":"https://github.com/carmelre/python_training","homepage":null,"size":5,"stargazers_count":0,"watchers_count":0,"language":null,"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/carmelre/python_training/pulls/2"},"html":{"href":"https://github.com/carmelre/python_training/pull/2"},"issue":{"href":"https://api.github.com/repos/carmelre/python_training/issues/2"},"comments":{"href":"https://api.github.com/repos/carmelre/python_training/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/carmelre/python_training/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/carmelre/python_training/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/carmelre/python_training/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/carmelre/python_training/statuses/ec27ea250aedd6a047ab183b66639cf842e0a3ef"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ofir123"}}