This file contains 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 matplotlib.pyplot as plt | |
import json | |
import cv2 | |
import math | |
# open the ./data_train.json | |
GRID = 64 | |
IMG_W = GRID * 20 |
This file contains 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
# a self play version of 20 quetsions with gpt playing against itself | |
from langchain.llms import OpenAI | |
# from langchain.chat_models import ChatOpenAI | |
llm = OpenAI(model_name="gpt-3.5-turbo-0301") | |
# an oracle | |
def get_oracle(concept): | |
def give_answer(question): | |
prompt = f"For a {concept}, \ | |
{question}. Answer with a single word [YES, NO]" |
This file contains 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
# get all possible next states | |
def get_next_state(tuple_state): | |
ret = [] | |
# for all index of tuple_state, subtract any number of stones 1 through maximum possible | |
for i in range(len(tuple_state)): | |
for j in range(1, tuple_state[i]+1): | |
# create new state | |
new_state = list(tuple_state) | |
new_state[i] -= j |
This file contains 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 | |
import string | |
# for the purpose of showing this is a "language model", all programs here are | |
# written as STRINGS, you need to call eval(prog) on them to get the actual program | |
def writer1(): | |
return ''.join(random.choice(string.printable) for i in range(9)) |
This file contains 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 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 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 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 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 |
NewerOlder