Exemplo n.º 1
0
    def create_func(self):
        """ Creates functions for variables and expression.
        Handles one and two variables. """
        self.function = {
            self.variables[0]: make_function(self.variables, self.expression[0])
        }

        if len(self.variables) > 1:
            function = make_function(self.variables, self.expression[1])
            self.function[self.variables[1]] = function
Exemplo n.º 2
0
    def init_toolbar(self):
        """ Initializes a toolbar, with a run button and delay controls """
        play_icon = QtGui.QIcon(res.imgs.__path__[0] + '/play.png')
        run_action = QtGui.QAction(play_icon, 'Run search', self)
        run_action.setShortcut('Ctrl+R')
        run_action.triggered.connect(self.gui.start_search)

        start_action = QtGui.QAction('&Play yourself', self)
        start_action.triggered.connect(self.gui.start_manual_game)

        train_action = QtGui.QAction('&Train', self)
        train_action.triggered.connect(self.gui.start_training)

        test_action = QtGui.QAction('&Test', self)
        test_action.triggered.connect(self.gui.start_test)

        welch_action = QtGui.QAction('&Welch', self)
        welch_action.triggered.connect(self.gui.start_welch)

        toolbar = self.addToolBar('Toolbar')
        toolbar.addAction(run_action)
        toolbar.addAction(start_action)
        toolbar.addAction(train_action)
        toolbar.addAction(test_action)
        toolbar.addAction(welch_action)

        save_num_plays = [100, 1000, 10000, 30000]
        for save_plays in save_num_plays:
            save_plays_action = QtGui.QAction('&Save ' + str(save_plays), self)
            expr = 'self.gui.save_plays({})'.format(save_plays)
            save_plays_action.triggered.connect(make_function([], expr, locals()))
            toolbar.addAction(save_plays_action)
Exemplo n.º 3
0
    def init_toolbar(self):
        """ Initializes a toolbar, with a run button and delay controls """
        play_icon = QtGui.QIcon(res.imgs.__path__[0]  + '/play.png')
        run_action = QtGui.QAction(play_icon, 'Run search', self)
        run_action.setShortcut('Ctrl+R')
        run_action.triggered.connect(self.graph_gui.start_search)

        toolbar = self.addToolBar('Run')
        toolbar.addAction(run_action)
        for i in range(3, 11):
            color_action = QtGui.QAction('Colors ' + str(i), self)
            expr = 'self.graph_gui.set_color({})'.format(i)
            color_action.triggered.connect(make_function([], expr, locals()))
            toolbar.addAction(color_action)
Exemplo n.º 4
0
    def init_toolbar(self):
        """ Initializes a toolbar, with a run button and delay controls """
        play_icon = QtGui.QIcon(res.imgs.__path__[0] + "/play.png")
        run_action = QtGui.QAction(play_icon, "Run search", self)
        run_action.setShortcut("Ctrl+R")
        run_action.triggered.connect(self.nonogram_gui.start_search)

        toolbar = self.addToolBar("Run")
        toolbar.addAction(run_action)

        delays = [0, 50, 150, 500, 1000]
        for delay in delays:
            delay_action = QtGui.QAction("&Delay: " + str(delay) + " ms", self)
            expr = "self.nonogram_gui.set_delay({})".format(delay)
            delay_action.triggered.connect(make_function([], expr, locals()))
            toolbar.addAction(delay_action)
Exemplo n.º 5
0
    def init_toolbar(self):
        """ Initializes a toolbar, with a run button and delay controls """
        play_icon = QtGui.QIcon(res.imgs.__path__[0] + '/play.png')
        run_action = QtGui.QAction(play_icon, 'Run search', self)
        run_action.setShortcut('Ctrl+R')
        run_action.triggered.connect(self.nav_gui.start_search)

        toolbar = self.addToolBar('Run')
        toolbar.addAction(run_action)

        delays = [0, 50, 150, 500, 1000]
        for delay in delays:
            delay_action = QtGui.QAction('&Delay: ' + str(delay) + ' ms', self)
            expr = 'self.nav_gui.set_delay({})'.format(delay)
            delay_action.triggered.connect(make_function([], expr, locals()))
            toolbar.addAction(delay_action)
