Skip to content

Instantly share code, notes, and snippets.

player(x).
player(o).
#domain player(P).
next(x,o).
next(o,x).
first_player(x).
{ happens(mark(P,C),T) } :-
pos(go).
pos(jail).
pos(park_place).
pos(boardwalk(santa_cruz)).
ui_space(P) :- pos(P).
ui_title('Monopoly!!!!!').
piece(dog).
@rndmcnlly
rndmcnlly / Dac.java
Created April 23, 2010 00:40
DSP Engine from Ethereal Dialpad
package as.adamsmith.etherealdialpad.dsp;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
public class Dac extends UGen {
private final float[] localBuffer;
private boolean isClean;
var sys = require('sys');
var http = require('http');
var buffer = require('buffer');
var child_process = require('child_process');
var Buffer = buffer.Buffer;
var PORT = 8765;
var SAMPLE_RATE = 44100;
@rndmcnlly
rndmcnlly / chromatic-maze-generator.lp
Created August 31, 2010 05:06
chromatic maze generator in ASP
%%%%
%%%% A chromatic maze generator
%%%%
% By Adam M. Smith ([email protected])
% This answer set program was designed to work with the Potassco (the Potsdam
% Answer Set Solving Collection) tools, namely "clingo".
%% Chromatic Mazes
@rndmcnlly
rndmcnlly / USAGE
Created December 9, 2011 06:53
Stone Network Puzzle
$ clingo instance.lp encoding.lp visualization.lp | lonsdaleite -cu
http://chart.googleapis.com/chart?chl=graph{node[shape=circle,style=filled,fillcolor=white,fixedsize=true];64[pos=%222,8!%22];58[pos=%225,7!%22];48[pos=%224,6!%22,fillcolor=black,fontcolor=white];47[pos=%223,6!%22];46[pos=%222,6!%22,fillcolor=black,fontcolor=white];45[pos=%221,6!%22];39[pos=%224,5!%22];37[pos=%222,5!%22];36[pos=%221,5!%22,fillcolor=black,fontcolor=white];33[pos=%227,4!%22];30[pos=%224,4!%22,fillcolor=black,fontcolor=white];27[pos=%221,4!%22,fillcolor=black,fontcolor=white];23[pos=%226,3!%22,fillcolor=black,fontcolor=white];22[pos=%225,3!%22];21[pos=%224,3!%22];19[pos=%222,3!%22];15[pos=%227,2!%22];14[pos=%226,2!%22,fillcolor=black,fontcolor=white];6[pos=%227,1!%22,fillcolor=black,fontcolor=white,shape=doublecircle];4[pos=%225,1!%22];47--48;46--47;45--46;39--48;37--46;36--45;36--37;30--39;27--36;22--23;21--30;21--22;14--23;14--15;6--15}&cht=gv:neato
@rndmcnlly
rndmcnlly / Instructions.scala
Created May 4, 2012 22:34
snapshot of cfml in scala
package as.adamsmith.riddle.instructions
import java.util.concurrent._
object InstructionBuilders {
def after[A](children: Instruction[A]*) = children.reduce(After(_, _))
def during[A](children: Instruction[A]*) = children.reduce(During(_, _))
def choose[A](children: Instruction[A]*) =
Resolve(() => children((math.random * children.length).asInstanceOf[Int]) )
def call[A](f: => Instruction[A]) = Resolve(() => f)
@rndmcnlly
rndmcnlly / run.java
Created July 29, 2012 02:40
renderscript audio synthesis demo
// this is a snippet from RSAudioDemoActivity#run
Process.setThreadPriority(Process.THREAD_PRIORITY_AUDIO);
short samples[] = new short[BLOCK_FRAMES];
Allocation out = Allocation.createSized(renderScript, Element.I16(renderScript), samples.length, Allocation.USAGE_SCRIPT);
synth.set_block_frames(BLOCK_FRAMES);
synth.bind_block_out(out);
synth.set_sample_rate(SAMPLE_RATE_IN_HZ);
@rndmcnlly
rndmcnlly / coin_flip.lua
Created May 30, 2013 21:53
# airscript
-- Sample script to make an HTTP request with query parameters
local response = http.request {
url = 'http://www.random.org/integers/',
params = {
num=1, min=0, max=1, format='plain',
rnd='new', col=1, base=10
}
}
if tonumber(response.content) == 0 then
return 'heads'
@rndmcnlly
rndmcnlly / uq_demo.lp
Last active December 20, 2015 02:49
A demonstration of manually applying the "disjunctive embedding" pattern to a transitive closure problem. The pattern replaces a normal rule with a cubic number of groundings with more complex rules requiring only quadratic groundings. In general, the pattern changes the worst-case number of groundings from O(n^|unique_vars_in_rule|) to O(n^max_…
node(1..100).
1 { arc(A,B):node(A):node(B) }.
%arc(A,C) :- arc(A,B), arc(B,C).
%% intent: forall( nodes(a,b,c), implies( and(arc(a,b), arc(b,c)), arc(a,c) ) ).
var(a;b;c).
bind(V,N):node(N) :- var(V).
bot :- bind(a,A), bind(b,B), not arc(A,B).