Lead Developer, Stardock Entertainment

The Zone of control (ZOC) code has always been a bit odd since it was written for GalCiv2, with weird little bubbles, twists, etc. But it mostly worked in GC2, and I didn't have time to give it a lot of love when porting it to the new engine. The code to update the ZOC is also fairly inefficient, which is why it only updates at the end of a turn. The ZOC expands based on the influence of the city and the player's influence ability.  It works by specifying a source, which has a power and a radius. The power determines how much influence the source is exerting on the tile, so that if there are two sources in the same area with different owners, the player who 'owns' the tile is the one who has the most power in that tile.

This is how the influence looks in 1.09e for a city hub which has a radius of 2: 

Current implementation - radius 2

Looks OK, right?  But wait, city hubs have a radius of 2, and that's only showing ZOC around tiles that are 1 tile away from the hub.  It turns out that the ZOC code was modifying the power of the source (the city hub) by its relative distance from the center using the Euclidean distance forumla  So the closer you were to the center, the higher the power was, and the tiles with distance 2 had a power of 0 because they were at the farthest edge. Also, adding an improvement on the edge of the ZOC didn't bump out the influence because most of them only have a radius of 1, which meant that the only tile that got influence was the one they were actually in, which tended to already have influence from the city hub.  Also, since you can have up to 4 improvements in one tile, each exuding their own influence, they were overwriting each other as sources. 

So first I changed it so that all tiles within the radius got the same power value.  If we cared about pixel distance instead of tile distance, having the influence fade out towards the edge of the range would make sense, but everything uses tile distance for calculations, and the descriptions for how much influence an improvement gives you says 2 tiles.  I also made it so that the influence was calculated from the city tiles instead of the improvements themselves, so that each tile would return the max influence radius and power for all the improvements on the tile.  This is what happened:

 

Per tile influence, constant influence

Well, rats.  The interpolation code is clearly just using the center point of each tile and it looks pretty lame.  The city hub is now starting with a radius of 1 and growing to 2 once it's built up a little more. But it looks lame, even with a radius of 2.  It must need more points.  Hmm, there are some extra points that are commented out in the code that calculates the edges. Maybe just uncommenting those will work?

Uncommented points

Nope.  That obviously isn't going to work. That must be why the points were commented out.  But why weren't they deleted when they clearly don't work? I hate that.  The developer who wrote the original ZOC code hasn't worked here for over 5 years, so there is no target for my crankiness.  

I commented out those lines again in case I needed them for reference and stared at the edge calculation code again.  I decided to simply outline the edges of the tiles, since that would be clear which tiles exactly were under your influence, and the filtering code should take care of adjacent zones.

Outlines

Well, that's better, I guess.  You can tell where your influence is--but wait, why isn't that fire shard in my influence? It's only two tiles away.  Oh, but it's still using the Euclidean distance formula to set the powers.  Well, that's lame, and it makes it look lame too.  No one is going to look at this and say, "Oh, it's calculating the Euclidean distance from the city hub." They're going to count the tiles.

So I made it not check the Euclidean distance and just check everything in the bounding rect with the source at its center and a radius of 2.

Using squares

I think it looks a lot better.  This is a city that has been built up a little, and has two improvements built. The first improvement, the farm, only has a radius of 1, so it was inside the 2 tile radius of the city hub.  It wasn't until I added the next improvement that it bumped out a bit.

I might need to do something with the line interpolation code though, because the leftmost corner of the zone always seems very pointy and we want the rounded squares for aesthetics.  Also, I haven't played very long with this code so I don't know how well it will react with adjacent zones yet. But I think it's headed in the right direction, and the calculations are a lot easier to read now, which is always good.  It's even a bit faster since it doesn't have to calculate the Euclidean distance anymore.  Now, to test and polish...

 


Comments (Page 3)
8 Pages1 2 3 4 5  Last
on Nov 08, 2010

CariElf

Interesting.  We've been calling it ZOC at least since GalCiv2, possibly GalCiv1. 

You can get away with it since AFAIK none of those games have a millitary related Zone of Control mechanic.

But they're right, ZoC commonly refers to units or buildings that exert control on adjacent territory. What that control does depends on the game, but I've seen stuff like being able to take a free attack when other units enter your ZoC, or hindering movement while in a ZoC.

on Nov 08, 2010

jeffalford
This kinda of sounds like much of anything, it sucks being hired to fix other peoples crap work. Way to go Cari, I would have been tempted strongly to tear the thing down and start over! Also I was wondering if there is in the works an alarm system that lets you know when some one or some thing crosses your zone of control.Could be a Tech or Skill that you need to research or learn but that would be cool. My thinking is when the game gets huge, you can forget your focus dealing with some other thing and leave your backdoor wide open. It would be nice to have noise makers or some sort of essence skill that would let you know when your line has been crossed!

Area Of Influence works just as well, might need to tell the new kids!

This.

 

Now, I vote we throw around new name suggestions to replace ZoC.

 

Here are a couple.

(Z/A/S/C/PGOI) Zone/Area/Sphere/Circle/Perimeter/Gravity of Influence

