Skip to content

Instantly share code, notes, and snippets.

View Vaguery's full-sized avatar

Bill Tozier Vaguery

View GitHub Profile
block {
ref aaa001
ref aaa002
value «code»
ref aaa003
block {
do int_duplicate
ref aaa004
do float_equal_q
do exec_yank
block {
value «int»
do int_multiply
ref x1
value «int»
do int_divide
ref x3
block {
do int_divide
ref x4
block {
value «int»
value «code»
ref x1
do code_define
value «float»
ref x1
do code_do_count}
«int» 5
Feature: Random code generation
In order to generate samples for algorithm search
As a modeler
I want a flexible suite of random code generating methods
Scenario: it should be possible to specify the exact number of points created
Given a target size in points for code
When I create random code
And pass in an optional parameter specifying the desired points
block {
block {
ref x
ref x
value «proportion»
ref x
do int_multiply }
block {
block {
ref x
# encoding: UTF-8
module Machine::Nudge
class SplitTournament < Machine
def process (answers)
@criteria ||= []
@tournament_size ||= 20
winners = []
losers = []
# Even with the added strengths of Ruby 1.9.2, it turns out to be tricky to write a Cucumber
# story that specifies something like
#
# "Then no warning message should be produced"
#
# As a holdover until I find something safer, I've had to redirect Ruby's $stderr stream
# to a StringIO instance, examine that in the step definition, and reset it to the STDERR
# default after the fact.
require 'stringio'
base exponent class time avg of 10
12345 0 Fixnum 1.2000000000000002e-06
12345 12345 Bignum 0.0052603
12345 24690 Bignum 0.0153229
12345 37035 Bignum 0.024372699999999997
12345 49380 Bignum 0.0443783
12345 61725 Bignum 0.0581005
12345 74070 Bignum 0.0720144
12345 86415 Bignum 0.12198920000000002
12345 98760 Bignum 0.1334477
# draws a random polygon (with absolute size!) of a random color and transparency
def rand_poly
"-fill \"rgba(#{rand()*100}, #{rand()*100}, #{rand()*100}, #{rand()})\" -stroke none -draw \"polyline #{rand(640)},#{rand(480)} #{rand(640)},#{rand(480)} #{rand(640)},#{rand(480)} #{rand(640)},#{rand(480)}\" "
end
# drop some random polygons onto the stupid wizard logo image
`convert logo: #{rand_poly} #{rand_poly} #{rand_poly} logo.tif`
block {
value «code»
value «int»
value «matrix»
value «dna»
value «uri»}
«code» value «int»
«int» -1
«int» 1000