RTS jittering

Started by
0 comments, last by FlyingSpork 15 years ago
Hi, I'm working on an RTS and I want to implement some kind of function in which I can place the units and building in my map randomly. Some mates talked me about jittering, but I didn't find any good information about it. I know it isn't too difficult to implement it but I would like to know if there is any "more proffesional" way to do it... Thanks
Advertisement
I am working on an RTS too, and for generation of things like developed AI cities here's what I do:

1. Keep a 2d array of values (an influence map): the higher the value, the more likely a building gets placed. Initially the whole array is filled with zeros.

2. To place a building, generate a random row and column number representing a spot on the map.

3. Generate a random "chance" (from 1-100 maybe) that the building gets placed there. Add the value of the influence map at that location to this, and if it's greater than a threshold value (mine is 80 initially), then the building is placed, anything else and it's not placed.

4. Add a set amount of influence to the tile the building is placed on, as well as a certain radius of tiles around it, decreasing the amount added with distance.

This way, once one building is placed, other buildings tend to clump around it. In addition, you can lower the value that the chance has to equal to get more spread out groups, or increase it to get a few big groups. Also, it allows a few 'outliers' to add some variety. I also have different building types, some of the buildings have to be built near another type of building, so for such a type, you make the value the chance has to equal impossible to achieve without some influence from the necessary buildings. You could do this to units as well if you wanted.

Hope that helps or gives you some ideas!

This topic is closed to new replies.

Advertisement