(IRA) Influence Radiation Area

(PPP) Peer Pressure Pentagon (requires code-change to accomodate new shape)

(BBS) Big Bully Sphere

(FSM) Flatulence Spread Matrix

on Nov 08, 2010

abomination5

quoting post

Nope.  That obviously isn't going to work. That must be why the points were commented out.  But why weren't they deleted when they clearly don't work? I hate that.  The developer who wrote the original ZOC code hasn't worked here for over 5 years, so there is no target for my crankiness.  

I commented out those lines again in case I needed them for reference and stared at the edge calculation code again.  I decided to simply outline the edges of the tiles, since that would be clear which tiles exactly were under your influence, and the filtering code should take care of adjacent zones.
 
I'm not sure if this was a joke but it made me laugh.

If not, a reason the lines still exisit, and will 5 years from now. Perhaps Cari wrote them in the future....?

on Nov 08, 2010

CariElf, I think you are doing great. Seems like it will work better like this. Hope it works when two ZOC's are near each other.

Keep up the good work.

on Nov 08, 2010

Bingjack



Colored Blob of Doom?

(Or perhaps the more politically correct term would be," A Doom Blob of Color" )

 

A Filled Out Area of Ethnically Diverse Doom?

on Nov 08, 2010

ZOC is exactly what this is. It is the zone of control for a given city and its improvements.  A previous posters said it just right, since there is no other ZOC types, like a military ZOC v a cultural ZOC, then there is no need to make a specific distinction here.

Looking at the various versions of the ZOC, I think it would cool if it had kind of a mix between the last version and the one from the commented out code. I think it would be nice to have very definitive ZOC but with a few outside artifacts. I think this would give a more natural feel to the ZOC outline, which would be not be a nice quasi circle of radius x.

on Nov 08, 2010

"sphere of influence" works.  Agree that ZOC doesn't.

on Nov 08, 2010

Istari

Now, I vote we throw around new name suggestions to replace ZoC.

 

Here are a couple.

(Z/A/S/C/PGOI) Zone/Area/Sphere/Circle/Perimeter/Gravity of Influence

(IRA) Influence Radiation Area

(PPP) Peer Pressure Pentagon (requires code-change to accomodate new shape)

(BBS) Big Bully Sphere

(FSM) Flatulence Spread Matrix

Domain of Mastery (DoM).

on Nov 09, 2010

This is going to be a nice new feature, which everyone will like, but no one will really give notice to since it seems really minor at first glance.

 

Still, it's a good change.


The question- will the AI be able to make use of this, and could autoplacement of tiles be set to make use of this?  For me, that's the key to how useful this feature will be- though that may take work from Brad as well.

 

 

 

 

on Nov 09, 2010

Bingjack

Quoting cephalo, reply 15
 

Colored Blob of Doom?


We've already got a Blob of Doom.

on Nov 09, 2010

Cari, you're a certified genius darlin, rock on .

Though I do gotta say the ZoC with all the odd points on it reminds me of a shuriken, which are used by Ninjas, which automatically makes it cool...

 

Seriously though, well done. In the final pic there are one or two tiles that are 2 spaces away but still not in the ZoC. If you look above the middle building you see the glow of a dropped pouch or something. The tile above that should be in the ZoC as well since it's within the two tile range. It's looking a lot better and will make more sense and work better too IMO. The chief should give you a raise. Keep up the great work.

on Nov 09, 2010

Wow! At last!!

Thank you, CariElf for fixing it!

But... there is several little questions remains.

 

1. We have actually "half-square" improvements. Maybe it worth to have 1/2 radius for it? I think, it could be better, because 1. It will be complement to existing "City-size ZOC" and 2. Give more "flexible" margins of ZOC. Also it reduce "overpower" of line building and will look more like existing one (but more sane).

 

2. So now this +1 ZOC works for everyone? What about second bug - with no-working "+1 ZOC" ability? (I presume now, it was because the same Euclidian calculations.) It will be +another square?

 

3. Will you fix also "End of turn ZOC" to "Immediate ZOC"? Because now I can simply extend almost-here-ZOC by save/load game. It looks very strange for me.

on Nov 09, 2010

One issue with zone of control is with island maps, where the zone of control will extend far into water hexes that a player can't land on an island without starting a war even when more than half the island is empty.

 

 

on Nov 09, 2010

Just to clarify, does that mean that the way you build your cities matter now?

For example, if I have a resource north of my city outside the ZOC (or whatever name you use), building houses and other improvements toward the resource will also help expending the ZOC to that area?

 

Also, besides catching resources and preventing random enemies from spawning, what advantages does the ZOC give?

Anything new planned for 1.1?

 

on Nov 09, 2010

@random target

Exactly this! I asked allready..

 

Quoting Lantros,
reply 6
Last picture looks really good.

My english isn´t good, so i have to ask to be sure i understand it right. ZOC grows in the direction i build my citys, right?

CariElf
Yes, it will with this new code. In the build currently available on Impulse, it doesn't really do that.

8 Pages1 2 3 4 5  Last