Exemple #1
0
    def do_offset_z(self, line):
        offset = float(line)
        arm, position = self.get_arm('left')

        destination = list(position)
        destination[2] += offset
        movement.move(arm, destination, True)
Exemple #2
0
def Main():
    iframe = 0

    camera = PiCamera()

    camera.resolution = (416, 416)

    camera.capture('frame.jpg')
    sleep(0.1)

    iframe = 0
    child = pexpect.spawnu('bash')
    child.logfile = sys.stdout
    child.sendline(
        "./darknet detect ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights -thresh 0.15"
    )

    while (True):
        child.expect("Enter Image Path")
        child.sendline("frame.jpg")
        sleep(0.1)

        try:
            obj = mainObject("/home/pi/Desktop/deneme.txt")
            print(obj.confidence)
            move(obj)

        except Exception as e:
            print(str(e))

        im = cv2.imread('predictions.png')
        cv2.imshow('yolov3-tiny', im)
        key = cv2.waitKey(20)
        camera.capture('frame.jpg')
Exemple #3
0
 def run():  # Function to store the code for the run of Mission 2
     movement.move(
         10, 0,
         38)  # Using movement.move as it is more accurate than EV3 move()
     #movement.move(0, 200, 430)
     movement.accelerate(
         0, 200, 0.01, 400, 10, False,
         False)  # Accelerating in order to have greater control
     movement.move(-15, 0, 41.5)
     movement.accelerate(0, 135, 0.01, 100, 9, False, False)
     movement.accelerate(135, 0, 0.01, 83, 9, True, False)
     resetAngles()
     wait(2200)
     angle_to_turn = 221.125  # Soft-coded variables to make it easier to change movement values.
     for i in range(2):
         left_attachment.run_angle(300, angle_to_turn, Stop.BRAKE, False)
         right_attachment.run_angle(300, angle_to_turn, Stop.BRAKE, True)
         left_attachment.run_angle(-300, angle_to_turn, Stop.BRAKE, False)
         if i != 1:
             right_attachment.run_angle(-300, angle_to_turn, Stop.BRAKE,
                                        True)
         else:
             right_attachment.run_angle(-300, angle_to_turn, Stop.BRAKE,
                                        False)
     movement.move(0, -200, 100)
     movement.move(-90, 0, 90)
     movement.move(0, 200, 200)
Exemple #4
0
def on_message(client, userdata, msg):
    """ Callback called for every PUBLISH received """
    print("got a message")

    message = msg.payload.decode("UTF-8")

    #BACKSTABBER
    if message == "Move":
        print("Sure thing, my friend")

        movement.move()

    print("%s => %s" % (msg.topic, message))
Exemple #5
0
 def white():  # Function to store the run of Mission 12, white.
     value = 61  # Value to store the turning amount, soft-coded to make it easier to change values.
     value = 48
     value = 50
     movement.move(
         20, 0, value
     )  # Movement.move taking the following input parameters (steering, speed, amount)
     movement.accelerate(
         0, 200, 0.001, 220, 7, False,
         False)  # Accelerating to allow greater control over the blocks
     movement.accelerate(200, 0, 0.001, 210, 5, False, False)
     movement.accelerate(
         0, -200, 0.001, 100, 10, False, False
     )  # Accelerating back, allows for smooth movement, to not displace the blocks.
     movement.move(0, -1000, 3000)
Exemple #6
0
    def move(self):
        """Move the bot 1 space forward

        Raises:
            InvalidMovement -- if the bot can't be moved
                               (ie. it hasn't been placed or the move would
                               result in being out of bounds)
        """
        self._location = movement.move(self._facing, self._location)
Exemple #7
0
    def do_move(self, line):
        """ move arm x y z
        arm: left or right. Defaults to right.
        x y z: should be kept in range [.2, 1.)
    """
        args = line.split()
        if len(args) == 4:
            arm = args.pop(0)
        else:
            arm = ""

        position = [float(coordinate) for coordinate in args]

        if arm == "left":
            arm = self.left_arm
        else:
            arm = self.right_arm

        movement.move(arm, position)
Exemple #8
0
def move():
    data = bottle.request.json

    """
    TODO: Using the data from the endpoint request object, your
            snake AI must choose a direction to move in.
    """
    # print(json.dumps(data))
    # print(json.dumps(data, indent=4, sort_keys=True))
    board = grid.createGrid(data, False)
    direction = movement.move(board, data)
    directions = ['up', 'down', 'left', 'right']

    return move_response(directions[direction])
Exemple #9
0
 def blue():  # Function to store the run of Mission 12, blue.
     movement.accelerate(
         0, 200, 0.001, 200, 7, False,
         False)  # Accelerating to allow greater control over the blocks
     movement.accelerate(200, 0, 0.001, 200, 5, False, False)
     movement.move(
         0, -1000, 300
     )  # Movement.move also allows for negative movement, i.e. backwards movement for Returning back to base
     movement.move(30, 0, 80)
     movement.move(0, -1000, 1500)
def game():
    main_loop=int(input("wybierz opcję:\n1.nowa gra\n2.wczytaj grę\n3.wyjdź\n "))
    while(main_loop!=3):
        if (main_loop==1):
            type=input("podaj klasę postaci: \n(mage) (palladyn) (warrior)\n(rouge) (warlock) (priest)\n(hunter) (dk -death knight) (shaman)\n ")
            player=character(1,type)
            map=dungeon()
            counter=0
            a=0
            x=map.layout[0].lenght-1
            y=0
            while(counter!=5):
                map.layout[counter].add_element("hero",map.layout[counter].lenght-1,0)
                while(a!=5):
                    print(map)
                    direction=input("podaj kierunek (left, right, up, down): ")
                    a=move(map.layout[counter],x,y,direction)
                    if a!=1:
                        if direction=="left":
                            x-=1
                        elif direction=="right":
                            x+=1
                        elif direction=="up":
                            y-=1
                        elif direction=="down":
                            y+=1
                        if a==2:
                            type=random.randint(1,3)
                            if type==1:
                                ai=monster(player.level,"skeleton")
                            elif type==2:
                                ai=monster(player.level,"zombie")
                            elif type==3:
                                ai=monster(player.level,"vampire")
                            fight(player,ai)
                        elif a==3:
                            ai = monster(player.level, "boss")
                            fight(player,ai)
                        elif a==4:
                            player.rest()
                    else:
                        print("zly kierunek\n\n")
                counter+=1
