View gist:d8a93a5097f869f35a894aad41e05507
struct Val
x : i32
y : i32
fn new (val)
let mval = (malloc (typeof val))
# option A: wrap pointer in a fancy reference type
let mval = (('from-pointer-type reference (typeof mval)) mval)
mval = val
a0 = 0.3
a1 = 0.7
a2 = 0.9
a3 = 0.1
c0 = 0.1
c1 = 0.2
c2 = 0.3
c3 = 0.4
from random import *
from math import *
# linear
if 0:
a = 0.2
b = 0.7
def analytic():

Shadow Chess

Version 1 (2017/11/15) by @BipolarMike and @paniq

Beware: This is an alpha version. The rules are completely untested.

Shadow Chess (also known as Quantum Chess, Imaginary Chess or M.A.D. Chess) works like regular chess, but with additional rules that are designed to produce new strategical opportunities and interesting outcomes:

View minmaxbounds.glsl
bool in_wedge(vec2 p, vec2 u) {
return (p.x >= u[0]*p.y) && (p.x <= u[1]*p.y);
bool in_frustum(vec3 p, vec2 u, vec2 v) {
return in_wedge(p.xz, u) && in_wedge(p.yz, v);
void merge_plane_range(inout vec2 outer, vec2 p0, vec2 p1, vec2 u) {
outer[0] = in_wedge(p0, u)?min(outer[0], p0.y):outer[0];
outer[1] = in_wedge(p1, u)?max(outer[1], p1.y):outer[1];
View bounding.glsl
void compute_bounding_points_compact(surface2x3 surf, vec2 u, vec2 v, out bounds2x3 bounds) {
float surf_c7_c7 = surf.c[7]*surf.c[7];
float surf_2x_c0 = 2.0*surf.c[0];
float surf_2x_c1 = 2.0*surf.c[1];
float surf_2x_c3 = 2.0*surf.c[3];
float surf_2x_c6 = 2.0*surf.c[6];
float surf_4x_c1 = 4.0*surf.c[1];

After solving the compaction puzzle for parallel processing of values in a partitioned stream, the path to a screenspace CSG quadtree kernel is now open.

Instead of separate tiles, products and factors, we now keep a single array of factors, of which each factor also has a product index and a tile coordinate. We operate on a 256x256 tile so our tile coordinates fit into 16 bit, and allow only a maximum of 65536 products for this tile, with 2^31 addressable brushes. A factor then requires only 8 bytes: 2 bytes for its product index, 2 bytes for its tile coordinate and 4 bytes for its signed brush id.

We seed the array with all factors that matter for this 256x256 tile, sorted by tile coordinate and product index so that factors which belong to the same product are packed together, and all products which belong to the same tile are packed together as well.

We also init a brush id image with tile size 1x1.

In the beginning, there is typically


Massively Parallel Processing of Partitioned Streams

by @paniq

We wish to perform sum/max/filter operations on streams that have been partitioned into groups of varying size, and do this in a massively parallel fashion.

Finding Partitions

View csgtree_pruning.txt
using "none.libc"
; generate random CSG trees, attempt to optimize and evaluate robustness and
; effectivity in comparison with a full evaluation.
var INSIDE -1
View 1ddistances.txt
; provided a list of boolean range operations, find the nearest depth
; at which the ray hits a 100% occluding volume
using "none.libc"
+++++++++++ (20 30)
--- (19 21)