🏄♂️
- GitHub Staff
- rickwinfrey.com
- @rewinfrey.bsky.social
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 minimax_with_alpha(max_player = true, ply = 0, alpha = -1000, beta = 1000) | |
return(board.winner? ? winning_score(max_player, ply) : 0) if base_case_satisfied? | |
ab_value = max_player ? -1000 : 1000 | |
ab_value, best_move = gen_score_game_tree(max_player, ply, alpha, beta, ab_value) | |
return( ply == 0 ? best_move : ab_value) | |
end | |
def gen_score_game_tree(max_player, ply, alpha, beta, ab_value) | |
best_move = 0 | |
available_moves.each do |index| |
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
$ git commit ... (1) | |
$ git reset --soft HEAD^ (2) | |
$ edit (3) | |
$ git add .... (4) | |
$ git commit -c ORIG_HEAD (5) | |
1. This is what you want to undo | |
2. This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". |
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 minimax_back(max_player = true, ply = 0, min_score = 1000, max_score = -1000) | |
if board.winner? | |
return(max_player ? (-1000 + ply) : (1000 - ply)) | |
elsif board.draw_game? | |
return 0 | |
end | |
if ply >= max_ply | |
return(max_player ? max_score : min_score) | |
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 'yaml' | |
class RetainAttributeOfToYaml | |
attr_accessor :name | |
def initialize(name) | |
@name = "Hi, my name is #{name}." | |
end | |
end | |
class ToYaml |
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
Install the necessary gems: | |
$ gem install autotest | |
$ gem install autotest-growl | |
$ gem install autotest-fsevent | |
note: you may also need the "autotest-rails-pure" gem | |
Create ~/.autotest configuration file (include the following 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
$ rvm install jruby-1.6.6 | |
https://github.com/slagyr/limelight/downloads | |
download: limelight_docs.llp | |
$ gem install limelight -v 0.5.5 | |
$ limelight open limelight_docs.llp |
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
First, we need FFMpeg's binary (put binary where it can be found in the load path): | |
http://ffmpegmac.net/ | |
Next, in order to encode a file as mp3, we need Lame (currently tested with 3.99.5): | |
http://sourceforge.net/projects/lame/files/lame/3.99/ | |
Untar the library: | |
$ tar -zxvf { file_name } | |
Run Lame's configure script (using the default configuration for this is fine): |
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
# don't really need Shape class | |
class Shape | |
def initialize(options) | |
end | |
def area | |
end | |
end | |
class CircleShape |
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 SelfMaker | |
def yet_what_is_self? | |
self.class.class_eval do | |
mirror(self, "Inside class_eval of SelfMaker#yet_what_is_self?") | |
end | |
instance_eval do | |
mirror(self, "Inside instance_eval of SelfMaker#yet_what_is_self?") | |
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
class PlayerIO | |
attr_accessor :output, :input | |
def initialize(output, input) | |
@output = output | |
@input = input | |
end | |
def output(args) | |
@output.puts args | |
end |