Exemple #11
0
 def run():
     left_colour_sensor = ColorSensor(Port.S1)
     right_colour_sensor = ColorSensor(Port.S2)
     # movement.move(0, 500, 1000)
     left_attachment.run_angle(30, 30, Stop.BRAKE, False)
     right_attachment.run_angle(30, 30, Stop.BRAKE, False)
     movement.accelerate(0, 150, 0.01, 500, 10, False, False)
     print("following")
     line_follow = movement.lineFollow(True, 32, 9)
     movement.move(-10, 0, 65)
     while left_colour_sensor.color != Color.BLACK or right_colour_sensor.color != Color.BLACK:
         movement.move(0, 10, 5)
     line_follow = movement.lineFollow(True, 1, 9)
     movement.move(0, 150, 300)
     line_follow = 60
     print("stopped")
Exemple #12
0
 def red():  # Function to store the run of Mission 12, red.
     # make it go a bit further.
     value = 35  # Value to store the turning amount, soft-coded to make it easier to change values.
     value = 21
     movement.move(-15, 0, value)
     movement.accelerate(
         0, 200, 0.001, 260, 7, False, False
     )  # Running the function to accelerate from x vel to y vel at z mm/s^2
     movement.move(0, 200,
                   150)  # 0 steering, hence there is straight movement.
     movement.accelerate(
         200, 0, 0.001, 315, 4, True, False
     )  # Decelerating back to 0, i.e. to the circle where they must be placed
     movement.accelerate(0, -200, 0.001, 150, 10, False,
                         False)  # Accelerating on the way back.
     movement.move(
         0, -1000, 3000
     )  # Movement.move also allows for negative movement, i.e. backwards movement for Returning back to base
Exemple #13
0
def main(window_width, window_height, fps, file_name, camera_offset):
    """
    Main function.
    :param camera_offset: Camera offset.
    :param window_width: Window width.
    :param window_height: Window height
    :param fps: Frames per second
    :param file_name: File to load.
    """
    # Start up.
    level_counter = 0
    is_started = False
    # Surfaces
    surface = pygame.display.set_mode((window_width, window_height))
    surface.fill(BG_COLOR)
    pygame.display.set_caption("PySokoban - Press Space to start!")
    # Clock.
    fps_clock = pygame.time.Clock()
    # Draw title.
    # noinspection PyUnresolvedReferences
    title_surface = pygame.image.load("title.png")
    title_surface_rect = title_surface.get_rect()
    title_surface_rect.center = (window_width / 2, window_height / 2)
    surface.blit(title_surface, title_surface_rect)
    pygame.display.update()
    # First loop to show a splash screen.
    while not is_started:
        for e in pygame.event.get():
            if e.type == QUIT:
                shutdown()
            elif e.type == KEYUP:  # Pressed a key.
                if e.key == K_SPACE:
                    is_started = True
    surface.fill(BG_COLOR)
    pygame.display.set_caption("PySokoban - Level {}, Steps:{}".format(
        level_counter, 0))
    # Level data.
    levels = pysokoban_map_data.load(file_name)
    level = levels[level_counter]

    game_state = level['start_state']
    player_location = game_state['player']
    crates = game_state['crates']
    map_data = level['map_obj']
    goals = level['goals']

    # Map surface.
    map_surface = pysokoban_surface.get_surface(map_data, player_location,
                                                crates, goals)

    map_surface_rect = map_surface.get_rect()
    map_surface_rect.center = (window_width / 2, window_height / 2)

    camera_x_offset = 0  # Camera X offset.
    camera_y_offset = 0  # Camera Y offset.
    # Event loop.
    while True:
        # Grab ALL events to process
        for event in pygame.event.get():
            if event.type == QUIT:
                shutdown()
            elif event.type == KEYUP:  # Pressed a key.
                direction = None  # Direction.
                redraw = False  # Requires redraw.
                if event.key == K_a:  # Left.
                    direction = LEFT
                    redraw = True
                    camera_x_offset += camera_offset
                elif event.key == K_d:  # Right
                    direction = RIGHT
                    redraw = True
                    camera_x_offset -= camera_offset
                elif event.key == K_w:  # Up.
                    direction = UP
                    redraw = True
                    camera_y_offset += camera_offset
                elif event.key == K_s:  # Down.
                    direction = DOWN
                    redraw = True
                    camera_y_offset -= camera_offset
                elif event.key == K_BACKSPACE:  # Undo.
                    pass
                elif event.key == K_SPACE:  # Redo.
                    pass

                # If moved and level is not complete.
                if direction is not None:
                    # Player make a move.
                    moved = pysokoban_movement.move(direction, map_data,
                                                    player_location, crates)
                    if moved:
                        # Add a step to step counter.
                        game_state['step_counter'] += 1
                        redraw = True

                if redraw:  # Redraw.
                    # First fill with background color.
                    surface.fill(BG_COLOR)
                    # Get the surface.
                    map_surface = pysokoban_surface.get_surface(
                        map_data, player_location, crates, goals)
                    # Get the rectangle of map surface.
                    map_surface_rect = map_surface.get_rect()
                    # If the width of map surface is smaller than screen surface
                    if map_surface_rect.width < window_width:
                        camera_x_offset = 0
                    if map_surface_rect.height < window_height:
                        camera_y_offset = 0
                    # Re-set center of map surface's rectangle.
                    map_surface_rect.center = (window_width / 2 +
                                               camera_x_offset,
                                               window_height / 2 +
                                               camera_y_offset)

                # Level is complete.
                if pysokoban_level_check.level_is_complete(crates, goals):
                    level_counter += 1
                    # Set to next level.
                    level = levels[level_counter]
                    game_state = level['start_state']
                    player_location = game_state['player']
                    crates = game_state['crates']
                    map_data = level['map_obj']
                    goals = level['goals']
                    # Blit refreshed surface.
                    surface.blit(map_surface, map_surface_rect)
                    level_complete_blit(surface, window_height, window_width)
                    pygame.display.update()
                    exit_flag = False
                    while not exit_flag:
                        for e in pygame.event.get():
                            if e.type == QUIT:
                                shutdown()
                            elif e.type == KEYUP:  # Pressed a key.
                                if e.key == K_SPACE:
                                    exit_flag = True

                    # Redraw second time..
                    # First fill with background color.
                    surface.fill(BG_COLOR)
                    # Get the surface.
                    map_surface = pysokoban_surface.get_surface(
                        map_data, player_location, crates, goals)
                    # Get the rectangle of map surface.
                    map_surface_rect = map_surface.get_rect()
                    # If the width of map surface is smaller than screen surface
                    if map_surface_rect.width < window_width:
                        camera_x_offset = 0
                    if map_surface_rect.height < window_height:
                        camera_y_offset = 0
                    # Re-set center of map surface's rectangle.
                    map_surface_rect.center = (window_width / 2 +
                                               camera_x_offset,
                                               window_height / 2 +
                                               camera_y_offset)

        pygame.display.set_caption("PySokoban - Level {}, Steps:{}".format(
            level_counter + 1, game_state['step_counter']))
        # Blit surface and update.
        surface.blit(map_surface, map_surface_rect)
        pygame.display.update()
        fps_clock.tick(fps)
