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 RandomGuess < SearchOperator | |
attr_accessor :params | |
def initialize(params={}) | |
@params = params | |
end | |
def generate(howMany = 1, tempParams ={}) | |
result = [] | |
howMany.times 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 domination_classes(crowd, template = all_shared_scores(crowd)) | |
result = Hash.new() | |
crowd.each_index do |i| | |
dominatedBy = 0 | |
crowd.each_index do |j| | |
dominatedBy += 1 if crowd[i].dominated_by?(crowd[j], template) | |
end | |
result[dominatedBy] ||= [] | |
result[dominatedBy].push crowd[i] | |
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
block { | |
literal «1» | |
literal «2» | |
block { | |
sample «3» | |
sample «4» | |
} | |
} | |
# local values: |
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
program = <<-ENDME | |
block { | |
value «1» | |
value «2» | |
value «3» | |
} | |
«1,string» hi there \n we have some lines | |
with extra space |
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 replace_point(which,new_junk) | |
raise ArgumentError,"Cannot replace #{which}th program point" if which < 1 | |
raise ArgumentError,"Cannot replace #{which}th program point" if which > self.points | |
raise ArgumentError,"Cannot insert #{new_junk.class}" unless new_junk.kind_of?(ProgramPoint) | |
result = self.deep_copy | |
if which == 1 | |
result.linked_code = new_junk | |
else |
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
block { | |
value «int» | |
do int_max | |
block {} | |
block { | |
value «int» | |
value «int» | |
ref planck_constant | |
block { | |
block { |
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
# Convert the provided const desc to a qualified constant name (as a string). | |
# A module, class, symbol, or string may be provided. | |
def to_constant_name(desc) #:nodoc: | |
name = case desc | |
when String then desc.starts_with?('::') ? desc[2..-1] : desc | |
when Symbol then desc.to_s | |
when Module | |
raise ArgumentError, "Anonymous modules have no name to be referenced by" if desc.name.blank? | |
desc.name | |
else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" |
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
# Ruby 1.9+ | |
j = /(?<!\-)\-{3}(?![\-])/ | |
positives = ["---", "x--- ", " ---x", "x --- x", "---!"] | |
negatives = ["--", "----", "x----", "----x", "---- x", "--!", "x--", "--x"] | |
positives.each {|t| puts "in #{t} I find a match a position #{t.match(j) ? t.match(j).offset(0) : 'NOWHERE!!1!'}, and I want to"} | |
negatives.each {|t| puts "in #{t} I find a match a position #{t.match(j) ? t.match(j).offset(0) : 'NOWHERE!!1!'}, and I don't want to"} |
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
#encoding: utf-8 | |
require File.join(File.dirname(__FILE__), "./../spec_helper") | |
include Nudge | |
describe "Nudge Program parser" do | |
it "should parse all these simple examples" do | |
["value «int»" , | |
"do int_add" , | |
"ref x88" , |
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
# Two columns: | |
# mutated program listing, does it parse? | |
"Xlock {\n ref aaa001\n block {\n block {\n do bool_yank\n block {\n block {\n value «bool»}\n block {\n value «float»}}}}\n value «int»\n do bool_from_float\n value «float»\n do code_rotate\n value «int»\n do float_yank\n block {\n do float_modulo\n block {\n ref aaa002}}} \n«bool» false\n«float» 75.0511936065204\n«int» -52\n«float» -523.763921107204\n«int» -34",false | |
"bXock {\n ref aaa001\n block {\n block {\n do bool_yank\n block {\n block {\n value «bool»}\n block {\n value «float»}}}}\n value «int»\n do bool_from_float\n value «float»\n do code_rotate\n value «int»\n do float_yank\n block {\n do float_modulo\n block {\n ref aaa002}}} \n«bool» false\n«float» 75.0511936065204\n«int» -52\n«float» -523.763921107204\n«int» -34",false | |
"blXck {\n ref aaa001\n block {\n block {\n do bool_yank\n block {\n b |
OlderNewer