def from_json(json_data, seed):
        bsg = BigStepGame()

        #bsg.dfa = cpp_placement.DFA()
        bsg.dfa = translate_dfa(interfaces.POWER_PHRASES)

        bsg.problem_id = json_data['problemId'] \
            if 'problemId' in json_data else -1
        bsg.remaining_units = json_data['sourceLength']
        bsg.seed = seed
        bsg.lcg = list(
            itertools.islice(game.lcg(seed), 0, bsg.remaining_units))


        bsg.width = json_data['width']
        bsg.height = json_data['height']

        # (x, y) of all filled cells
        bsg.filled = set()

        for pt in json_data['filled']:
            x, y = xy = pt['x'], pt['y']
            assert 0 <= x < bsg.width, x
            assert 0 <= y < bsg.height, y
            assert xy not in bsg.filled
            bsg.filled.add(xy)

        bsg.units = list(map(game.Unit, json_data['units']))

        bsg.cpp_units = []
        for unit in bsg.units:
          unit_builder = cpp_placement.UnitBuilder()
          for shapes in [unit.even_shapes, unit.odd_shapes]:
            for angle, shape in enumerate(shapes):
              for cell_x, cell_y in shape.members:
                unit_builder.SetCell(
                    shape.pivot_x, shape.pivot_y, angle,
                    shape.min_x, shape.min_y,
                    shape.max_x, shape.max_y,
                    cell_x, cell_y)
          bsg.cpp_units.append(unit_builder.Build(bsg.width, bsg.height))

        bsg.move_score = 0
        bsg.ls_old = 0
        bsg.game_ended = False
        bsg.reason = None

        bsg.current_unit = None
        bsg.current_cpp_unit = None
        bsg.initial_placement = None

        bsg.pick_next_unit()

        return bsg
def test_lcg():
    eq_(list(itertools.islice(game.lcg(17), 10)),
        [0,24107,16552,12125,9427,13152,21440,3383,6873,16117])