Exemple #14
0
direction = True
step_count = 0
score = 0

#Directions input
while gameplay:
    print("Your position is \u001b[32mx: %s , y: %s\u001b[0m \n" %
          (player.position.x, player.position.y))
    print("Your distance between the boss is \u001b[32m%s\u001b[0m \n" %
          map_size.calc_distance(player.position, boss.position))
    print("which direction would you like to move? \n")
    while direction:
        step_count += 1
        move = input("[\u001b[36mup, down, left, right\u001b[0m] \n>> ")
        if move == "up":
            movement.move(player.position, "up")
            direction = False
        elif move == "down":
            movement.move(player.position, "down")
            direction = False
        elif move == "left":
            movement.move(player.position, "left")
            direction = False
        elif move == "right":
            movement.move(player.position, "right")
            direction = False
        else:
            print("\u001b[31mInvalid direction.\u001b[0m\n")
    direction = True
    #Players starting position and distance away from the boss
    battle = encounter.enc_probability(player.position, boss.position)
		speed = float(raw_input("Enter a speed (less than 2):"))

		while not(check_valid_speed(speed)):
			speed = float(raw_input("Please enter a valid speed (0<speed<=2):"))

		duration = float(raw_input("Enter a duration (be mindful of surroundings):"))

		while not(check_valid_duration(duration)):
			duration = float(raw_input("Please enter a valid duration (>0):"))

		direction = check_valid_direction(direction)
		start_time = time()

		if (direction == 1):
			while time() < start_time + duration:
				movement.move(speed)
				movement.read_laser_scan_data()
		elif (direction == 2):
			while time() < start_time + duration:
				movement.move(-1*speed)
				movement.read_laser_scan_data()
		elif (direction == 3):
			while time() < start_time + duration:
				movement.turn(-1*speed)
				movement.read_laser_scan_data()
		elif (direction == 4):
			while time() < start_time + duration:
				movement.turn(speed)
				movement.read_laser_scan_data()

