Staredit Network > Forums > SC2 Assistance > Topic: dynamic circular/polygonal boundary regions
dynamic circular/polygonal boundary regions
May 16 2011, 4:48 pm
By: NicholasBeige  

May 16 2011, 4:48 pm NicholasBeige Post #1



Hey, so the Trigger editor is my weakness! I hate it, it hates me. We get along just great.

What I want to do is this:

Create a building for each player in the game at a random point in the playable map area. But no two buildings can be within 24 range of each other. I can't get this to work, and this is the simple/easy part I believe.

I was doing something like this:

Code
Create 1 building for Player 1 at random point in map
Set Building[1] to last created unit
Set Temp_Point == random point in map
Do While - Distance between Temp_Point & Building[1] is equal to <24
Set Temp_Point == random point in map
End Do While
Create 1 Building for Player 2 at TempPoint
Set Building[2] to last created unit


Then this was repeated for each of the remaining 4 players, with another condition being added to the Do While statement, with an 'And' thingy. Eg. When creating player 6's location, the While loop will keep randomising the point until it is further than 24 away from P1, P2, P3, P4 AND p5.

I realise that there might be rare cases in which it is impossible for player 6 to have a start location - so I was going about adding validation to check the number of attempts it has taken to give player 6 a home. And if the attempts was over 1000, i would reset and start again at player 1.

BUT, for some reason, the above trigger (as shown) would spawn 2 buildings for player 1, and 2 buildings for player 2 - they wouldn't be closer than 24 to each other but for some reason, the trigger having only 2 lines as 'Create Unit' would end up creating 4 units.

----------------------------------------------------------- I rage quitted my map editor at this point -----------------------------------

I'm going to rebuild it from scratch again and hopefully try and figure it out myself - but in the mean time if anyone has any clues, I'd love to hear em.

Later on, I would like to create a 'circle' of units around the building (I can do this fine), to make a boundary of that buildings 'influence'. However, if two players boundaries overlap (which is impossible in the starting instance due to the 24 range limit on how close they can spawn), then the boundary units will move to an average point between each of them. The reason for this is, later on in the game your main (starting) building can be upgraded to increase it's 'control radius' - which gives you more land to exploit (currently leaving your control radius reverts your units to AI control).

------------------------------

This is ultimately a sort of proof of concept for emulating features such as in Civilisation IV (Culture), and even the Settlers game series, where you would build structures at strategic points to choke off enemy 'control' and gain more resources.

Edit: I cannot use 'Regions' for this since they are too limiting in their shapes. Since, yes, at the start everyone has a perfect 'circle' of control, but as the map fills up, you might get squashed or stretched depending on other players expanding territories around yours.

I will also like to know how to calculate 'if a unit is in the region', although i'm not using a region, i'm using a circle/group of units to define a boundary. I presume I will have to calculate the distance between the nearest boundary unit (to the unit that to the Starting Building. And so, if the unit (being checked)'s distance is greater to the starting building than the nearest boundary's distance - it would be outside? am I right?

Post has been edited 1 time(s), last time on May 16 2011, 4:54 pm by Cardinal.



None.

May 16 2011, 5:59 pm Ahli Post #2

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

@ your ragequit
Programs won't do something without a good reason. Ragequitting is the wrong approach to solve/understand a problem.
I guess that you've had messed up your reset functionality because your approach seems fine.

Since I'm not an algorithm genius I can't give you a perfect solution. :(

But because you didn't hit the execution time limit (you didn't implement a wait every few thousand random point attempts).
So I guess you have enough space to get a working positioning after a few attempts.

You could fill the map with units at start, too. Then you pick a random one, create your building and remove every of these units within the radius. Then you pick another random one and do the same. If you have 0 units left, it failed.

edit:
At region checking:
I'm imagine what you describe as it is shown in Bluebyte's "The Settlers"'s games where 2 close ruler building's of different factions will result in a split in the controllable ground.
Your idea should work and I've no better idea right now.

Post has been edited 1 time(s), last time on May 16 2011, 6:11 pm by Ahli.




May 16 2011, 6:25 pm NicholasBeige Post #3



Well re: my ragequit... it was 4am and I had started off with the circular radius implementation, and detecting units with in it. Then I decided I wanted it to be random start points, so I tried to salvage bits of the triggers I had already done. I ended up with confusing For each Integer loops and wasn't naming my variables sensibly... Passing parameters like a noob and end result: not understanding my code. It was destined for failure.

I'm gonna play Terraria for a few days and then attempt it again, I always find when I'm triggering (coding) that I jump right in it and decide 'this is what I want to do'. But then it just gets messy. When I have made a successful system, I actually spent about 10 minutes writing down in notepad some pseudocode exactly how it would work and then just translated that into triggers.

I'm too impatient :P...



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[06:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[06:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[06:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[06:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[06:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[06:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
[06:45 pm]
NudeRaider -- Vrael
Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
beats me, but I'd make sure to pick the epitome of excellence and nothing less.
[06:41 pm]
Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
[06:38 pm]
Vrael -- I need a go-to solution and someone who understands that Carpets are more than just decorative elements in my home.
Please log in to shout.


Members Online: Zergy