This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AIPlayer < Player | |
| def make_move(board) | |
| ai = AI.new(self) | |
| cell = ai.computer_move(board, self) | |
| add_marker(board, cell) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Updated config.ru | |
| require './app' | |
| run TicTacToe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Updated app.rb | |
| require 'rubygems' | |
| require 'ruby_ttt' | |
| require 'sinatra/base' | |
| require 'shotgun' | |
| require './game_helpers.rb' | |
| class TicTacToe < Sinatra::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## env.rb | |
| require File.join(File.expand_path(File.dirname(__FILE__)),'../../app') | |
| require "Capybara" | |
| require "Capybara/cucumber" | |
| require "rspec" | |
| module TicTacToeCapybaraTest | |
| Capybara.app = TicTacToe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| ruby '1.9.3' | |
| gem "sinatra" | |
| gem "thin" | |
| gem 'shotgun' | |
| gem "ruby_ttt", "~> 0.3.1" | |
| gem "cucumber" | |
| gem "capybara" | |
| gem "rspec" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Feature: Board | |
| In order to play a game | |
| As a game player | |
| I want to make moves on the board | |
| Background: | |
| Given I visit the homepage | |
| And I select 'Human' for 'Player one' | |
| And I select 'Human' for 'Player two' | |
| And I press 'Start game!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include TicTacToeCapybaraTest | |
| Given(/^I press the (\d+)A cell button$/) do |arg1| | |
| click_button "#{arg1}A" | |
| end | |
| Then(/^I should see a marker in the (\d+)A cell$/) do |arg1| | |
| expect(page).to have_css("#board button[value=\"#{arg1}A\"]", text: (/(X|O)/)) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'tictactoe_constants' | |
| class PlayerFactory | |
| include TictactoeConstants | |
| attr_accessor :player_one, :player_two | |
| def initialize(type_one, type_two) | |
| @player_one = create_player(type_one, TictactoeConstants::MARKER_X) | |
| @player_two = create_player(type_two, TictactoeConstants::MARKER_O) | |
| set_opponents | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module TictactoeConstants | |
| MARKER_X = 'X' | |
| MARKER_O = 'O' | |
| COMPUTER_PLAYER = 'computer' | |
| HUMAN_PLAYER = 'human' | |
| AI_PLAYER = 'hard computer' | |
| HARD_LEVEL = 'hard' | |
| EASY_LEVEL = 'easy' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'simplecov' | |
| SimpleCov.start | |
| require 'sinatra' | |
| require 'rack/test' # Require Rack Test library | |
| require 'ruby_ttt' | |
| require 'web_board' | |
| require 'web_game' | |
| require 'web_game_setup' | |
| require './game_helpers.rb' |