Skip to content

Instantly share code, notes, and snippets.

@rndmcnlly
rndmcnlly / lazy_graph.lp
Created July 23, 2013 00:01
A demonstration of automatic decomposition of universally quantified constraints according to the "disjunctive embedding" pattern. Constraints are specified as facts in the forall(Bindings,Expression) predicate. In this example, I encode the reflexivity, symmetry, and transitivity aspects of the definition of an equality relation in a simple gra…
#begin_lua
function args(t)
if Val.type(t) == Val.FUNC then
local res = t:args()
res.n = nil
return res
else
return {}
end
end
#begin_lua
function collect(pred,arity)
local t = {}
Assignment.begin(pred,arity)
while Assignment.next() do
if Assignment.isTrue() then
table.insert(t,Assignment.args())
end
@rndmcnlly
rndmcnlly / Playing with Sample Data.ipynb
Created January 19, 2014 12:43
Using IPython Notebook and PyMC to play around with some probabilistic graphical models. We're looking at ways of doing some serious machine learning *during gameplay* in the next version of DragonBox Adaptive.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rndmcnlly
rndmcnlly / interstellar.lp
Created June 2, 2014 18:53
ASP model of space trading simulation game (gringo 3 w/ lua)
#begin_lua function min(a,b) return math.min(a,b) end #end_lua.
%% Adam's minimal event calculus formalism:
%% - only true holds/happens are tracked
%% - all fluents are always inertial
%% - time is a totally ordered contiguous integer sequence
%% - events and fluents are self-contained terms
%% - T variables always come first for easy sorting
initiated(T,F) :- happens(T,E), initiates(T,E,F).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rndmcnlly
rndmcnlly / Optimization.ipynb
Created April 18, 2017 18:14
Tutorial from a lecture on Modeling Optimization Problems in an Applied Answer Set Programming course at UC Santa Cruz (Spring 2017)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rndmcnlly
rndmcnlly / Equivalence.ipynb
Created April 19, 2017 01:09
Check if two combinatorial circuits defined in Verilog are behaviorally equivalent (synthesis to a sea of gates using Yosys and search using Potassco)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rndmcnlly
rndmcnlly / Collect.ipynb
Last active April 19, 2017 21:26
Demo of using %%capture magic to collect output of a cell into a Python variable
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rndmcnlly
rndmcnlly / Integer Programming.ipynb
Created April 25, 2017 18:10
An example of modeling and solving integer linear constraints in ASP using a few different approaches
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.