예제 #1
0
    def test_single_1x1(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", 0.5, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(1, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", 1.5, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(1, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", -0.5, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(1, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", -1.5, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(1, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
예제 #2
0
    def test_multiple_1x1(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", 0.5, 0.5),
            get_entity_dict("transport-belt", 1.5, 1.5),
        ]))
        g = Grid(bp)
        self.assertEqual(2, g.width)
        self.assertEqual(2, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
        self.assertEqual(bp.entities[1], g[1, 1])
        self.assertIsNone(g[0, 1])
        self.assertIsNone(g[1, 0])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", -2.5, -2.5),
            get_entity_dict("transport-belt", -2.5, 2.5),
            get_entity_dict("transport-belt", 2.5, -2.5),
            get_entity_dict("transport-belt", 2.5, 2.5),
        ]))
        g = Grid(bp)
        self.assertEqual(6, g.width)
        self.assertEqual(6, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
        self.assertEqual(bp.entities[1], g[0, 5])
        self.assertEqual(bp.entities[2], g[5, 0])
        self.assertEqual(bp.entities[3], g[5, 5])
예제 #3
0
    def test_single_1x2(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("splitter", 1, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(2, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
        self.assertEqual(bp.entities[0], g[1, 0])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("splitter", 0.5, 1, direction=2),
        ]))
        g = Grid(bp)
        self.assertEqual(1, g.width)
        self.assertEqual(2, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
        self.assertEqual(bp.entities[0], g[0, 1])

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("splitter", -1, 0.5),
        ]))
        g = Grid(bp)
        self.assertEqual(2, g.width)
        self.assertEqual(1, g.height)
        self.assertEqual(bp.entities[0], g[0, 0])
        self.assertEqual(bp.entities[0], g[1, 0])
예제 #4
0
    def test_bounding_box_single_3x3(self):
        bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("assembling-machine-1", 0.5, 0.5)]))
        self.assertEqual((Position(-1, -1), Position(2, 2)), bp.bounding_box)

        bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("assembling-machine-1", 1.5, 1.5)]))
        self.assertEqual((Position(0, 0), Position(3, 3)), bp.bounding_box)

        bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("assembling-machine-1", -1.5, -1.5)]))
        self.assertEqual((Position(-3, -3), Position(0, 0)), bp.bounding_box)
예제 #5
0
    def test_get_dimensions_3x3_square(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", 0.5, 0.5),
            get_entity_dict("transport-belt", 2.5, 2.5),
        ]))
        self.assertEqual((3, 3), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("assembling-machine-1", -0.5, -0.5),
            get_entity_dict("transport-belt", 2.5, 2.5),
        ]))
        self.assertEqual((5, 5), bp.get_dimensions())
예제 #6
0
    def test_get_dimensions_single_rails(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0)
        ]))
        self.assertEqual((5, 8), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0, direction=5)
        ]))
        self.assertEqual((5, 8), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0, direction=2)
        ]))
        self.assertEqual((8, 5), bp.get_dimensions())
예제 #7
0
 def test_mixed(self):
     bp = Blueprint(**BlueprintDict(entities=[
         get_entity_dict("assembling-machine-1", 9.5, -5.5),
         get_entity_dict("electric-furnace", 6.5, -3.5),
         get_entity_dict("transport-belt", 8.5, -3.5),
         get_entity_dict("splitter", 5.5, -7, direction=2),
     ]))
     g = Grid(bp)
     self.assertEqual(6, g.width)
     self.assertEqual(6, g.height)
     self.assertEqual(g[0, 0], bp.entities[3])
     self.assertEqual(g[0, 1], bp.entities[3])
     self.assertEqual(g[3, 1], bp.entities[0])
     self.assertEqual(g[4, 1], bp.entities[0])
     self.assertEqual(g[5, 1], bp.entities[0])
     self.assertEqual(g[3, 2], bp.entities[0])
     self.assertEqual(g[4, 2], bp.entities[0])
     self.assertEqual(g[5, 2], bp.entities[0])
     self.assertEqual(g[3, 3], bp.entities[0])
     self.assertEqual(g[4, 3], bp.entities[0])
     self.assertEqual(g[5, 3], bp.entities[0])
     self.assertEqual(g[0, 3], bp.entities[1])
     self.assertEqual(g[1, 3], bp.entities[1])
     self.assertEqual(g[2, 3], bp.entities[1])
     self.assertEqual(g[0, 4], bp.entities[1])
     self.assertEqual(g[1, 4], bp.entities[1])
     self.assertEqual(g[2, 4], bp.entities[1])
     self.assertEqual(g[0, 5], bp.entities[1])
     self.assertEqual(g[1, 5], bp.entities[1])
     self.assertEqual(g[2, 5], bp.entities[1])
     self.assertEqual(g[3, 4], bp.entities[2])