Exemplo n.º 6
0
    def init_menubar(self):
        """ Initializes a menubar with the following items:
         File -> [ Load, Kill, Exit ]
         Vertex Numbers -> [Yes, No]
         Delay -> [0 ms, 50 ms, 150 ms, 500 ms, 1000 ms]
        """
        load_action = QtGui.QAction('&Load graph', self)
        load_action.setShortcut('Ctrl+L')
        load_action.triggered.connect(self.graph_gui.set_graph)

        kill_action = QtGui.QAction('&Kill search', self)
        kill_action.setShortcut('Ctrl+K')
        kill_action.triggered.connect(self.graph_gui.thread.end_search)

        exit_action = QtGui.QAction('&Exit', self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.triggered.connect(QtGui.qApp.quit)

        yes_action = QtGui.QAction('&Yes', self)
        yes_action.triggered.connect(
            lambda: self.graph_gui.set_vertex_numbering(True)
        )

        no_action = QtGui.QAction('&No', self)
        no_action.triggered.connect(
            lambda: self.graph_gui.set_vertex_numbering(False)
        )

        menu = self.menuBar()
        file_menu = menu.addMenu('&File')
        file_menu.addAction(load_action)
        file_menu.addAction(kill_action)
        file_menu.addAction(exit_action)

        numbering_menu = menu.addMenu('&Vertex Numbers')
        numbering_menu.addAction(yes_action)
        numbering_menu.addAction(no_action)

        delay_menu = menu.addMenu('&Delay')
        delays = [0, 50, 150, 500, 1000]
        for delay in delays:
            delay_action = QtGui.QAction('&' + str(delay) + ' ms', self)
            expr = 'self.graph_gui.set_delay({})'.format(delay)
            delay_action.triggered.connect(make_function([], expr, locals()))
            delay_menu.addAction(delay_action)
Exemplo n.º 7
0
    def init_menubar(self):
        """ Initializes a menubar with the following items:
        File -> [ Kill, Reset, Exit ]
        Delay -> [ 10 ms, 50 ms, 150 ms, 500 ms ]
        Screenshots -> [ On, Off ]
        Depth -> [ 2, 3, 4 ]
        """
        menu = self.menuBar()
        file_menu = menu.addMenu('&File')
        delay_menu = menu.addMenu('&Delay')
        screenshots_menu = menu.addMenu('&Screenshots')
        pickling_menu = menu.addMenu('&Save states')
        delete_state_menu = menu.addMenu('&Delete states')
        min_tile_menu = menu.addMenu('&Min tile')
        heuristics_menu = menu.addMenu('&Heuristics')
        depth_menu = menu.addMenu('&Depth')
        epochs_menu = menu.addMenu('&Epochs')
        num_cases_menu = menu.addMenu('&Number of cases')

        kill_action = QtGui.QAction('&Kill running process', self)
        kill_action.setShortcut('Ctrl+K')
        kill_action.triggered.connect(self.gui.end_process)
        file_menu.addAction(kill_action)

        reset_size_action = QtGui.QAction('&Reset size', self)
        reset_size_action.triggered.connect(self.gui.reset_size)
        file_menu.addAction(reset_size_action)

        exit_action = QtGui.QAction('&Exit', self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.triggered.connect(QtGui.qApp.quit)
        file_menu.addAction(exit_action)

        delays = [0, 50, 150, 500]
        for delay in delays:
            delay_action = QtGui.QAction('&' + str(delay) + ' ms', self)
            expr = 'self.gui.set_delay({})'.format(delay)
            delay_action.triggered.connect(make_function([], expr, locals()))
            delay_menu.addAction(delay_action)

        screens_on = QtGui.QAction('&On', self)
        screens_on.triggered.connect(lambda: self.gui.set_screenshots(True))
        screenshots_menu.addAction(screens_on)

        screens_off = QtGui.QAction('&Off', self)
        screens_off.triggered.connect(lambda: self.gui.set_screenshots(False))
        screenshots_menu.addAction(screens_off)

        pickling_on = QtGui.QAction('&On', self)
        pickling_on.triggered.connect(lambda: self.gui.set_pickling(True))
        pickling_menu.addAction(pickling_on)

        pickling_off = QtGui.QAction('&Off', self)
        pickling_off.triggered.connect(lambda: self.gui.set_pickling(False))
        pickling_menu.addAction(pickling_off)

        depths = [2, 3, 4]
        for depth in depths:
            depth_action = QtGui.QAction('&' + str(depth), self)
            expr = 'self.gui.set_depth({})'.format(depth)
            depth_action.triggered.connect(make_function([], expr, locals()))
            depth_menu.addAction(depth_action)

        min_tiles = [7, 8, 9, 10, 11, 12]
        for min_tile in min_tiles:
            min_tile_action = QtGui.QAction('&' + str(2 ** min_tile), self)
            expr = 'self.gui.set_min_save_tiles({})'.format(min_tile)
            min_tile_action.triggered.connect(make_function([], expr, locals()))
            min_tile_menu.addAction(min_tile_action)

        delete_states = [7, 8, 9, 10, 11, 12]
        for delete_state in delete_states:
            delete_state_action = QtGui.QAction('&' + str(2 ** delete_state), self)
            expr = 'self.gui.delete_states({})'.format(delete_state)
            delete_state_action.triggered.connect(make_function([], expr, locals()))
            delete_state_menu.addAction(delete_state_action)

        heuristics = [0, 1]
        for heuristic in heuristics:
            heuristics_action = QtGui.QAction('&Heuristic ' + str(heuristic + 1), self)
            expr = 'self.gui.set_heuristic({})'.format(heuristic)
            heuristics_action.triggered.connect(make_function([], expr, locals()))
            heuristics_menu.addAction(heuristics_action)

        epochs = [10, 30, 60, 100, 200, 300, 500, 1000, 2000, 3000, 4000, 5000, 10000]
        for epoch in epochs:
            epoch_action = QtGui.QAction('&' + str(epoch), self)
            expr = 'self.gui.set_epochs({})'.format(epoch)
            epoch_action.triggered.connect(make_function([], expr, locals()))
            epochs_menu.addAction(epoch_action)

        num_cases_items = [10, 100, 500, 1000, 5000, 10000, 20000, 30000, 40000, 50000, 60000]
        for num_cases in num_cases_items:
            num_cases_action = QtGui.QAction('&' + str(num_cases), self)
            expr = 'self.gui.set_num_cases({})'.format(num_cases)
            num_cases_action.triggered.connect(make_function([], expr, locals()))
            num_cases_menu.addAction(num_cases_action)