Exemple #16
0
def main():
    '''main function of the game'''
    if os.name == 'nt':
        # System check. App works only on unix system
        # Caused by getch function and console clearing
        # Can be fixed by implementing msvcrt library
        print("This application is meant for unix devices.")
        print("Closing the program.")
        sleep(2)
        forcequit()

    player = Player()

    args = {
        # Define map numbers
        'maps': {
            0: "menu",
            1: "respawn.map",
            2: "forest.map",
            3: "dungeon.map",
            4: "boss.map",
            5: "end.map",
        },
        'map_id': 0,
        'board': [],
        'current_choice': 1,
        'last_input': '',
        'direction': None,
        'change': 0,
        'enemies': [1, True],
        'player': player,
        'last_pos': '',
    }

    clear()
    while True:
        '''main loop of the game'''
        clear()
        # mapcheck
        ############################################   MAP MENU  ########################################################
        if args['map_id'] == 0:
            status = display_menu(args)
            if status is None:
                exit()
            elif status[0] == args['maps'][0]:
                args['map_id'] = 0
                args['current_choice'] = status[1]
                args['last_input'] = status[2]

            else:
                args['map_id'] = status[0]
                args['last_pos'] = status[1]
                args['board'] = status[2]
        ############################################   MAP SPAWN ########################################################
        elif args['map_id'] == 1:
            if args['last_pos'] is None:
                args['last_pos'] = (33, 60)
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
            # If on certain map stay on that map
            # Can be implemented as a standalone function
            print_map(args['board'])
            user_input = getch()
            if user_input == 'p':
                clear(24, 80)
                break
            elif user_input == 'w':
                args['direction'] = 0
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = change[2]
                    args['board'] = unfile(args['maps'][change[2]])
                    args['last_pos'] = None
                    args['enemies'] = [1, True]
            elif user_input == 's':
                args['direction'] = 0
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
            elif user_input == 'a':
                args['direction'] = 1
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
            elif user_input == 'd':
                args['direction'] = 1
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
            elif user_input == 'i':
                clear()
                inventory(player)
            else:
                exit()

        ############################################  MAP FOREST ########################################################
        elif args['map_id'] == 2:

            enemies_left = 0
            print(enemies_left, ' b4')
            if args['last_pos'] is None:
                args['last_pos'] = (3, 50)
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]

            if args['enemies'][1]:
                for i in range(10):
                    if randint(0, 1):
                        args['enemies'].append(Enemy(1))
                        args['enemies'][0] += 1
                        args['enemies'][args['enemies'][0]].spawn(
                            args['board'])
                        args['board'][args['enemies'][
                            args['enemies'][0]].y_coord][args['enemies'][
                                args['enemies'][0]].x_coord] = args['enemies'][
                                    args['enemies'][0]].enemy_char
                if args['enemies'][0] < 2:
                    args['enemies'].append(Enemy(1))
                    args['enemies'][0] += 1
                    args['enemies'][args['enemies'][0]].spawn(args['board'])
                    args['board'][args['enemies'][args['enemies'][0]].y_coord][
                        args['enemies'][args['enemies'][0]].x_coord] = args[
                            'enemies'][args['enemies'][0]].enemy_char

                args['enemies'][1] = False

            print_map(args['board'])

            user_input = getch()
            if user_input == 'p':
                clear(24, 80)
                break
            elif user_input == 'w':
                args['direction'] = 0
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = args['maps'][change[2]]
            elif user_input == 's':
                args['direction'] = 0
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = args['maps'][change[2]]
            elif user_input == 'a':
                args['direction'] = 1
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = maps[change[2]]
            elif user_input == 'd':
                args['direction'] = 1
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = maps[change[2]]
            elif user_input == 'q':
                if player.potions > 0:
                    player.life += player.level * 2
                    player.potions -= 1
            elif user_input == 'i':
                clear()
                inventory(player)
            else:
                exit()

            for line in args['board']:
                if args['enemies'][2].enemy_char in line:
                    print(line)
                    enemies_left += 1
            print(enemies_left, ' aftr')

            if enemies_left == 0:
                print("Level clear!")
                sleep(1)
                args['map_id'] = 1
                args['current_choice'] = 1
                args['board'] = unfile(args['maps'][1])
                args['last_pos'] = None

        ############################################ MAP DUNGEON ########################################################
        elif args['map_id'] == 3:

            enemies_left = 0
            clear()

            if args['last_pos'] is None:
                args['last_pos'] = (19, 109)
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]

            if args['enemies'][1]:
                args['enemies_left'] = 0
                for i in range(15):
                    if randint(0, 1):
                        args['enemies'].append(Enemy(2))
                        args['enemies'][0] += 1
                        args['enemies'][args['enemies'][0]].spawn(
                            args['board'])
                        args['board'][args['enemies'][
                            args['enemies'][0]].y_coord][args['enemies'][
                                args['enemies'][0]].x_coord] = args['enemies'][
                                    args['enemies'][0]].enemy_char
                if args['enemies'][0] < 2:
                    args['enemies'].append(Enemy(2))
                    args['enemies'][0] += 1
                    args['enemies'][args['enemies'][0]].spawn(args['board'])
                    args['board'][args['enemies'][args['enemies'][0]].y_coord][
                        args['enemies'][args['enemies'][0]].x_coord] = args[
                            'enemies'][args['enemies'][0]].enemy_char

                args['enemies'][1] = False

            print_map(args['board'])

            user_input = getch()
            if user_input == 'p':
                clear(24, 80)
                break
            elif user_input == 'w':
                args['direction'] = 0
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = args['maps'][change[2]]
            elif user_input == 's':
                args['direction'] = 0
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = args['maps'][change[2]]
            elif user_input == 'a':
                args['direction'] = 1
                args['change'] = -1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = maps[change[2]]
            elif user_input == 'd':
                args['direction'] = 1
                args['change'] = 1
                change = move(args)
                args['last_pos'] = change[0]
                args['board'] = change[1]
                if change[2] is not None:
                    args['map_id'] = maps[change[2]]
            elif user_input == 'q':
                if player.potions > 0:
                    player.life += player.level * 2
                    player.potions -= 1
            elif user_input == 'i':
                clear()
                inventory(player)
            else:
                exit()

            for line in args['board']:
                if args['enemies'][2].enemy_char in line:
                    enemies_left += 1

            if enemies_left == 0:
                print("Level clear!")
                sleep(1)
                args['map_id'] = 1
                args['current_choice'] = 1
                args['board'] = unfile(args['maps'][1])
                args['last_pos'] = None

        if args['player'].life == 0:
            clear()
            lost()
            sleep(3)
            args['map_id'] = 0
            args['current_choice'] = 1
            args['last_pos'] = None
Exemple #17
0
from selenium import webdriver
from movement import move

# Variables
driver = webdriver.Chrome()

# Defining what website to use
driver.get('https://play2048.co/')

board = ([0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0])

tile_container = driver.find_element_by_class_name("tile-container")

# MAIN
move('left', tile_container, board)
Exemple #18
0
        if keys[pygame.K_LEFT]:
            try:
                movement.read_laser_scan_data()
                movement.turn()
            except rospy.ROSInterruptException:
                pass
        elif keys[pygame.K_RIGHT]:
            try:
                movement.read_laser_scan_data()
                movement.turn(-0.75)
            except rospy.ROSInterruptException:
                pass
        elif keys[pygame.K_UP]:
            try:
                movement.read_laser_scan_data()
                movement.move()
            except rospy.ROSInterruptException:
                pass
        elif keys[pygame.K_DOWN]:
            try:
                movement.read_laser_scan_data()
                movement.move(-1)
            except rospy.ROSInterruptException:
                pass
        else:
            movement.stop()

        clock.tick(25)

    pygame.quit()
    sys.exit()
