Jump to content

Image of the Day

Everything is fine. 

#screenshotsaturday #indiedev #gamedev https://t.co/98BAKUInyo
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.

Sign up now

Infinite world?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 good_fella   Members   


Posted 22 April 2012 - 07:21 AM

I am currently teaching myself Java, I would consider myself intermediate having done many tutorials, etc. I want to eventually make a space exploration and trading game. I had always assumed that I would need to create a "map" for the universe, and plan everything out before hand. But as a minecraft player, this got me thinking about making an infinite world that spawns new areas whenever you get close to the edge.

Because I want a trading game, with planets having an economy and some AI (to build up defences and infrastructure, etc), I don't know if an infinite world is viable for the game I want to make?

In minecraft, if you, for instance, plant a tree and then move far away from it, the tree won't grow because the chunk isn't loaded. Is this a CPU constraint or a GPU constraint? Because a GPU constraint doesn't matter as I don't need to have all these chunks rendered at the same time (and anyway my game will be a 2d map, not 3d environment like minecraft). I guess it's mostly a CPU constraint though, processing all the info of all these chunks (plants growing and such in minecraft).

How would it work for a game where I wanted planets to continue to function no matter where the player is? So if a player travels to a far away primitive planet, then goes home, then much time passes and he returns and the same planet is high tec. Would that be feasible? Or would it put too much stress on the CPU?

If the player played the game for a long time, and explored a lot, the game would get really bloated and slow wouldn't it? Or could I sort of stagger and or simply AI development? Like, guestimate what the AI would do in say 5 in game years and process that (for far away planets), rather than having it all process in real time?

I'm still a long way off having the programming knowledge to actually make my game, but I'm just trying to make a design document for it atm and really want to lock in the foundations, ie, 2d vs 3d (almost certainly 2d, but aspirations for 3d -will be map only though, no 3d graphics- too noob to be dealing with the physics of 3d space combat atm), infinite world vs fixed preplanned maps, etc.

What I'm thinking atm is an infinite 2d world, that exists only as a map, with markers that move around like a board game. But that functions in real time. Originally I was thinking Flash, but I'm finding that java has so much more docunmentation that it's so much easier to learn, but what do you reckon is more practical?

ATM it's going to be single player, I'm hoping it could be browser based with a download option (but don't know how big the file would be yet if it's practical for browser, as well as server hosting costs, etc). Perhaps eventually it'll be multiplayer, but this would only be possible with major financial investment so unlikely. I'm just trying to create a game that I really want to play, that I feel hasn't been created yet (played EVE online, star wolves, sins of a solar empire, home world, and many other space exploration/trading games, not happy with any of them).

So, further explanation of idea. Say you start in the centre, with a ship and a planet, player is at X chunk:


Then it will load chunks if when you get close to the edge:


Etc, and possible in 3d, so imagine a layer of O's above and below that also get spawned.

Each O might represent a solar system, or empty space, or an asteroid field, or a space station, etc. Randomly generated with a different % for each, and solar systems with different properties (number of planets, types of planets, type of star, etc).

All the time planets AI will be working, so it can build up resources for the player to trade, build up defense for the player to fight, etc. But will this work if the potential number of planets is infinite? Maybe it would work if it was turn based instead of real time? (But then would the "turns" get too slow that the player would get frustrated?)

And the planets would be doing things such as increasing population, building/upgrading structures, possibly trading with other AI (although this might be getting too complicated), expanding to other planets (again, maybe too complicated), and building up armies (space ships). Chunks that spawn things like asteroid fields, deep space, star stations, etc, don't need to be doing anything though.

What do you reckon? Infinite or non-infinite? Granted this is just for early design phase, beyond theory I still don't know how to program an infinite world, but I want to really try and get an established design document going before I start coding any of this, and I know the design document will take quite awhile in itself.

Infinite or non-infinite, what do you reckon?

#2 alcedine   Members   


Posted 22 April 2012 - 09:31 AM

The CPU loadis going to depend heavily on a player's projected maximum range, as well as the complexity of the operations that each tile performs. If it's just a question of finite versus infinite, you could just postpone that decision until you have some rough version of what each square does each turn, then make a program that measures the time taken by a calculation on 1k, 1M, 1bln etc. squares (that's cubes 10, 100, 1000 on a side*); you'll be able to find your feasible range that way, and determine for yourself whether that's something that you expect your player to reach. (also, note that it's probably fine to use a pretty streamlined version of AI for far-away squares, and possibly "frame-skip" on them or draw them every five turns or what-have-you).

* note that this doesn't mean you'll find a measure of the maximum side length, since it's, erhm, unlikely that your player will hit a billion squares in a single game, ever.

#3 Antheus   Members   


Posted 22 April 2012 - 09:57 AM

How would it work for a game where I wanted planets to continue to function no matter where the player is?

Functional programming.

Instead of simulating economy of a planet step by step, you express its economy as a mathematical function, perhaps of time:
double moneyOnPlanet(float time) {
  return startingMoney + sin(time);
Whenever you're in range of a planet and need to know how much money it has, evaluate the function with current time. Function above is simple and will return fluctuating value.

Advantage of this approach is that simulation doesn't need to be running to "update".

It can go even further. Instead of defining planets, generate them procedurally:
List<Planet> getPlanetsAtSystemAt(int x, int y, int z) {
  Random r = new Random(x * y * z);
  int nPlanets = r.nextInt() % 10;
  List<Planet> p = new List<Planet>(nPlanets);
  for (int i = 0; i < nPlanets) {
    p.add(new Planet(r.nextInt()); // parameter is starting money
  return p;
Now, as you move around space, and need to know if there are any planets at (x,y,z), just evaluate the above. It will give same result no matter when it's called, meaning that result doesn't need to be stored.

Go from there.

There was a game that did this called Elite: Frontiers. It was a buggy mess, but it did have 1 billion star systems, all uniquely named, with their own economies, asteroids, resources, space ships. It was 600 kilobytes long, graphics, sound, universe and everything and ran under DOS in 640kb of memory or something close.

#4 good_fella   Members   


Posted 22 April 2012 - 03:59 PM

That's awesome guys, thanks. Yeah I guess I'll have to see how I go with the AI. Resource gathering seems simple enough, just not sure about having them build buildings, and trade/battle with other AI, expand to other planets, level up their tech tree, etc. I don't want all these far away planets to just hoard resources as that would seriously screw up the games economy. But yeah, maybe I'll only figure all this out by actually trying to do it. Will definitely check out Elite, sounds epic!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.