This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rectangle import is_inside, is_correct, inside, outside, W | |
import random | |
def random_writer(spec): | |
# ignores the spec | |
T, D, L, R = random.randint(0,W), random.randint(0,W), random.randint(0,W), random.randint(0,W) | |
return [T, D, L, R] | |
def better_writer(spec): | |
# get the coordinates of spec that are inside |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# some globals | |
W = 6 | |
inside = True | |
outside = False | |
def interpret(program, inputt): | |
T, D, L, R = program | |
i, j = inputt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# some globals | |
W = 6 | |
def exe(prog, x): | |
T, D, L, R = prog | |
i, j = x | |
return i >= L and i <= R and j >= T and j <= D | |
# check if a spec is satisfied |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the tiling environment, a grid world where you place tetris pieces | |
import random | |
# the dimension of the grid | |
L = 6 | |
# hardcoding a few pieces, it's fine | |
PIECES = [ | |
[[1,1,1,1]], # horizontal line |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
np.random.seed(0) | |
def generate_pair(): | |
# make two random numbers x and y | |
# make x first randomly from 1 to 10 | |
x = np.random.randint(1, 11) | |
y = np.random.randint(1, 11) | |
x_y = x + y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
track = track4() | |
car = newCar(track) | |
startDisplay(track, car) | |
def control(sd, pastsd): | |
# average these values to be more smooth | |
leftt = sd[0] + pastsd[0]; | |
mid = sd[1] + pastsd[1]; | |
# this bit of assymetry is actually very clever, because | |
# "intuitively" assymetrical things has more information on it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
from queue import PriorityQueue | |
# here is the task | |
# we want to construct a goal number, starting from a template of expression | |
# i.e. (E * E) + E = 11 | |
# we can expand the expression E node further following the grammar | |
# E -> E + E | E * E | -3 | -2 | -1 | 1 | 2 | 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
from queue import PriorityQueue | |
# here is the task | |
# we want to construct a goal number, starting from a template of expression | |
# i.e. (E * E) + E = 11 | |
# we can expand the expression E node further following the grammar | |
# E -> E + E | E * E | -3 | -2 | -1 | 1 | 2 | 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare-sort Person) | |
(declare-fun ancestor (Person Person) Bool) | |
;; anti symmetry | |
(assert (forall ((x Person) (y Person)) | |
(=> (ancestor x y) (not (ancestor y x))))) | |
;; transitivity | |
(assert (forall ((x Person) (y Person) (z Person)) | |
(=> (and (ancestor x y) (ancestor y z)) |