예제 #1
0
    def test_undo_destroy(self):
        tag = "fluffy"

        # Build something
        obj = self.add_object(shapes.cube(bid=(41, 0)), (0, 63, 0))
        self.set_looking_at(list(obj.blocks.keys())[0])

        # Tag it
        d = {
            "dialogue_type": "PUT_MEMORY",
            "filters": {"reference_object": {"coref_resolve": "that"}},
            "upsert": {"memory_data": {"memory_type": "TRIPLE", "has_tag": "fluffy"}},
        }
        self.handle_logical_form(d)
        self.assertIn(tag, obj.get_tags())

        # Destroy it
        d = {
            "dialogue_type": "HUMAN_GIVE_COMMAND",
            "action": {
                "action_type": "DESTROY",
                "reference_object": {"location": {"location_type": "SPEAKER_LOOK"}},
            },
        }
        self.handle_logical_form(d)
        self.assertIsNone(self.agent.memory.get_block_object_by_xyz(list(obj.blocks.keys())[0]))

        # Undo destroy (will ask confirmation)
        d = {"dialogue_type": "HUMAN_GIVE_COMMAND", "action": {"action_type": "UNDO"}}
        self.handle_logical_form(d)
        self.assertIsInstance(self.agent.dialogue_manager.dialogue_stack.peek(), AwaitResponse)

        # confirm undo
        # TODO change tests to record different speakers to avoid the sleep?
        time.sleep(0.02)
        self.add_incoming_chat("yes", self.speaker)
        self.flush()

        # Check that block object has tag
        newobj = self.agent.memory.get_block_object_by_xyz(list(obj.blocks.keys())[0])
        self.assertIsNotNone(newobj)
        self.assertIn(tag, newobj.get_tags())
예제 #2
0
    def test_undo_destroy(self):
        tag = "fluffy"

        # Build something
        obj = self.add_object(shapes.cube(bid=(41, 0)), (0, 63, 0))
        self.set_looking_at(list(obj.blocks.keys())[0])

        # Tag it
        d = PUT_MEMORY_COMMANDS["that is fluffy"]
        self.handle_logical_form(d)
        self.assertIn(tag, obj.get_tags())

        # Destroy it
        d = DESTROY_COMMANDS["destroy where I am looking"]
        self.handle_logical_form(d)
        self.assertIsNone(
            self.agent.memory.get_block_object_by_xyz(
                list(obj.blocks.keys())[0]))

        # Undo destroy (will ask confirmation)
        d = OTHER_COMMANDS["undo"]
        self.handle_logical_form(d)
        self.assertIsInstance(
            self.agent.dialogue_manager.dialogue_stack.peek(), AwaitResponse)

        # confirm undo
        # TODO change tests to record different speakers to avoid the sleep?
        time.sleep(0.02)
        self.add_incoming_chat("yes", self.speaker)
        self.flush()

        # Check that block object has tag
        newobj = self.agent.memory.get_block_object_by_xyz(
            list(obj.blocks.keys())[0])
        self.assertIsNotNone(newobj)
        self.assertIn(tag, newobj.get_tags())
예제 #3
0
 def setUp(self):
     super().setUp()
     self.cube_right = self.add_object(shapes.cube(bid=(42, 0)), (9, 63, 4))
     self.cube_left = self.add_object(shapes.cube(), (9, 63, 10))
     self.set_looking_at(list(self.cube_right.blocks.keys())[0])
예제 #4
0
 def setUp(self):
     super().setUp()
     self.cube_right: List[Block] = list(
         self.add_object(shapes.cube(bid=(42, 0)),
                         (9, 63, 4)).blocks.items())
     self.set_looking_at(self.cube_right[0][0])
예제 #5
0
# main.py Graham Seamans 2020

import cProfile
import pstats
import time

from shapes import tetrahedron, cube
from environment import environment


if __name__ == "__main__":
    profiler = cProfile.Profile()
    profiler.enable()

    env = environment()
    env.add_shape(cube())
    env.add_shape(tetrahedron(spin=-0.01))

    for i in range(10000):
        env.time_step()
        time.sleep(0.01)

    profiler.disable()
    stats = pstats.Stats(profiler)
    stats.strip_dirs().sort_stats("tottime").print_stats(10)
예제 #6
0
from flask import Flask
from flask import render_template
import os
from random import choice
from shapes import cube
from graphics import drawRubiks
from rotations import *
from scrambler import scramble, scramble2
from globals import colors
import pprint

app = Flask(__name__)
Rubiks = cube()
Rubiks.initialize()
scramble2(Rubiks)
Colors = colors() 

@app.route('/')
def index():
	squares = drawRubiks(Rubiks)
	return render_template('index.html', squares=squares)

@app.route('/update')
def update():
	#pprint.pprint(Rubiks.CubeArray[0].FaceMatrix) 
	rotateL(Rubiks)
	squares = drawRubiks(Rubiks)
	return squares

if __name__ == '__main__':
	port = int(os.environ.get('PORT', 5000))
예제 #7
0
 def add_cube(x, y, z):
     self.meshes.add(Mesh(shapes.cube(1), (x, y, z)))
예제 #8
0
 def load_meshes_2(self):
     cube = PhysicsMesh(shapes.cube(0.2), (0, 0, 4))
     cube.velocity = (0, 10, -1.5)
     cube.acceleration = (0, -9.81, 0)
     self.meshes.add(cube)