예제 #8
0
    def test_get_bounding_box_3x3_square(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", 0.5, 0.5),
            get_entity_dict("transport-belt", 2.5, 2.5),
        ]))
        self.assertEqual((Position(0, 0), Position(3, 3)), bp.bounding_box)

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", -0.5, -0.5),
            get_entity_dict("transport-belt", 1.5, 1.5),
        ]))
        self.assertEqual((Position(-1, -1), Position(2, 2)), bp.bounding_box)

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("transport-belt", -2.5, -2.5),
            get_entity_dict("transport-belt", -0.5, -0.5),
        ]))
        self.assertEqual((Position(-3, -3), Position(0, 0)), bp.bounding_box)
예제 #9
0
파일: Grid.py 프로젝트: jurgyy/Factor-IO
def _main():
    bp = Blueprint(**BlueprintDict(entities=[
        get_entity_dict("transport-belt", -3.5, 0.5),
        get_entity_dict("transport-belt", 2.5, 2.5),
        get_entity_dict("assembling-machine-1", 5.5, 2.5),
        get_entity_dict("splitter", 0.5, 2, direction=2),
    ]))
    print(bp)
    g: Grid = Grid(bp)
    print(g)
예제 #10
0
    def test_get_dimensions_multiple_rails(self):
        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0),
            get_entity_dict("curved-rail", 18, 0)
        ]))
        self.assertEqual((23, 8), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0, direction=0),
            get_entity_dict("curved-rail", 18, 0, direction=4)
        ]))
        self.assertEqual((24, 8), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0, direction=2),
            get_entity_dict("curved-rail", 0, 18, direction=2)
        ]))
        self.assertEqual((8, 23), bp.get_dimensions())

        bp = Blueprint(**BlueprintDict(entities=[
            get_entity_dict("curved-rail", 0, 0, direction=2),
            get_entity_dict("curved-rail", 0, 18, direction=6)
        ]))
        self.assertEqual((8, 24), bp.get_dimensions())
예제 #11
0
 def test_multiple_1x2(self):
     bp = Blueprint(**BlueprintDict(entities=[
         get_entity_dict("splitter", 1, 0.5),
         get_entity_dict("splitter", 1.5, 2, direction=2),
         get_entity_dict("splitter", -0.5, 2),
     ]))
     g = Grid(bp)
     self.assertIsNone(g[0, 0])
     self.assertEqual(bp.entities[0], g[1, 0])
     self.assertEqual(bp.entities[0], g[2, 0])
     self.assertIsNone(g[0, 1])
     self.assertIsNone(g[1, 1])
     self.assertEqual(bp.entities[1], g[2, 1])
     self.assertEqual(bp.entities[2], g[0, 2])
     self.assertEqual(bp.entities[2], g[1, 2])
     self.assertEqual(bp.entities[1], g[2, 2])
예제 #12
0
 def test_get_dimensions_single_1x1(self):
     bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("transport-belt", 0.5, 0.5)]))
     self.assertEqual((1, 1), bp.get_dimensions())
예제 #13
0
 def test_get_dimensions_mixed(self):
     bp = Blueprint(**BlueprintDict(entities=[
         get_entity_dict("stone-furnace", -10, 0),
         get_entity_dict("stone-furnace", 10, 0),
     ]))
     self.assertEqual((22, 2), bp.get_dimensions())
예제 #14
0
    def test_bounding_box_single_1x1(self):
        bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("transport-belt", 0.5, 0.5)]))
        self.assertEqual((Position(0, 0), Position(1, 1)), bp.bounding_box)

        bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("transport-belt", -0.5, -0.5)]))
        self.assertEqual((Position(-1, -1), Position(0, 0)), bp.bounding_box)
예제 #15
0
 def test_get_dimensions_single_3x3(self):
     bp = Blueprint(**BlueprintDict(entities=[get_entity_dict("assembling-machine-1", 1.5, 1.5)]))
     self.assertEqual((3, 3), bp.get_dimensions())