This file contains 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
# Spec Step 1 | |
describe CoinChanger do | |
it "should return a penny" do | |
CoinChanger.make_change(1).should == %w(p) | |
end | |
end | |
# Class Step 1 - after failed uninitialized constant, failed no method errors, failed wrong number of arguments and | |
# failed 'got nil expected ["p"]' | |
class CoinChanger |
This file contains 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
def coordinates_for_next_move | |
while attackable(@row,@column) | |
@column += 1 if @column < @size | |
while @column >= @size | |
@row = @positions.last[0] | |
@column = @positions.last[1] + 1 | |
@positions.delete_at(@positions.count - 1) | |
end | |
end | |
place_next_queen |
This file contains 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
<div class="gist">https://gist.github.com/#INSERT GIST NUMBER HERE#</div> |
This file contains 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
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> |
This file contains 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
def set_min_and_max_players(board) | |
if board.next_player == :player1 | |
@max_symbol = board.player1_symbol | |
@max_player = :player1 | |
@min_symbol = board.player2_symbol | |
@min_player = :player2 | |
elsif board.next_player == :player2 | |
@max_symbol = board.player2_symbol | |
@max_player = :player2 | |
@min_symbol = board.player1_symbol |
This file contains 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 MinimaxPlayer | |
attr_accessor :symbol, :starting_score | |
def initialize(symbol, score) | |
@symbol = symbol | |
@starting_score = score | |
end | |
end | |
class MinPlayer < MinimaxPlayer | |
def compare(best_score,new_score) |
This file contains 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
def set_min_and_max_players(board) | |
@max = MaxPlayer.new(board.next_player_symbol, -50) | |
@min = MinPlayer.new(board.opponent_symbol, 50) | |
end | |
def minimax_score(board) | |
score = game_value(board) | |
return score unless score == -1 #-1 means a game is still in progress | |
player = set_player(board.next_player_symbol) | |
best_score = player.starting_score |
This file contains 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 'board' | |
class Game | |
attr_accesor :ui, :board | |
def initialize(ui) | |
@ui = ui | |
@board = Board.new(3) | |
end | |
end |
This file contains 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
#where foundry below is the name of your main app file | |
require File.join(File.expand_path(File.dirname(__FILE__)),'../../foundry') | |
require "Capybara" | |
require "Capybara/cucumber" | |
require "rspec" | |
World do | |
Capybara.app = Foundry #where Foundry is the class in your main app file | |
This file contains 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 File.join(File.expand_path(File.dirname(__FILE__)), '/../', 'foundry') | |
require 'sinatra' | |
require 'rack/test' | |
set :environment, :test | |
#specify that the app is a Sinatra app | |
def app | |
Sinatra::Application |
OlderNewer