Example #1
0
def main():
    init_logging()
    # nice exit via ctrl-c
    signal.signal(signal.SIGINT, signal_handler)

    print "Welcome to MAIA! a.k.a flowerpicker v4!"

    # initialize runtime configuration
    config = init_config()

    # create game window object and tell it the size our screenshots will have
    gw = gamewindow.GameWindow(config['frame_size'])

    # initiate connection to minecraft
    mc = minecraft.Minecraft.create()

    # save current time
    main_start_time = time.time()

    # connect to api server
    if config['graph_server']:
        ws = create_connection("ws://localhost:8080")
    else:
        ws = "empty"

    # run q-learner
    run_qlearner(config, ws, gw, mc)

    # save time data
    main_run_time = time.time() - main_start_time

    print "MAIA has completed %s episodes in %s seconds" % (
        config['number_of_episodes'], main_run_time)
    print "That means an average of %s seconds per episode (20 flowers)" % (
        main_run_time / config['number_of_episodes'])

    # close connection to api server
    if config['graph_server']: ws.close()
Example #2
0
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication
import sys
import gamewindow
from gamestate import *

if __name__ == "__main__":
    game_state_test = GameState(physic=Physic(minimum_speed=0.000005),
                                collider=Collider(),
                                size=Vector(1500, 900))
    App = QApplication(sys.argv)
    window = gamewindow.GameWindow(game_state_test)
    sys.exit(App.exec())
Example #3
0
    count = 0  # want to find at least these many red pixels
    for pixel in pixel_array:
        for color in flower_colors_outer:
            if all(pixel == color):
                count += 1
        for color in flower_colors_inner:
            if all(pixel == color):
                count += 1
    return count


size = 50
config = {}
config['pixel_indices'] = get_indices(size)

gw = gamewindow.GameWindow(size)

counter = 1

states = []

while counter != 0:

    logging.debug("taking screenshot in 3 seconds...")
    time.sleep(1)
    logging.debug("2...")
    time.sleep(0)
    logging.debug("1...")
    time.sleep(0)
    state = observe_state(gw)