typegraph/scripts/typing/getRandomType.gml

33 lines
684 B
Plaintext
Raw Permalink Normal View History

///getRandomType(conset)
/**
* getRandomType :: Set TypeCon1Link -> TypeConLink
*
*/
var conset = argument0;
var con;
if (irandom_range(0, sqrt(ds_set_size(conset))) == 0) {
con = new(choose(TypeConLink, TypeCon1Link, TypeCon1Link, TypeCon1Link));
if (instanceof(con, TypeCon1Link)) {
con.type = new(choose(FreeType, ConcreteType));
ds_set_add(conset, con);
}
else {
if (random(1) < 0.50) {
addLink(con, function);
addLink(con, getRandomType(conset));
addLink(con, getRandomType(conset));
}
else
repeat (irandom_range(1, 3))
addLink(con, getRandomType(conset));
}
}
else
con = ds_set_choose(conset);
return con;