{"action":"created","comment":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/94254727","pull_request_review_id":14785952,"id":94254727,"diff_hunk":"@@ -0,0 +1,78 @@\n+class Game\n+\n+  # Game constants for winning combinations and corner, side and center cells.\n+  WIN_COMBINATIONS = [\n+      [0, 1, 2],\n+      [3, 4, 5],\n+      [6, 7, 8],\n+      [0, 4, 8],\n+      [6, 4, 2],\n+      [0, 3, 6],\n+      [1, 4, 7],\n+      [2, 5, 8],\n+  ].freeze\n+  CORNERS = [0, 2, 6, 8].freeze\n+  SIDES = [1, 3, 5, 7].freeze\n+  CENTER = 4\n+\n+  attr_accessor :board, :player_1, :player_2\n+\n+  # Initialize a game, setting the players and the board, plus the :opponent and :player_num of both players.\n+  def initialize(player_1 = Players::Human.new('X'), player_2 = Players::Human.new('O'), board = Board.new)\n+    @player_1 = player_1\n+    @player_2 = player_2\n+    @board    = board\n+    @player_1.opponent   = @player_2\n+    @player_1.player_num = 1\n+    @player_2.opponent   = @player_1\n+    @player_2.player_num = 2\n+  end\n+\n+  def current_player\n+    board.turn_count.even? ? player_1 : player_2\n+  end\n+\n+  def over?\n+    draw? || won?\n+  end\n+\n+  # Find the first WIN_COMBINATION where every cell is an 'X' or every cell is an 'O'.\n+  def won?\n+    WIN_COMBINATIONS.detect do |combo|\n+      combo.all? { |cell| board.cells[cell] == 'X' } || combo.all? { |cell| board.cells[cell] == 'O' }\n+    end\n+  end\n+\n+  def draw?\n+    board.full? && !won?\n+  end\n+\n+  def winner\n+    board.cells[won?.first] if won?","path":"lib/game.rb","position":51,"original_position":51,"commit_id":"a5aef03eb4f9420917a23b74ff616d3b313244b7","original_commit_id":"a5aef03eb4f9420917a23b74ff616d3b313244b7","user":{"login":"cernanb","id":7960757,"avatar_url":"https://avatars.githubusercontent.com/u/7960757?v=3","gravatar_id":"","url":"https://api.github.com/users/cernanb","html_url":"https://github.com/cernanb","followers_url":"https://api.github.com/users/cernanb/followers","following_url":"https://api.github.com/users/cernanb/following{/other_user}","gists_url":"https://api.github.com/users/cernanb/gists{/gist_id}","starred_url":"https://api.github.com/users/cernanb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cernanb/subscriptions","organizations_url":"https://api.github.com/users/cernanb/orgs","repos_url":"https://api.github.com/users/cernanb/repos","events_url":"https://api.github.com/users/cernanb/events{/privacy}","received_events_url":"https://api.github.com/users/cernanb/received_events","type":"User","site_admin":false},"body":"Instead of calling `Game#won?` twice, consider using an if statement assignment. For example:\r\n\r\n```ruby\r\nif won = won?\r\n  board.cells[won.first]\r\nend\r\n```\r\n\r\nIf `won?` returns true, then and only then will the local variable `won` be assigned, otherwise, the method will just abort with a false return value. But if `won` is assigned, we can use that variable instead of calling `won?` again within the if statement.","created_at":"2016-12-30T20:06:12Z","updated_at":"2016-12-30T20:07:42Z","html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357#discussion_r94254727","pull_request_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357","_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments/94254727"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357#discussion_r94254727"},"pull_request":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357"}}},"pull_request":{"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357","id":99707507,"html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357","diff_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357.diff","patch_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357.patch","issue_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/357","number":357,"state":"open","locked":false,"title":"Project submitted","user":{"login":"msimonborg","id":22436641,"avatar_url":"https://avatars.githubusercontent.com/u/22436641?v=3","gravatar_id":"","url":"https://api.github.com/users/msimonborg","html_url":"https://github.com/msimonborg","followers_url":"https://api.github.com/users/msimonborg/followers","following_url":"https://api.github.com/users/msimonborg/following{/other_user}","gists_url":"https://api.github.com/users/msimonborg/gists{/gist_id}","starred_url":"https://api.github.com/users/msimonborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msimonborg/subscriptions","organizations_url":"https://api.github.com/users/msimonborg/orgs","repos_url":"https://api.github.com/users/msimonborg/repos","events_url":"https://api.github.com/users/msimonborg/events{/privacy}","received_events_url":"https://api.github.com/users/msimonborg/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-12-29T23:00:55Z","updated_at":"2016-12-30T20:07:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8505f92bc1f7e168aec521dcd022bbb06a241844","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357/commits","review_comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357/comments","review_comment_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments{/number}","comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/357/comments","statuses_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/a5aef03eb4f9420917a23b74ff616d3b313244b7","head":{"label":"msimonborg:master","ref":"master","sha":"a5aef03eb4f9420917a23b74ff616d3b313244b7","user":{"login":"msimonborg","id":22436641,"avatar_url":"https://avatars.githubusercontent.com/u/22436641?v=3","gravatar_id":"","url":"https://api.github.com/users/msimonborg","html_url":"https://github.com/msimonborg","followers_url":"https://api.github.com/users/msimonborg/followers","following_url":"https://api.github.com/users/msimonborg/following{/other_user}","gists_url":"https://api.github.com/users/msimonborg/gists{/gist_id}","starred_url":"https://api.github.com/users/msimonborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msimonborg/subscriptions","organizations_url":"https://api.github.com/users/msimonborg/orgs","repos_url":"https://api.github.com/users/msimonborg/repos","events_url":"https://api.github.com/users/msimonborg/events{/privacy}","received_events_url":"https://api.github.com/users/msimonborg/received_events","type":"User","site_admin":false},"repo":{"id":77501832,"name":"ttt-with-ai-project-v-000","full_name":"msimonborg/ttt-with-ai-project-v-000","owner":{"login":"msimonborg","id":22436641,"avatar_url":"https://avatars.githubusercontent.com/u/22436641?v=3","gravatar_id":"","url":"https://api.github.com/users/msimonborg","html_url":"https://github.com/msimonborg","followers_url":"https://api.github.com/users/msimonborg/followers","following_url":"https://api.github.com/users/msimonborg/following{/other_user}","gists_url":"https://api.github.com/users/msimonborg/gists{/gist_id}","starred_url":"https://api.github.com/users/msimonborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msimonborg/subscriptions","organizations_url":"https://api.github.com/users/msimonborg/orgs","repos_url":"https://api.github.com/users/msimonborg/repos","events_url":"https://api.github.com/users/msimonborg/events{/privacy}","received_events_url":"https://api.github.com/users/msimonborg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/msimonborg/ttt-with-ai-project-v-000","description":null,"fork":true,"url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000","forks_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/forks","keys_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/keys{/key_id}","collaborators_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/teams","hooks_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/hooks","issue_events_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/issues/events{/number}","events_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/events","assignees_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/assignees{/user}","branches_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/branches{/branch}","tags_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/tags","blobs_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/git/refs{/sha}","trees_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/git/trees{/sha}","statuses_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/statuses/{sha}","languages_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/languages","stargazers_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/stargazers","contributors_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/contributors","subscribers_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/subscribers","subscription_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/subscription","commits_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/commits{/sha}","git_commits_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/git/commits{/sha}","comments_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/comments{/number}","issue_comment_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/issues/comments{/number}","contents_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/contents/{+path}","compare_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/compare/{base}...{head}","merges_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/merges","archive_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/downloads","issues_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/issues{/number}","pulls_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/pulls{/number}","milestones_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/milestones{/number}","notifications_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/labels{/name}","releases_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/releases{/id}","deployments_url":"https://api.github.com/repos/msimonborg/ttt-with-ai-project-v-000/deployments","created_at":"2016-12-28T04:02:10Z","updated_at":"2016-12-28T04:02:13Z","pushed_at":"2016-12-30T18:36:10Z","git_url":"git://github.com/msimonborg/ttt-with-ai-project-v-000.git","ssh_url":"git@github.com:msimonborg/ttt-with-ai-project-v-000.git","clone_url":"https://github.com/msimonborg/ttt-with-ai-project-v-000.git","svn_url":"https://github.com/msimonborg/ttt-with-ai-project-v-000","homepage":null,"size":63,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"learn-co-students:master","ref":"master","sha":"7f7dd92aaea115368e91881671ec600ae1acc089","user":{"login":"learn-co-students","id":8825476,"avatar_url":"https://avatars.githubusercontent.com/u/8825476?v=3","gravatar_id":"","url":"https://api.github.com/users/learn-co-students","html_url":"https://github.com/learn-co-students","followers_url":"https://api.github.com/users/learn-co-students/followers","following_url":"https://api.github.com/users/learn-co-students/following{/other_user}","gists_url":"https://api.github.com/users/learn-co-students/gists{/gist_id}","starred_url":"https://api.github.com/users/learn-co-students/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learn-co-students/subscriptions","organizations_url":"https://api.github.com/users/learn-co-students/orgs","repos_url":"https://api.github.com/users/learn-co-students/repos","events_url":"https://api.github.com/users/learn-co-students/events{/privacy}","received_events_url":"https://api.github.com/users/learn-co-students/received_events","type":"Organization","site_admin":false},"repo":{"id":46080145,"name":"ttt-with-ai-project-v-000","full_name":"learn-co-students/ttt-with-ai-project-v-000","owner":{"login":"learn-co-students","id":8825476,"avatar_url":"https://avatars.githubusercontent.com/u/8825476?v=3","gravatar_id":"","url":"https://api.github.com/users/learn-co-students","html_url":"https://github.com/learn-co-students","followers_url":"https://api.github.com/users/learn-co-students/followers","following_url":"https://api.github.com/users/learn-co-students/following{/other_user}","gists_url":"https://api.github.com/users/learn-co-students/gists{/gist_id}","starred_url":"https://api.github.com/users/learn-co-students/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learn-co-students/subscriptions","organizations_url":"https://api.github.com/users/learn-co-students/orgs","repos_url":"https://api.github.com/users/learn-co-students/repos","events_url":"https://api.github.com/users/learn-co-students/events{/privacy}","received_events_url":"https://api.github.com/users/learn-co-students/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000","description":null,"fork":false,"url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000","forks_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/forks","keys_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/keys{/key_id}","collaborators_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/teams","hooks_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/hooks","issue_events_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/events{/number}","events_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/events","assignees_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/assignees{/user}","branches_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/branches{/branch}","tags_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/tags","blobs_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/refs{/sha}","trees_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/trees{/sha}","statuses_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/{sha}","languages_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/languages","stargazers_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/stargazers","contributors_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/contributors","subscribers_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/subscribers","subscription_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/subscription","commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/commits{/sha}","git_commits_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/git/commits{/sha}","comments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/comments{/number}","issue_comment_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/comments{/number}","contents_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/contents/{+path}","compare_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/compare/{base}...{head}","merges_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/merges","archive_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/downloads","issues_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues{/number}","pulls_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls{/number}","milestones_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/milestones{/number}","notifications_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/labels{/name}","releases_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/releases{/id}","deployments_url":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/deployments","created_at":"2015-11-12T20:52:43Z","updated_at":"2016-11-11T01:59:49Z","pushed_at":"2016-12-30T18:36:11Z","git_url":"git://github.com/learn-co-students/ttt-with-ai-project-v-000.git","ssh_url":"git@github.com:learn-co-students/ttt-with-ai-project-v-000.git","clone_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000.git","svn_url":"https://github.com/learn-co-students/ttt-with-ai-project-v-000","homepage":null,"size":3849,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":368,"mirror_url":null,"open_issues_count":188,"forks":368,"open_issues":188,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357"},"html":{"href":"https://github.com/learn-co-students/ttt-with-ai-project-v-000/pull/357"},"issue":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/357"},"comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/issues/357/comments"},"review_comments":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357/comments"},"review_comment":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/pulls/357/commits"},"statuses":{"href":"https://api.github.com/repos/learn-co-students/ttt-with-ai-project-v-000/statuses/a5aef03eb4f9420917a23b74ff616d3b313244b7"}}}}
{"actor":{"display_login":"cernanb"}}