Exemple #19
0
 def __init__(self):
     Frame.__init__(self)
     self.master.title("Chess")
     self.master.geometry()
     self.master.resizable(0, 1)
     self.grid()
     self._move = move()
     #This was created to control the function <self._emp>
     #so that it does store erroneous values, when the user
     #mistakenly clicks an empty tile button
     self._state = True
     #creating the instance variable that stores the
     #piece and empty tile positions
     self._pieces = []
     self._name = None
     self._p = []
     #creating the images
     self._black = PhotoImage(file="./images/black.png")
     self._white = PhotoImage(file="./images/white.png")
     self._king = PhotoImage(file="./images/king.gif")
     self._queen = PhotoImage(file="./images/queen.gif")
     self._rookblack = PhotoImage(file="./images/rook.gif")
     self._rookwhite = PhotoImage(file="./images/rook.gif")
     self._bishopblack = PhotoImage(file="./images/bishop.gif")
     self._bishopwhite = PhotoImage(file="./images/bishop.gif")
     self._knightblack = PhotoImage(file='./images/knight.gif')
     self._knightwhite = PhotoImage(file='./images/knight.gif')
     #placing the images on the screen
     self._kinglabel = Button(
         self,
         image=self._king,
         command=lambda: self._piece(self._move._kingstore, "king"))
     self._kinglabel.grid(row=7, column=3)
     self._queenlabel = Button(
         self,
         image=self._queen,
         command=lambda: self._piece(self._move._queenstore, "queen"))
     self._queenlabel.grid(row=7, column=4)
     self._rookblacklab = Button(
         self,
         image=self._rookblack,
         command=lambda: self._piece(self._move._blakrookstore))
     self._rookblacklab.grid(row=7, column=0)
     self._rookwhitelab = Button(
         self,
         image=self._rookwhite,
         command=lambda: self._piece(self._move._witerookstore))
     self._rookwhitelab.grid(row=7, column=7)
     self._bishopblacklab = Button(
         self,
         image=self._bishopblack,
         command=lambda: self._piece(self._move._blakbishopstore))
     self._bishopblacklab.grid(row=7, column=2)
     self._bishopwhitelab = Button(
         self,
         image=self._bishopwhite,
         command=lambda: self._piece(self._move._witebishopstore))
     self._bishopwhitelab.grid(row=7, column=5)
     self._knightblacklab = Button(
         self,
         image=self._knightblack,
         command=lambda: self._piece(self._move._blaknite))
     self._knightblacklab.grid(row=7, column=6)
     self._knightwhitelab = Button(
         self,
         image=self._knightwhite,
         command=lambda: self._piece(self._move._witenite))
     self._knightwhitelab.grid(row=7, column=1)
     self._a0 = Button(self,
                       image=self._white,
                       text=str("00"),
                       command=lambda: self._emp(self._a0["text"]))
     self._a0.grid(row=0, column=0)
     self._a1 = Button(self,
                       image=self._black,
                       text=str("01"),
                       command=lambda: self._emp(self._a1["text"]))
     self._a1.grid(row=0, column=1)
     self._a2 = Button(self,
                       image=self._white,
                       text=str("02"),
                       command=lambda: self._emp(self._a2["text"]))
     self._a2.grid(row=0, column=2)
     self._a3 = Button(self,
                       image=self._black,
                       text=str("03"),
                       command=lambda: self._emp(self._a3["text"]))
     self._a3.grid(row=0, column=3)
     self._a4 = Button(self,
                       image=self._white,
                       text=str("04"),
                       command=lambda: self._emp(self._a4["text"]))
     self._a4.grid(row=0, column=4)
     self._a5 = Button(self,
                       image=self._black,
                       text=str("05"),
                       command=lambda: self._emp(self._a5["text"]))
     self._a5.grid(row=0, column=5)
     self._a6 = Button(self,
                       image=self._white,
                       text=str("06"),
                       command=lambda: self._emp(self._a6["text"]))
     self._a6.grid(row=0, column=6)
     self._a7 = Button(self,
                       image=self._black,
                       text=str("07"),
                       command=lambda: self._emp(self._a7["text"]))
     self._a7.grid(row=0, column=7)
     self._b0 = Button(self,
                       image=self._black,
                       text=str("10"),
                       command=lambda: self._emp(self._b0["text"]))
     self._b0.grid(row=1, column=0)
     self._b1 = Button(self,
                       image=self._white,
                       text=str("11"),
                       command=lambda: self._emp(self._b1["text"]))
     self._b1.grid(row=1, column=1)
     self._b2 = Button(self,
                       image=self._black,
                       text=str("12"),
                       command=lambda: self._emp(self._b2["text"]))
     self._b2.grid(row=1, column=2)
     self._b3 = Button(self,
                       image=self._white,
                       text=str("13"),
                       command=lambda: self._emp(self._b3["text"]))
     self._b3.grid(row=1, column=3)
     self._b4 = Button(self,
                       image=self._black,
                       text=str("14"),
                       command=lambda: self._emp(self._b4["text"]))
     self._b4.grid(row=1, column=4)
     self._b5 = Button(self,
                       image=self._white,
                       text=str("15"),
                       command=lambda: self._emp(self._b5["text"]))
     self._b5.grid(row=1, column=5)
     self._b6 = Button(self,
                       image=self._black,
                       text=str("16"),
                       command=lambda: self._emp(self._b6["text"]))
     self._b6.grid(row=1, column=6)
     self._b7 = Button(self,
                       image=self._white,
                       text=str("17"),
                       command=lambda: self._emp(self._b7["text"]))
     self._b7.grid(row=1, column=7)
     self._c0 = Button(self,
                       image=self._white,
                       text=str("20"),
                       command=lambda: self._emp(self._c0["text"]))
     self._c0.grid(row=2, column=0)
     self._c1 = Button(self,
                       image=self._black,
                       text=str("21"),
                       command=lambda: self._emp(self._c1["text"]))
     self._c1.grid(row=2, column=1)
     self._c2 = Button(self,
                       image=self._white,
                       text=str("22"),
                       command=lambda: self._emp(self._c2["text"]))
     self._c2.grid(row=2, column=2)
     self._c3 = Button(self,
                       image=self._black,
                       text=str("23"),
                       command=lambda: self._emp(self._c3["text"]))
     self._c3.grid(row=2, column=3)
     self._c4 = Button(self,
                       image=self._white,
                       text=str("24"),
                       command=lambda: self._emp(self._c4["text"]))
     self._c4.grid(row=2, column=4)
     self._c5 = Button(self,
                       image=self._black,
                       text=str("25"),
                       command=lambda: self._emp(self._c5["text"]))
     self._c5.grid(row=2, column=5)
     self._c6 = Button(self,
                       image=self._white,
                       text=str("26"),
                       command=lambda: self._emp(self._c6["text"]))
     self._c6.grid(row=2, column=6)
     self._c7 = Button(self,
                       image=self._black,
                       text=str("27"),
                       command=lambda: self._emp(self._c7["text"]))
     self._c7.grid(row=2, column=7)
     self._d0 = Button(self,
                       image=self._black,
                       text=str("30"),
                       command=lambda: self._emp(self._d0["text"]))
     self._d0.grid(row=3, column=0)
     self._d1 = Button(self,
                       image=self._white,
                       text=str("31"),
                       command=lambda: self._emp(self._d1["text"]))
     self._d1.grid(row=3, column=1)
     self._d2 = Button(self,
                       image=self._black,
                       text=str("32"),
                       command=lambda: self._emp(self._d2["text"]))
     self._d2.grid(row=3, column=2)
     self._d3 = Button(self,
                       image=self._white,
                       text=str("33"),
                       command=lambda: self._emp(self._d3["text"]))
     self._d3.grid(row=3, column=3)
     self._d4 = Button(self,
                       image=self._black,
                       text=str("34"),
                       command=lambda: self._emp(self._d4["text"]))
     self._d4.grid(row=3, column=4)
     self._d5 = Button(self,
                       image=self._white,
                       text=str("35"),
                       command=lambda: self._emp(self._d5["text"]))
     self._d5.grid(row=3, column=5)
     self._d6 = Button(self,
                       image=self._black,
                       text=str("36"),
                       command=lambda: self._emp(self._d6["text"]))
     self._d6.grid(row=3, column=6)
     self._d7 = Button(self,
                       image=self._white,
                       text=str("37"),
                       command=lambda: self._emp(self._d7["text"]))
     self._d7.grid(row=3, column=7)
     self._e0 = Button(self,
                       image=self._white,
                       text=str("40"),
                       command=lambda: self._emp(self._e0["text"]))
     self._e0.grid(row=4, column=0)
     self._e1 = Button(self,
                       image=self._black,
                       text=str("41"),
                       command=lambda: self._emp(self._e1["text"]))
     self._e1.grid(row=4, column=1)
     self._e2 = Button(self,
                       image=self._white,
                       text=str("42"),
                       command=lambda: self._emp(self._e2["text"]))
     self._e2.grid(row=4, column=2)
     self._e3 = Button(self,
                       image=self._black,
                       text=str("43"),
                       command=lambda: self._emp(self._e3["text"]))
     self._e3.grid(row=4, column=3)
     self._e4 = Button(self,
                       image=self._white,
                       text=str("44"),
                       command=lambda: self._emp(self._e4["text"]))
     self._e4.grid(row=4, column=4)
     self._e5 = Button(self,
                       image=self._black,
                       text=str("45"),
                       command=lambda: self._emp(self._e5["text"]))
     self._e5.grid(row=4, column=5)
     self._e6 = Button(self,
                       image=self._white,
                       text=str("46"),
                       command=lambda: self._emp(self._e6["text"]))
     self._e6.grid(row=4, column=6)
     self._e7 = Button(self,
                       image=self._black,
                       text=str("47"),
                       command=lambda: self._emp(self._e7["text"]))
     self._e7.grid(row=4, column=7)
     self._f0 = Button(self,
                       image=self._black,
                       text=str("50"),
                       command=lambda: self._emp(self._f0["text"]))
     self._f0.grid(row=5, column=0)
     self._f1 = Button(self,
                       image=self._white,
                       text=str("51"),
                       command=lambda: self._emp(self._f1["text"]))
     self._f1.grid(row=5, column=1)
     self._f2 = Button(self,
                       image=self._black,
                       text=str("52"),
                       command=lambda: self._emp(self._f2["text"]))
     self._f2.grid(row=5, column=2)
     self._f3 = Button(self,
                       image=self._white,
                       text=str("53"),
                       command=lambda: self._emp(self._f3["text"]))
     self._f3.grid(row=5, column=3)
     self._f4 = Button(self,
                       image=self._black,
                       text=str("54"),
                       command=lambda: self._emp(self._f4["text"]))
     self._f4.grid(row=5, column=4)
     self._f5 = Button(self,
                       image=self._white,
                       text=str("55"),
                       command=lambda: self._emp(self._f5["text"]))
     self._f5.grid(row=5, column=5)
     self._f6 = Button(self,
                       image=self._black,
                       text=str("56"),
                       command=lambda: self._emp(self._f6["text"]))
     self._f6.grid(row=5, column=6)
     self._f7 = Button(self,
                       image=self._white,
                       text=str("57"),
                       command=lambda: self._emp(self._f7["text"]))
     self._f7.grid(row=5, column=7)
     self._g0 = Button(self,
                       image=self._white,
                       text=str("60"),
                       command=lambda: self._emp(self._g0["text"]))
     self._g0.grid(row=6, column=0)
     self._g1 = Button(self,
                       image=self._black,
                       text=str("61"),
                       command=lambda: self._emp(self._g1["text"]))
     self._g1.grid(row=6, column=1)
     self._g2 = Button(self,
                       image=self._white,
                       text=str("62"),
                       command=lambda: self._emp(self._g2["text"]))
     self._g2.grid(row=6, column=2)
     self._g3 = Button(self,
                       image=self._black,
                       text=str("63"),
                       command=lambda: self._emp(self._g3["text"]))
     self._g3.grid(row=6, column=3)
     self._g4 = Button(self,
                       image=self._white,
                       text=str("64"),
                       command=lambda: self._emp(self._g4["text"]))
     self._g4.grid(row=6, column=4)
     self._g5 = Button(self,
                       image=self._black,
                       text=str("65"),
                       command=lambda: self._emp(self._g5["text"]))
     self._g5.grid(row=6, column=5)
     self._g6 = Button(self,
                       image=self._white,
                       text=str("66"),
                       command=lambda: self._emp(self._g6["text"]))
     self._g6.grid(row=6, column=6)
     self._g7 = Button(self,
                       image=self._black,
                       text=str("67"),
                       command=lambda: self._emp(self._g7["text"]))
     self._g7.grid(row=6, column=7)
