python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
import random
from functools import lru_cache
import networkx as nx
class Tree(abc.ABC):
"""
Abstract Tree structure con... | CTrLBenchmark-master | ctrl/commons/tree.py |
# Copyright (c) Facebook, Inc. and its affiliates.
"""
Common components shared across the project.
""" | CTrLBenchmark-master | ctrl/commons/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import re
import plotly
def plotly_rgb_to_hex(rgb_colors):
"""
Convert a list of RGB strings in the format used by plotly ("rgb(<R>... | CTrLBenchmark-master | ctrl/commons/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from ctrl.strategies.task_creation_strategy import TaskCreationStrategy
class LabelPermutationStrategy(TaskCreationStrategy):
def __init... | CTrLBenchmark-master | ctrl/strategies/label_permutation_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from ctrl.strategies.task_creation_strategy import TaskCreationStrategy
class MixedStrategy(TaskCreationStrategy):
def __init__(self, st... | CTrLBenchmark-master | ctrl/strategies/mixed_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from ctrl.strategies.task_creation_strategy import TaskCreationStrategy
from ctrl.transformations.identity_transformation import \
load_or... | CTrLBenchmark-master | ctrl/strategies/input_domain_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from ctrl.concepts.concept import ComposedConcept
from ctrl.strategies.input_domain_strategy import TaskCreationStrategy
logg... | CTrLBenchmark-master | ctrl/strategies/random_mutation_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .incremental_strategy import IncrementalStrategy
from .input_domain_strategy import InputDomainMutationStrategy
from .label_permutation_s... | CTrLBenchmark-master | ctrl/strategies/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
import logging
import random
logger = logging.getLogger(__name__)
class TaskCreationStrategy(abc.ABC):
def __init__(self, do... | CTrLBenchmark-master | ctrl/strategies/task_creation_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from ctrl.strategies.task_creation_strategy import TaskCreationStrategy
class IncrementalStrategy(TaskCreationStrategy):
def __init__(se... | CTrLBenchmark-master | ctrl/strategies/incremental_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
from ctrl.strategies.task_creation_strategy import TaskCreationStrategy
class DataStrategy(TaskCreationStrategy):
def... | CTrLBenchmark-master | ctrl/strategies/data_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from ctrl.strategies.input_domain_strategy import TaskCreationStrategy
class AttributeStrategy(TaskCreationStrategy):
def __init__(self,... | CTrLBenchmark-master | ctrl/strategies/attributes_strategy.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import defaultdict
import networkx as nx
import numpy as np
from ctrl.strategies.task_creation_strategy import TaskCreationS... | CTrLBenchmark-master | ctrl/strategies/split_strategy.py |
"""
This module contains a bunch of code extracted from
https://github.com/TomVeniat/MNTDP in order to allow the usage of automatic
configuration and initialization on the CTrL benchmark.
"""
import collections
import os
from os import path
from copy import deepcopy
import yaml
from numpy.random import default_rng
fr... | CTrLBenchmark-master | ctrl/streams/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| CTrLBenchmark-master | ctrl/concepts/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
import hashlib
import numpy as np
import torch
from torch.distributions import Multinomial
class Concept(abc.ABC):
def __init... | CTrLBenchmark-master | ctrl/concepts/concept.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Trees of concepts
"""
import abc
import logging
from collections import defaultdict
import bs4
import networkx as nx
import numpy as np
... | CTrLBenchmark-master | ctrl/concepts/concept_tree.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
import torchvision
from ctrl.concepts... | CTrLBenchmark-master | ctrl/instances/image_dataset_tree.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import networkx as nx
import numpy as np
import torch
import torchvision
from ctrl.concepts.concept import ComposedConcept
from ctrl.concepts... | CTrLBenchmark-master | ctrl/instances/md_tree.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| CTrLBenchmark-master | ctrl/instances/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cifar100_taxonomy = {
'aquatic mammals': ['beaver', 'dolphin', 'otter', 'seal', 'whale'],
'fish': ['aquarium_fish', 'flatfish', 'ray',... | CTrLBenchmark-master | ctrl/instances/taxonomies.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import glob
import itertools
import os
from collections import defaultdict
import numpy as np
import torch
from torchvision.datasets import V... | CTrLBenchmark-master | ctrl/instances/DTD.py |
import pytest
import torch
import ctrl
def test_s_plus():
task_gen = ctrl.get_stream('s_plus')
tasks = list(task_gen)
assert len(tasks) == 6
assert tasks[0].src_concepts == tasks[-1].src_concepts
assert len(tasks[0].datasets[0]) < len(tasks[-1].datasets[0])
def test_s_minus():
task_gen = ct... | CTrLBenchmark-master | tests/test_ctrl.py |
CTrLBenchmark-master | tests/__init__.py | |
#Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# lis... | CTrLBenchmark-master | docs/source/conf.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from setuptools import find_packages, setup
setup(
name='dcem',
version='0.0.1',
description="The Differentiable Cross-Entropy Method",
author='Brandon Amos',
author_email='[email protected]',
platforms=['any'],
license="CC BY-NC 4... | dcem-main | setup.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import argparse
import typing
import copy
import numpy as np
import numpy.random as npr
import torch
from torch import nn
from torch.utils.data import DataLoader
import torch.nn.functional as F
import torch.optim as optim
from torchvision imp... | dcem-main | exps/regression.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
import numpy.random as npr
import torch
from torch import nn, optim
from torch.nn import functional as F
from torch.autograd import grad, Function
from torch.optim.lr_scheduler import ReduceLROnPlateau
import argparse
import... | dcem-main | exps/cartpole_emb.py |
# Copyright (c) Facebook, Inc. and its affiliates.
from .dcem import dcem
from .dcem_ctrl import dcem_ctrl
| dcem-main | dcem/__init__.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
import torch
from dcem import dcem
import sys
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
color_scheme='Linux', call_pdb=1)
def bmv(X, y):
return X.bmm(y.unsqueeze(2)).squee... | dcem-main | dcem/test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import torch
from dcem import dcem
def dcem_ctrl(
obs,
plan_horizon,
init_mu,
init_sigma,
n_sample,
n_elite,
n_iter,
n_ctrl,
temp,
rollout_cost,
lb=None,
ub=None,
iter_cb=None,
dcem_iter_eps=1e-3,
dcem_norma... | dcem-main | dcem/dcem_ctrl.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
import torch
from torch import nn
from torch.distributions import Normal
from lml import LML
def dcem(
f,
nx,
n_batch=1,
n_sample=20,
n_elite=10,
n_iter=10,
temp=1.,
lb=None,
ub=None,
init_mu=None,
init... | dcem-main | dcem/dcem.py |
import sys
from os import curdir, sep
import qrcode
from PIL import Image
from http.server import BaseHTTPRequestHandler, HTTPServer
PORT = 8000
class HTTPHandler(BaseHTTPRequestHandler):
def do_GET(self):
if (self.path.endswith(".png")):
self.send_response(200)
self.send_header('Content-type','image/png')
... | craftassist-master | cuberite_plugins/minecraft_asr_app/start_qr_web.py |
"""
generate QR code image and start the webserver to display the image
usage: run python qr_web.py -info <info to put in the qr code image>
to start the webserver and generate the QR Code image.
add the flag -update (webserver is already running, just need to regenerate the QR Code image)
"""
import sys
from os import... | craftassist-master | cuberite_plugins/minecraft_asr_app/qr_web.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This file generates a craft_recipes.h file that is used by the C++ client.
"""
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("items_ini")
parser.add_argument("crafting_txt")
parser.add_argument(
"-o", "--out-file", required=True, help=... | craftassist-master | python/generate_recipes.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import argparse
import glob
import logging
import numpy as np
import os
import random
import subprocess
import sys
python_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.insert(0, python_dir)
from cuberite_process import CuberitePro... | craftassist-master | python/render_one_block_change.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
""" Visualize Segmentation """
import numpy as np
import pickle
import os
import sys
import json
import random
import glob
from tqdm import tqdm
possible_types = [(35, i) for i in range(1, 16)]
possible_types.extend(
[
(1, 0),
(2, 0),
... | craftassist-master | python/visual_segmentation.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import atexit
import logging
import numpy as np
import os
import shutil
import subprocess
import tempfile
import time
import edit_cuberite_config
import place_blocks
import repo
from wait_for_cuberite import wait_for_cuberite
from craftassist.shape_helpers imp... | craftassist-master | python/cuberite_process.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import random
import atexit
from agent import Agent
from cuberite_process import CuberiteProcess
random.seed(0)
p = CuberiteProcess("flat_world", seed=0, game_mode="creative")
atexit.register(lambda: p.destroy()) # close Cuberite server when this script exit... | craftassist-master | python/example_agent_random.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This .ini file config parser accepts multiple keys with the same name, unlike
Python's configparser.
"""
import contextlib
@contextlib.contextmanager
def inplace_edit(path):
with open(path, "r") as f:
config = read_config(f.readlines())
yield confi... | craftassist-master | python/config_parser.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import socket
# Raw bytes of handshake and ping packets, see http://wiki.vg/Protocol#Ping
HANDSHAKE_PING = b"\x10\x00\xd4\x02\tlocalhost\x63\xdd\x01\t\x01\x00\x00\x00\x00\x00\x00\x00*"
# Raw bytes of clientbound pong packet, see http://wiki.vg/Protocol#Pong
PO... | craftassist-master | python/ping_cuberite.py |
craftassist-master | python/__init__.py | |
"""
Copyright (c) Facebook, Inc. and its affiliates.
Tool to convert betweeen .schematic and .npy formats
The output is a .npy formatted 4d-array of uint8 with shape (y, z, x, 2), where
the last dimension is id/meta.
"""
import argparse
import os
import subprocess
import tempfile
import gzip
from repo import repo_ho... | craftassist-master | python/schematic_convert.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import time
import agent
DEFAULT_PORT = 25565
def agent_init(port=DEFAULT_PORT):
""" initialize the agent on localhost at specified port"""
return agent.Agent("localhost", port, default_agent_name())
def default_agent_name():
"""Use a unique nam... | craftassist-master | python/agent_connection.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import os
python_dir = os.path.dirname(os.path.realpath(__file__))
repo_home = os.path.join(python_dir, "..")
def path(p):
return os.path.join(repo_home, p)
| craftassist-master | python/repo.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has functions that an help edit the config
got cuberite."""
import config_parser
def set_seed(path, seed):
with config_parser.inplace_edit(path) as config:
config["Seed"]["Seed"] = seed
def add_plugin(path, plugin):
with config_p... | craftassist-master | python/edit_cuberite_config.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import argparse
import glob
import logging
import numpy as np
import os
import pathlib
import subprocess
import sys
python_dir = pathlib.Path(__file__).parents[0].absolute()
sys.path.insert(0, python_dir)
from cuberite_process import CuberiteProcess
from repo ... | craftassist-master | python/render_schematic.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
def yzx_to_dicts(yzx, y_offset=63):
"""Converts yzx format array into a dictionary
with keys: x, y, z, id and meta"""
yzx = yzx["schematic"]
ysize, zsize, xsize, _ = yzx.shape
if ysize + y_offset > 255:
raise ValueError("Shape is too... | craftassist-master | python/place_blocks.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import socket
import time
import ping_cuberite
def wait_for_server(host, port, wait_ms=200, max_tries=200):
"""This function tries max_tries times to connect to the
host at the port using a socket connection"""
for i in range(max_tries):
t... | craftassist-master | python/wait_for_cuberite.py |
import argparse
import os
class ArgumentParser:
def __init__(self, agent_type, base_path):
self.agent_parsers = {"Minecraft": self.add_mc_parser, "Locobot": self.add_loco_parser}
self.base_path = base_path
self.parser = argparse.ArgumentParser()
# NSP args
self.add_nsp_par... | craftassist-master | python/argument_parser.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import os
import sys
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(BASE_AGENT_ROOT)
from base_agent.stop_condition import StopCondition
class AgentAdjacentStopCondition(StopCondition):
def __init__(self, agent, bid):
... | craftassist-master | python/craftassist/mc_stop_condition.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from test.fake_agent import FakeAgent
# from craftassist.test.fake_agent import FakeAgent
from typing import Dict
from mc_util import Player, Pos, Look, Item, XYZ, IDM
from world import World, Opt, flat_ground_generator
class BaseSQLMockEnvironment:
def _... | craftassist-master | python/craftassist/base_sql_mock_environment.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import numpy as np
import os
import pickle
PATH = os.path.join(os.path.dirname(__file__), "../../minecraft_specs")
assert os.path.isdir(PATH), (
"Not found: "
+ PATH
+ "\n\nDid you follow the instructions at "
+ "https://github.com/fairinternal/... | craftassist-master | python/craftassist/minecraft_specs.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has implementation for a variety of shapes and
their arrangements"""
import math
import numpy as np
from typing import Optional, Tuple
IDM = Tuple[int, int]
DEFAULT_IDM = (5, 0)
# TODO cylinder
# TODO: add negative versions of each of the shapes
#... | craftassist-master | python/craftassist/shapes.py |
import os
import sys
from mc_util import (
XYZ,
IDM,
to_block_pos,
pos_to_np,
euclid_dist,
diag_adjacent,
capped_line_of_sight,
)
from typing import Tuple, List
from block_data import BORING_BLOCKS
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(BASE_AGENT_R... | craftassist-master | python/craftassist/low_level_perception.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import logging
import os
import sys
import numpy as np
import time
from random import randint
from block_data import (
PASSABLE_BLOCKS,
BUILD_BLOCK_REPLACE_MAP,
BUILD_IGNORE_BLOCKS,
BUILD_INTERCHANGEABLE_PAIRS,
)
from build_utils import blocks_... | craftassist-master | python/craftassist/tasks.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file contains functions to map strings representing abstract
sizes to ints and ranges"""
import numpy as np
RANGES = {
"tiny": (1, 3),
"small": (3, 4),
"medium": (4, 6),
"large": (6, 10),
"huge": (10, 16),
"gigantic": (16, 32),
... | craftassist-master | python/craftassist/size_words.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# TODO correct model paths
import os
import sys
import logging
import faulthandler
import signal
import random
import re
import sentry_sdk
import numpy as np
# FIXME
import time
from multiprocessing import set_start_method
import inventory
import mc_memory
fr... | craftassist-master | python/craftassist/craftassist_agent.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from typing import Dict, Callable
import shapes
# mapping from mob names to id
SPAWN_OBJECTS = {
"elder guardian": 4,
"wither skeleton": 5,
"stray": 6,
"husk": 23,
"zombie villager": 27,
"skeleton horse": 28,
"zombie horse": 29,
... | craftassist-master | python/craftassist/word_maps.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has functions to implement different dances for the agent.
"""
import numpy as np
import tasks
import shapes
import search
from mc_util import ErrorWithResponse
# FIXME! actual jump on client
jump = [{"translate": (0, 1, 0)}, {"translate": (0, -1, ... | craftassist-master | python/craftassist/dance.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import logging
import os
import sys
import numpy as np
import random
import shape_helpers as sh
import tasks
from mc_util import pos_to_np
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(BASE_AGENT_ROOT)
from base_agent.dialog... | craftassist-master | python/craftassist/default_behaviors.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
This is a utility script which allows the user to easily query the ttad model
At the prompt, try typing "build me a cube"
"""
import faulthandler
import fileinput
import json
import signal
from ttad.ttad_model.ttad_model_wrapper import ActionDictBuilder
faulthan... | craftassist-master | python/craftassist/ttad_repl.py |
import os
import sys
sys.path.append(os.path.dirname(__file__))
| craftassist-master | python/craftassist/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import os
import random
import sys
from typing import Optional, List
from build_utils import npy_to_blocks_list
import minecraft_specs
import dance
PERCEPTION_RANGE = 64
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(BASE_AGENT_... | craftassist-master | python/craftassist/mc_memory.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import heapq
import math
import numpy as np
from scipy.ndimage.filters import median_filter
from scipy.optimize import linprog
import logging
import minecraft_specs
from mc_util import (
manhat_dist,
get_locs_from_entity,
build_safe_diag_adjacent,
... | craftassist-master | python/craftassist/heuristic_perception.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from preprocess import word_tokenize
from ttad.generation_dialogues.generate_dialogue import action_type_map # Dict[str, Class]
from ttad.generation_dialogues.templates.templates import template_map # Dict[str, List[Template]]
from typing import Dict, List, T... | craftassist-master | python/craftassist/adtt.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from base_sql_mock_environment import BaseSQLMockEnvironment
from typing import Dict
class SQLConverter(BaseSQLMockEnvironment):
"""A script with basic commands dealing with reference objects.
"""
def __init__(self):
super().__init__()
... | craftassist-master | python/craftassist/sql_script.py |
import os
import sys
import numpy as np
import logging
from collections import Counter
from typing import cast, List, Sequence, Dict
# FIXME fix util imports
from mc_util import XYZ, LOOK, POINT_AT_TARGET, IDM, Block
import minecraft_specs
from entities import MOBS_BY_ID
BASE_AGENT_ROOT = os.path.join(os.path.dirnam... | craftassist-master | python/craftassist/mc_memory_nodes.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import csv
import numpy as np
SHAPENET_PATH = "" # add path to shapenet csv here
def read_shapenet_csv(csvpath=SHAPENET_PATH + "metadata.csv"):
keyword_to_id = {}
id_to_keyword = {}
with open(csvpath, "r") as cfile:
cvs_metadata = csv.re... | craftassist-master | python/craftassist/build_utils.py |
import logging
import socket
import json
import os
HOST = "127.0.0.1" # The server's hostname or IP address
PORT = 2557 # The port used by the server
dirname = os.path.dirname(__file__)
web_app_filename = os.path.join(dirname, "webapp_data.json")
# create a socket
s = socket.socket()
print("web app socket: created... | craftassist-master | python/craftassist/web_app_socket.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import heapq
import logging
import numpy as np
import time
from block_data import PASSABLE_BLOCKS
from mc_util import adjacent, manhat_dist
def depth_first_search(blocks_shape, pos, fn, adj_fn=adjacent):
"""Do depth-first search on array with blocks_shape... | craftassist-master | python/craftassist/search.py |
import numpy as np
from collections import Counter
from build_utils import blocks_list_to_npy # , npy_to_blocks_list
##############################################
# WARNING: all npy arrays in this file are xyz
# not yzx
def maybe_convert_to_npy(blocks):
if type(blocks) is list:
blocks, _ = blocks_list_... | craftassist-master | python/craftassist/shape_transforms.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has Minecraft entities"""
# TODO: pull from cuberite source?
# Map of mob id to mob name
MOBS_BY_ID = {
50: "creeper",
51: "skeleton",
52: "spider",
53: "giant",
54: "zombie",
55: "slime",
56: "ghast",
57: "pig zombi... | craftassist-master | python/craftassist/entities.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""This file has helper functions for shapes.py"""
import random
import numpy as np
import shapes
FORCE_SMALL = 10 # for debug
# Map shape name to function in shapes.py
SHAPE_FNS = {
"CUBE": shapes.cube,
"HOLLOW_CUBE": shapes.hollow_cube,
"RECTAN... | craftassist-master | python/craftassist/shape_helpers.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import copy
import os
import sys
from math import sin, cos, pi
from typing import cast, Sequence
BASE_AGENT_ROOT = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(BASE_AGENT_ROOT)
from base_agent.base_util import *
import rotation
TICKS_PER_MC_... | craftassist-master | python/craftassist/mc_util.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import numpy as np
from numpy import sin, cos, deg2rad
DIRECTIONS = {
"AWAY": np.array([0, 0, 1]),
"FRONT": np.array([0, 0, 1]),
"BACK": np.array([0, 0, -1]),
"LEFT": np.array([1, 0, 0]),
"RIGHT": np.array([-1, 0, 0]),
"DOWN": np.array([... | craftassist-master | python/craftassist/rotation.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
NORMAL_BLOCKS_N = 454
PASSABLE_BLOCKS = (0, 8, 9, 31, 37, 38, 39, 40, 55, 106, 171, 175)
BORING_BLOCKS = (0, 1, 2, 3, 6, 12, 31, 32, 37, 38, 39, 40)
REMOVABLE_BLOCKS = BORING_BLOCKS + (106,)
# don't bother trying to remove vines, since they grow
BUILD_IGNORE_B... | craftassist-master | python/craftassist/block_data.py |
from typing import Tuple, List
from mc_util import IDM
ITEM_STACK_NODE = Tuple[str, int] # (memid, count)
ITEM_QUEUE = Tuple[
int, List[ITEM_STACK_NODE]
] # (queue_size, [item_stack_node_1, item_stack_node_2, ...])
class Inventory:
def __init__(self):
self.items_map = {}
def add_item_stack(sel... | craftassist-master | python/craftassist/inventory.py |
from base_agent.nsp_dialogue_manager import NSPDialogueManager
from base_agent.loco_mc_agent import LocoMCAgent
import os
import unittest
import logging
from all_test_commands import *
class AttributeDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
class FakeAgent(LocoMCAgent):
... | craftassist-master | python/craftassist/test/test_dialogue_manager.py |
import numpy as np
from typing import Sequence, Dict
from mc_util import Block, XYZ, IDM
from rotation import look_vec
from fake_mobs import make_mob_opts, MOB_META, SimpleMob
FLAT_GROUND_DEPTH = 8
class Opt:
pass
def flat_ground_generator_with_grass(world):
flat_ground_generator(world, grass=True)
def f... | craftassist-master | python/craftassist/test/world.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import os
from world import Opt
from base_craftassist_test_case import BaseCraftassistTestCase
GROUND_TRUTH_DATA_DIR = os.path.join(os.path.dirname(__file__), "../datasets/ground_truth/")
"""This class tests common greetings. Tests check whethe... | craftassist-master | python/craftassist/test/test_greeting.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import shapes
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
class GetMemoryTestCase(BaseCraftassistTestCase):
def setUp(self):
super().setUp()
self.cube_right = self.add_obje... | craftassist-master | python/craftassist/test/test_get_memory.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
from craftassist_agent import CraftAssistAgent
class Opt:
pass
class BaseAgentTest(unittest.TestCase):
def test_init_agent(self):
opts = Opt()
opts.no_default_behavior = False
opts.semseg_model_path = None
... | craftassist-master | python/craftassist/test/test_agent.py |
from base_agent.dialogue_objects import SPEAKERLOOK, AGENTPOS
from copy import deepcopy
FILTERS = {
"that cow": {"has_name": "cow", "contains_coreference": "resolved", "location": SPEAKERLOOK},
"that cube": {"has_name": "cube", "contains_coreference": "resolved", "location": SPEAKERLOOK},
"a cow": {"has_na... | craftassist-master | python/craftassist/test/all_test_commands.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
from unittest.mock import Mock
import tasks
from base_agent.dialogue_objects import BotStackStatus
from dialogue_stack import DialogueStack
from mc_memory import MCAgentMemory
class BotStackStatusTest(unittest.TestCase):
def setUp(self):
... | craftassist-master | python/craftassist/test/test_dialogue_objects.py |
import numpy as np
from utils import Pos, Look
from entities import MOBS_BY_ID
FLAT_GROUND_DEPTH = 8
FALL_SPEED = 1
# TODO make these prettier
MOB_COLORS = {
"rabbit": (0.3, 0.3, 0.3),
"cow": (0.9, 0.9, 0.9),
"pig": (0.9, 0.5, 0.5),
"chicken": (0.9, 0.9, 0.0),
"sheep": (0.6, 0.6, 0.6),
}
MOB_META =... | craftassist-master | python/craftassist/test/fake_mobs.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
from base_craftassist_test_case import BaseCraftassistTestCase
from world import Opt
import os
GROUND_TRUTH_DATA_DIR = os.path.join(os.path.dirname(__file__), "../datasets/ground_truth/")
"""This class tests safety checks using a preset list of... | craftassist-master | python/craftassist/test/test_safety.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import shapes
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
class PutMemoryTestCase(BaseCraftassistTestCase):
def setUp(self):
super().setUp()
self.cube_right = self.add_obje... | craftassist-master | python/craftassist/test/test_put_memory.py |
import numpy as np
import pickle
from world import build_coord_shifts
# TODO replay instantiates world, replays in world
class Recorder:
def __init__(self, agent=None, filepath=None):
assert agent or filepath
self.agent = agent
self.tape = {}
if filepath:
self.load_from... | craftassist-master | python/craftassist/test/recorder.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
from fake_mobs import LoopMob, make_mob_opts
from base_agent.base_util import TICKS_PER_SEC
def add_sequence_mob(test, mobname, sequence):
m = Lo... | craftassist-master | python/craftassist/test/test_conditions.py |
import os
import sys
dir_test = os.path.dirname(__file__)
dir_craftassist = os.path.join(dir_test, "..")
dir_root = os.path.join(dir_craftassist, "..")
sys.path.append(dir_craftassist)
sys.path.append(dir_root)
sys.path.insert(0, dir_test) # insert 0 so that Agent is pulled from here
print("sys path {}".format(sys.... | craftassist-master | python/craftassist/test/__init__.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import shapes
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
class CorefResolveTestCase(BaseCraftassistTestCase):
def setUp(self):
super().setUp()
self.cube_right = self.add_o... | craftassist-master | python/craftassist/test/test_coref_resolve.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import time
import shapes
from base_agent.dialogue_objects import AwaitResponse
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
class UndoTest(BaseCraftassistTestCase):
def test_undo_destroy(se... | craftassist-master | python/craftassist/test/test_undo.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
from collections import namedtuple
from unittest.mock import Mock
Player = namedtuple("Player", "entityId, name, pos, look, mainHand")
Mob = namedtuple("Mob", "entityId, mobType, pos, look")
Pos = namedtuple("Pos", "x, y, z")
Look = namedtuple("Look", "yaw, pi... | craftassist-master | python/craftassist/test/utils.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
"""Minimal agent stub only used to test CraftAssistAgent's __init__ function. It must be called "Agent" to mimic the agent.so import.
For a full-featured test agent to import in other unit tests, use FakeAgent.
"""
class Agent(object):
def __init__(self, ... | craftassist-master | python/craftassist/test/agent.py |
# Adapted from Michael Fogleman (https://github.com/fogleman/Minecraft)
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, ... | craftassist-master | python/craftassist/test/world_visualizer.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import shapes
from mc_memory import MCAgentMemory
from utils import Mob, Pos, Look
from entities import MOBS_BY_ID
from base_craftassist_test_case import BaseCraftassistTestCase
from all_test_commands import *
class ObjectsTest(BaseCraftassist... | craftassist-master | python/craftassist/test/test_memory.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import logging
import numpy as np
from typing import List
from mc_util import XYZ, IDM, Block
from utils import Look, Pos, Item, Player
from base_agent.loco_mc_agent import LocoMCAgent
from base_agent.base_util import TICKS_PER_SEC
from mc_memory import MCAgent... | craftassist-master | python/craftassist/test/fake_agent.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
from unittest.mock import Mock
import heuristic_perception
import shapes
from base_agent.dialogue_objects import SPEAKERLOOK
from base_craftassist_test_case import BaseCraftassistTestCase
from dialogue_objects.interpreter_helper import NextDialog... | craftassist-master | python/craftassist/test/test_interpreter.py |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
import unittest
import size_words
class TestSizeWords(unittest.TestCase):
def assert_in_range(self, x, rng):
a, b = rng
self.assertTrue(a <= x < b)
def test_str_to_int(self):
x = size_words.size_str_to_int("big")
self.... | craftassist-master | python/craftassist/test/test_size_words.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.