コード例 #1
0
ファイル: test_tools.py プロジェクト: alberthier/bhware-bhbot
 def test_quasi_equal(self):
     self.assertTrue(tools.quasi_equal(1.00000001, 1.0))
     self.assertFalse(tools.quasi_equal(1.00000001, 4.0))
     self.assertTrue(
         tools.quasi_equal(tools.EPSILON,
                           tools.EPSILON + tools.EPSILON / 2.0))
     self.assertFalse(tools.quasi_equal(tools.EPSILON, tools.EPSILON * 2.0))
コード例 #2
0
    def userEvent(self, button, x, y):
        if button == 'left-button':
            self.ghost_layer.reset_origin()
            self.path_layer.add_segment()

            if self.ghost_layer.forward:
                direction = "MARCHE_AVANT"
            else:
                direction = "MARCHE_ARRIERE"
            angle = self.ghost_layer.convert_angle()
            if not tools.quasi_equal(self.current_angle, angle):
                self.current_angle = angle
                self.commands.append(('rotate_to', angle))
            self.commands.append(
                ('move_to', direction,
                 self.ghost_layer.mouse_item.pos().y() / 1000.0,
                 self.ghost_layer.mouse_item.pos().x() / 1000.0))
        elif button == 'u':
            self.commands.append(('shovel_up', ))
        elif button == 'd':
            self.commands.append(('shovel_down', ))
        elif button == 'a':
            self.commands.append(('anti_block_on', ))
        elif button == 'z':
            self.commands.append(('anti_block_off', ))

        self.update_code()
コード例 #3
0
 def on_simulator_graph_map_edges(self, packet):
     segment_items = 5
     for i in range(len(packet.points) // segment_items):
         y1 = packet.points[i * segment_items] * 1000.0
         x1 = packet.points[i * segment_items + 1] * 1000.0
         y2 = packet.points[i * segment_items + 2] * 1000.0
         x2 = packet.points[i * segment_items + 3] * 1000.0
         penality = packet.points[i * segment_items + 4]
         item = QGraphicsLineItem(x1, y1, x2, y2)
         if tools.quasi_equal(penality, 0.0):
             style = Qt.SolidLine
         else:
             style = Qt.DotLine
         item.setPen(QPen(QColor(self.color).lighter(120), 2, style))
         self.edges.append(item)
         self.addToGroup(item)
コード例 #4
0
ファイル: mainwindow.py プロジェクト: alberthier/bhware
    def userEvent(self, button, x, y):
        if button == 'left-button':
            self.ghost_layer.reset_origin()
            self.path_layer.add_segment()

            if self.ghost_layer.forward:
                direction = "MARCHE_AVANT"
            else:
                direction = "MARCHE_ARRIERE"
            angle = self.ghost_layer.convert_angle()
            if not tools.quasi_equal(self.current_angle, angle):
                self.current_angle = angle
                self.commands.append(('rotate_to', angle))
            self.commands.append(('move_to', direction, self.ghost_layer.mouse_item.pos().y() / 1000.0, self.ghost_layer.mouse_item.pos().x() / 1000.0))
        elif button == 'u':
            self.commands.append(('shovel_up',))
        elif button == 'd':
            self.commands.append(('shovel_down',))
        elif button == 'a':
            self.commands.append(('anti_block_on',))
        elif button == 'z':
            self.commands.append(('anti_block_off',))

        self.update_code()
コード例 #5
0
ファイル: test_tools.py プロジェクト: alberthier/bhware
 def test_quasi_equal(self):
     self.assertTrue(tools.quasi_equal(1.00000001, 1.0))
     self.assertFalse(tools.quasi_equal(1.00000001, 4.0))
     self.assertTrue(tools.quasi_equal(tools.EPSILON, tools.EPSILON + tools.EPSILON / 2.0))
     self.assertFalse(tools.quasi_equal(tools.EPSILON, tools.EPSILON * 2.0))