Exemple #20
0
    def run():  # Function to store the code for the run of Mission 9
        left_attachment.run_angle(30, 30, Stop.BRAKE,
                                  False)  # Moving platform up a bit
        right_attachment.run_angle(30, 30, Stop.BRAKE, False)
        movement.accelerate(0, 150, 0.01, 500, 10, False, False)
        print("following")  # Outputting the state of the robot to the console.
        line_follow = movement.lineFollow(
            True, 20,
            9)  # Line-following as it is more accurate than straight moving.
        line_follow = 38.213
        print("stopped")  # Outputting the state of the robot to the console.
        angle_to_turn = 30
        movement.move(-10, 0, angle_to_turn)  # Turns when line follow is done
        movement.move(0, 150, 465)
        Drift = False  # Drift affects the direction of the bot
        if Drift:
            left_attachment.run_angle(
                70, 70, Stop.BRAKE,
                False)  # Platform moves up so moment increases (m=fxd)
            right_attachment.run_angle(70, 70, Stop.BRAKE, False)
            movement.move(10, 0, 20)
            movement.move(0, 50, 93)
            movement.move(5, 0, 10)  # Move middle beam
            movement.move(0, -50, 50)
            movement.move(5, 0, 10)  # Move right beams
            movement.move(0, 50, 50)
            movement.move(20, 0, 33)
        if not Drift:
            left_attachment.run_angle(70, 70, Stop.BRAKE, False)
            right_attachment.run_angle(70, 70, Stop.BRAKE, False)
            movement.move(10, 0, 13)
            movement.move(0, 50, 30)
            movement.move(14, 0, 14)  # Move middle beam
            movement.move(0, -50, 28)
            movement.move(10, 0, 7)  # Move right beams
            movement.move(0, 50, 80)
            movement.move(20, 0, 30)

        movement.move(0, -50, 100)
        movement.move(20, 0, 30)
        movement.move(0, 150, 190)  # Run into swings
        movement.move(0, -150, 100)
        left_attachment.run_angle(350, 350, Stop.BRAKE, False)
        right_attachment.run_angle(350, 350, Stop.BRAKE, False)
        # Pushing the house downwards & leftwards
        if Drift:
            movement.move(-20, 0, 95)
        if not Drift:
            movement.move(-20, 0, 83.5)
        movement.move(0, -500, 600)  # Into traffic jam
        movement.move(20, 0, 30)
        movement.move(0, -1000, 5000)  # Into base
