Solving an algorithm for a friend to be able to tell his emacs what window he wants to replace his current window when he closes it.
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' | |
require 'minimax' | |
class Test_Minimax_Ai | |
include Algorithm::Minimax | |
end | |
describe 'Test_Minimax_Ai' do | |
before (:each) do |
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_relative 'library' | |
module Algorithm | |
module Minimax # I return the best_move (win or block) | |
include Library # TODO namespace these methods | |
# max_move-find winningest Computer move, score it, add it to answer hash | |
# min_move-find winningest Human move, score it, add it to answer hash | |
def ai_moves(board) | |
turn_number = board.grid.select{ |k, v| v != " " }.keys.length | |
# receive board...is the game over? check for conditions... |
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 'minimax' | |
class Test_Minimax_Ai | |
include Algorithm::Minimax | |
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
require 'board' | |
require 'minimax' | |
class Test_Minimax_Ai | |
include Algorithm::Minimax | |
end | |
describe 'Test_Minimax_Ai' do | |
before (:each) do |
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 generate_boards(board, player) | |
virtual_board = board.dup | |
new_board_hash = {} | |
empty_spaces = virtual_board.grid.select{ |k, v| v == " " }.keys | |
empty_spaces.each do |space| | |
cloned_board = Board.new | |
cloned_board.grid = board.grid.clone |
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 move_as_somebody(board, player, empty_space) | |
board.grid[empty_space] = player | |
@i+=1 | |
return board | |
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
both thefonso and kosh can log into name_of_some-machine.com | |
Note: if you don't have a github account take a look at this to generate your keys... | |
https://help.github.com/articles/generating-ssh-keys | |
tmux pairing via ssh tunnel | |
Step 0: both users edit ~/.ssh/config | |
thefonso: |
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
#!/usr/bin/ruby | |
=begin | |
Usage: rtftomarkdown.rb FILENAME.rtf | |
Uses textutil, available on Mac only (installed by default) | |
Outputs to STDOUT | |
Notes: | |
Links are replaced with Markdown references (duplicate links combined). |
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 Rectangle | |
attr_accessor :height, :width | |
def area | |
@height * @width | |
end | |
end | |
class Square < Rectangle | |
def height=(height) |