If you are flying around in your 3d Elite Clone, and you fly ahead without turning (With a "when you get to the edge of the map" it moves you to the other edge, like CIV, implementation), then you will eventualy get back to the spacestation
Then the game space is a 3d model of a 4d space. (Just like real space is)
Then the game space is a 3d model of a 4d space. (Just like real space is)
True, but your ship and view is still restricted to your local 3D world. There is no way to travel "sideways" into the 4th dimension.
For example, imagine a 2D space game running on a sheet of paper. Imagine the ships that reach the end of your sheet of paper would "fall" off the end of the universe, so you roll the sheet into a tube, then roll that tube into a torus. Now all your ships loop around the the other side of the universe - there are no "edges" any more.
However, from your 2D ship's viewpoint, nothing has changed visually. You still are living in a 2 dimensional world, even though some strange "magical" effects can occur due to the "real" 3D world outside. And you can't exit that 2D world by rotating off the 2D world plane and heading an a totally different 3D direction.
If you did "break" out of 3D and into 4D space in a 3D game, there's no way you can visualize more than a 3D scene with only 3D eyes. Since what you would see would be a 3D cross-section of a 4D world, any 4D rotations would make that 3D image warp and morph strangely, almost like taking 100 2D slices of a 3D object and animating them as though they were a movie.
It's called polymorphism ... using virtual functions on a class you could have a class (or a BMax Type with methods) 'simulation' or 'universe' and then have a 1D, 2D, 3D, 4D, etc... derived from 'simulation' or 'universe' or whatever you want to call it and using that typical object oriented thought process you could have it all under the same codebase calling the same functions to act upon it as well.
That would work, but that's theoretically no different from implementing a different engine for each dimension space - you still have to write different code for 2D/3D/4D/5D/6D/7D/etc., even though it's all provided through the same interface.
The original question was: can this be done all under the same code? It's probably possible, I just don't understand why you would waste time on dimensions which cannot be seen.