Exemple #21
0
			lastLev = 1
		state = 2
	# Third State in state machine
	if state == 2:
		# Variables to track previous location
		player_x_prev = player_x
		player_y_prev = player_y
		
		# User Input
		direction = raw_input()
		
		# Condition for Exit
		if direction == "E":
			endGame = 1
		# Call to Move Function
		player_x, player_y = move(player_x, player_y, direction, currentMap)
			
		# Check for wall or boundary
		if wallCheck(player_x, player_y, currentMap) == 0:
			player_x = player_x_prev
			player_y = player_y_prev
		# Check for trap
		if trapCheck(player_x, player_y, currentMap) == 0:
			state = 4
		if diff == "4" or diff == "5":
			currentMap, leverStage = leverCheck(player_x, player_y, currentMap, diff, leverStage)
		os.system("clear")	
		
		# Update of map with player
		currentMap = updateMap(player_x, player_y, player_x_prev, player_y_prev, currentMap)
		
Exemple #22
0
def main():
    running = True
    clock = pygame.time.Clock()

    champ_index = main_menu.main_menu(screen)
    entities = []
    player = c.get_champion(champ_index)
    num = 0
    for i in range(10):
        if i == 10:
            num += 1
        entities.append(e.get_enemy(num, player))

    r.init(screen, player)

    width = (screen.get_width() / 2) - (player.surf.get_width() / 2)
    height = (screen.get_height() / 2) - (player.surf.get_height() / 2) - (75)

    room = f.gen_dungeon()
    f.get_wall_rects(walls, room, TILESIZE)

    pygame.time.set_timer(pygame.USEREVENT, 100)
    millisecond = 0

    while running:
        screen.fill(BLACK)
        dt = clock.tick(60)
        mousepos = list(pygame.mouse.get_pos())
        mousepos[0] += player.position[0] - width
        mousepos[1] += player.position[1] - height

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            if event.type == pygame.USEREVENT:
                player.charge += 1
                if player.charge > 100:
                    player.charge = 100

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_r:
                    player.special(player)
                if event.key == pygame.K_e:
                    player.health -= 10
                if event.key == pygame.K_SPACE:
                    player.auto()

                if millisecond >= 10000:
                    millisecond = 0
                    for i in player.entities:
                        i.counter += 1

                        if i.counter > i.lifetime:
                            player.entities.remove(i)

        update_animations(player)
        update_entities(entities, player, dt)
        player.update(entities, mousepos)
        movement.move(player, pygame.key.get_pressed(), dt / 60, walls)
        movement.move_enemy(entities, walls, dt / 60)
        r.draw_room(room, player, screen)
        r.draw_entities(screen, entities, player)
        r.draw_animations(screen, player)
        r.draw_hud(screen, player, int(clock.get_fps()), mousepos)

        pygame.display.flip()

        millisecond += dt
