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 Board | |
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows | |
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] + # cols | |
[[1, 5, 9], [3, 5, 7]] # diagonals | |
def initialize | |
@squares = {} | |
@human_marker = nil | |
@computer_marker = nil | |
reset |
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
# Rock Paper Scissors Spock Lizard | |
# require 'pry' | |
VALID_CHOICES = %w(rock paper scissors spock lizard) | |
def win?(first, second) | |
(first == 'scissors' && second == 'paper') || | |
(first == 'paper' && second == 'rock') || | |
(first == 'rock' && second == 'lizard') || | |
(first == 'lizard' && second == 'spock') || |