I am trying to make a platform game that generates semi-random levels. I want it to read in the segments of a level and then choose a random one from among these segments. I am stuck. I have absolutely no clue how to set up a system like this and I can't find any good tutorials.
The answer to this is highly dependent on what you want out of your semi-random levels, but I'll assume for now that you are moving horizontally and want chunks of level such as a pit with a platform over it or a constrained space with enemies in it that you set up beforehand.
To take this approach you need to have the ability to load one of these level chunks on the fly. This means that you need to be able to have everything that describes one (tile layout if tile based, types of objects and locations/orientations for everything else) in an object that you can reference such as a class. This could be as simple as an object containing an array of what to spawn and where, but you can also add other things as necessary.
Once you have the ability to have these chunks in memory, you then need to set up your game to be able to take one of these chunks and a location so you can spawn all the objects relative to that location. This location could be the top left corner, the place where the edge of the ground touches the new edge of the ground, whatever. So long as the level chunk object locations are also described as positions relative to this anchor.
From here you have a couple options. Assuming you create a number of level chunks, you can then choose from them randomly to set up your random level.
If you know you want the level to be a fixed set and/or finite, at this point you can simply load x random segments at the appropriate positions (perhaps with one or two fixed to things you want at certain locations like a level end or a checkpoint).
If you want to generate your levels on the fly and/or have an infinite level, load enough level chunks to cover the camera plus at least one off each edge the player can move in. These are your buffer so the player never sees empty space (also so enemies off screen can do things if that's how you like it). When one of those buffer chunks would come into the camera, load a new random chunk out of camera as the new buffer. Depending on your gameplay you can also remove the level chunk you moved away from to avoid having too much in memory or if you know you're not going back that way.
There are of course a lot of modifications that can be made to this general formula as well as refinements for various behaviour; but hopefully this will give you a good jumping off point for exploring the world of level generation.