Exemple #23
0
def mainloop(dt):
    try:
        draw()
        g.cleanup()
        if g.menulist != g.mainmenu:
            for r in map.randomambs:
                r.update()
            if map.myroom() != "" and map.myroom() != g.currentroom:
                g.currentroom = map.myroom()
                if g.roomsound.get_state() == al.AL_PLAYING:
                    g.roomsound.stop()
                g.roomsound = g.oalOpen(map.myroom(), ".wav")
                g.roomsound.set_looping(True)
                g.roomsound.play()

            if g.jumping == 1:
                g.WalkTime = g.airtime
                if g.ascending == True:
                    if map.tile(g.me.x, g.me.y, g.me.z + 1) == "":
                        if g.jumptime.elapsed() >= 50:
                            g.jumptime.restart()
                            g.ascenddistance += 1
                            g.me.z += 1
                            g.checkplatform()
                    elif map.tile(g.me.x, g.me.y, g.me.z + 1) != "":
                        g.checkplatform()
                        g.ascenddistance = 0
                        if map.mytile() == "":
                            g.falling = 1
                        g.descenddistance = 0
                        g.jumping = 0
                    if g.ascenddistance > 5:
                        g.ascending = False
                elif g.ascending == False:
                    if g.jumptime.elapsed() >= 70:
                        g.jumptime.restart()
                        g.descenddistance += 1
                        g.me.z -= 1
                        g.checkplatform()
                    if g.descenddistance > 15:
                        g.ascenddistance = 0
                        g.descenddistance = 0
                        g.jumping = 0
            g.falldown()
            if g.loaded and g.falling == 0 and g.jumping == 0 and map.tile(
                    g.me.x, g.me.y, g.me.z) == "":
                g.falling = 1

            if g.falling == 1 and map.tile(g.me.x, g.me.y, g.me.z) != "":
                g.WalkTime = g.MainWalkTime
                if g.falldistance > 10:
                    tempsplit = map.mytile().split("|")
                    fallingsounds = list()
                    for x in tempsplit:
                        fallingsounds.append(
                            "sounds/footsteps/" + x + "/falling/" + str(
                                random.randint(
                                    1,
                                    len(
                                        g.find_files("sounds/footsteps/" + x +
                                                     "/falling")))) + ".wav")
                    for x in fallingsounds:
                        fallsound = g.oalOpen(x, ".wav")
                        fallsound.set_source_relative(True)
                        g.sourcelist.append(fallsound)
                        fallsound.play()
                elif g.falldistance <= 10:
                    if "wall" not in map.tile(g.me.x, g.me.y, g.me.z):
                        tempsplit = map.mytile().split("|")
                        landingsounds = list()
                        for x in tempsplit:
                            landingsounds.append(
                                "sounds/footsteps/" + x + "/landing/" + str(
                                    random.randint(
                                        1,
                                        len(
                                            g.find_files("sounds/footsteps/" +
                                                         x + "/landing")))) +
                                ".wav")
                        for x in landingsounds:
                            landsound = g.oalOpen(x, ".wav")
                            landsound.set_source_relative(True)
                            g.sourcelist.append(landsound)
                            landsound.play()
                g.fallingwind.stop()
                g.fallingwind.set_gain(0.01)
                g.jumping = 0
                g.falling = 0
                g.falldistance = 0
        if g.menu == False and g.connecting == False:
            if "LSHIFT" in g.input or "RSHIFT" in g.input:
                if g.WalkTime > g.airtime:
                    g.WalkTime = 27
            if g.turntime.elapsed() >= 5:
                if "LALT" not in g.input and "RALT" not in g.input:
                    if "Q" in g.input:
                        g.turntime.restart()
                        g.direction = movement.turnleft(g.direction, 1)
                    elif "E" in g.input:
                        g.turntime.restart()
                        g.direction = movement.turnright(g.direction, 1)
            if g.walktimer.elapsed() >= 180:
                if "PAGEUP" in g.input and map.tile(
                        g.me.x, g.me.y, g.me.z + 1) != "wall" and map.tile(
                            g.me.x, g.me.y,
                            g.me.z + 1) != "" and g.jumping == 0:
                    g.walktimer.restart()
                    tempsplit = map.mytile().split("|")
                    stepsounds = list()
                    for x in tempsplit:
                        stepsounds.append(
                            g.oalOpen(
                                "sounds/footsteps/" + x + "/" + str(
                                    random.randint(
                                        1,
                                        len(
                                            g.find_files("sounds/footsteps/" +
                                                         x)))) + ".wav",
                                ".wav"))
                    for stepsound in stepsounds:
                        stepsound.set_source_relative(True)
                        g.sourcelist.append(stepsound)
                        stepsound.play()
                    g.me.z += 1
                    if "wall" in map.tile(g.me.x, g.me.y, g.me.z + 1):
                        wallsound = g.oalOpen("sounds/wall.wav")
                        wallsound.set_source_relative(True)
                        g.sourcelist.append(wallsound)
                        wallsound.play()
                if "PAGEDOWN" in g.input and map.tile(
                        g.me.x, g.me.y, g.me.z - 1) != "wall" and map.tile(
                            g.me.x, g.me.y,
                            g.me.z - 1) != "" and g.jumping == 0:
                    g.walktimer.restart()
                    tempsplit = map.mytile().split("|")
                    stepsounds = list()
                    for x in tempsplit:
                        stepsounds.append(
                            g.oalOpen(
                                "sounds/footsteps/" + x + "/" + str(
                                    random.randint(
                                        1,
                                        len(
                                            g.find_files("sounds/footsteps/" +
                                                         x)))) + ".wav",
                                ".wav"))
                    for stepsound in stepsounds:
                        stepsound.set_source_relative(True)
                        g.sourcelist.append(stepsound)
                        stepsound.play()
                    g.me.z -= 1
                    if "wall" in map.tile(g.me.x, g.me.y, g.me.z - 1):
                        wallsound = g.oalOpen("sounds/wall.wav")
                        wallsound.set_source_relative(True)
                        g.sourcelist.append(wallsound)
                        wallsound.play()

            if g.walktimer.elapsed() >= g.WalkTime:
                if "W" in g.input:
                    g.walktimer.restart()
                    movement.move(g.direction, 0.1)
                    if g.ascenddistance > 0:
                        g.checkplatform()
                elif "S" in g.input:
                    g.walktimer.restart()
                    movement.move(movement.turnleft(g.direction, 180), 0.1)
                    if g.ascenddistance > 0:
                        g.checkplatform()
                elif "A" in g.input:
                    g.walktimer.restart()
                    movement.move(movement.turnleft(g.direction, 90), 0.1)
                    if g.ascenddistance > 0:
                        g.checkplatform()
                elif "D" in g.input:
                    g.walktimer.restart()
                    movement.move(movement.turnright(g.direction, 90), 0.1)
                    if g.ascenddistance > 0:
                        g.checkplatform()

        g.listener.set_position((g.me.x, g.me.z, g.me.y))
        g.listener.set_orientation(
            (movement.getpointer()[0], 0, movement.getpointer()[1], 0, 1, 0))
    except Exception as e:
        g.speak(str(e))
    #Defining object locations
    items.clear()
    if location == [4,4]:
        inventory.addItems(location, items, currentInventory, 'apple')
    elif location == [4,5]:
        inventory.addItems(location, items, currentInventory, 'orange')

    print(' ')
    action = input('Type what you would like to do: ')
    print(' ')
    commands = action.split()

    # Movement
    if commands[0] == 'move':
        location = movement.move(commands[1], location[0], location[1])

    # Help
    elif commands[0] == 'help':
        help.listCommands()

    #Inventory
    elif commands[0] == 'take':
        inventory.take(commands[1], items, currentInventory)

    elif commands[0] == 'inv':
        for value in currentInventory.values():
            print(value)

    elif commands[0] == 'search':
        print(items)
Exemple #25
0
 def brown(
 ):  # Individual Mission 12 runs have been differentiated into different subroutines of the object.
     value = 50  # Value to store the turning amount, soft-coded to make it easier to change values.
     value = 38
     movement.move(
         0, 50, 200
     )  # Using the move function we declared in movement as it is more accurate then ev3's movement.
     movement.move(-30, 0, value)
     movement.accelerate(
         0, 150, 0.001, 250, 7, False, False
     )  # Function to accelerate/decelerate from x to y vel at z mm/s^2
     movement.move(0, 150, 540)
     movement.accelerate(
         150, 0, 0.001, 292, 4, True, False
     )  # Decelerating to allow greater control over the blocks and to allow a less change in delta v when stopping.
     movement.accelerate(0, -150, 0.001, 150, 10, False, False)
     movement.move(0, -300, 100)
     movement.move(30, 0, 30)  # Turning to ensure fastest return to base
     movement.move(0, -1000, 3000)
     movement.move(100, -300, 170)  # Fitting into base