当前位置: 首页>>代码示例>>Python>>正文


Python Solver.scramble方法代码示例

本文整理汇总了Python中solver.Solver.scramble方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.scramble方法的具体用法?Python Solver.scramble怎么用?Python Solver.scramble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solver.Solver的用法示例。


在下文中一共展示了Solver.scramble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Controller

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import scramble [as 别名]
class Controller(object):

    """Docstring for Controller. """

    def __init__(self, settings):
        """TODO: to be defined1. """
        self.cubo = Cubo()
        self.cuboescaneado = CuboEscaneado()
        self.settings = settings
        self.scanner = Scanner(self.cubo, self.settings)
        self.robot = Robot()
        self.solver = Solver(self.cubo)


        # camara a of (primero true y luego switch)

    def set_view(self, view):
        self.view = view
        self.view.setImg(cv2.imread('novideo.png'))
    

    def change_setting(self, widget, scroll, value):
        print "en change setting"

        print "rango ", widget.get_name()
        print "scrll ", scroll
        print "value ", value
        value = int(value)
        self.settings[widget.get_name()] = value
    def showSettings(self):
        result = gtk.RESPONSE_CANCEL
        settings = Settings()

        for w in settings:
            print w
            widget = self.view.wTree.get_widget(w)
            widget.set_value(settings[w])
            print 'on_'+w+'_change_value'
            #widget.connect('on_'+w+'_change_value', self.change_setting)            
            widget.connect('change_value', self.change_setting)            
        print "Muestro"

        #run the dialog and store the response
        result = self.view.dlg_settings.run()
        if (result==gtk.RESPONSE_OK):
            #get the value of the entry fields
            print "grabaria la configuracion"
            self.settings.save()

        elif (result==gtk.RESPONSE_CANCEL):
            print "cancelo"
            self.settings.load()
        else:
            print "Result = ",result
                

        #we are done with the dialog, destroy it
        self.view.dlg_settings.hide()

        #return the result
        return result
        

    def camara_off(self):
        self.view.setTxtSolver("Camara apagada")
        self.scanner.reset()
        time.sleep(2/24.0)   # por si esta pendiente el thread 
        self.view.setImg(cv2.imread('novideo.png'))

    def switch_camara(self):
        self.scanner.switch_camara()
        if self.scanner.activo:
            threading.Thread(target=self.scanner_thread, args=(self.scanner,)).start()
        else:
            self.camara_off()

    def resolver(self):
        if self.solver.is_running():
            logging.debug("Aguanta! Estoy en ello!")
            pass
        else:
            print self.solver
            self.solver.scramble(30)
            #obj = ObjetoRedirect(s)
            threading.Thread(target=self.resolver_thread, args=(self.solver,)).start()


    # threads
    def scanner_thread(self, scanner, data=None):
        # pillo el primer frame para no entrar en la chisma
        #self.cuboescaneado.carasescaneadas = 0
        self.robot.reset()
        scanner.reset()
        scanner.activar()

        self.view.setTxtSolver("Comienza escaneo")
        print self.scanner.activo
        while self.scanner.activo:
            self.robot.reset()
            #scanner.reset()
#.........这里部分代码省略.........
开发者ID:RecunchoMaker,项目名称:robik,代码行数:103,代码来源:controller.py


注:本文中的solver.Solver.scramble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。