# Math for infinite turn based strategy game

Status
Not open for further replies.

#### spiceant

Level 4
I am making a map that is supposed the mimic the behaviour of turn based strategy games. I have already forced a few concepts into my current version of the map, concepts like:
• A square based positioning system, allowing me to get the number of a square a unit stands on, a number that is unique for every square on the field.
• A data system that will allow me to store... data. Data like which type (crop/iron/stone/forest) the 18 hexagons inside one unique square are and which level those 18 hexagons inside one square are (which determines how much they yield per turn and how much food they eat or produce per turn).
• A random data generation system which randomly generates how many hexagons of each type each of the unique squares will hold (18hexagons x 4types x 88^2) = 69,696 Kilobytes).
• An interface system that will allow me to display the data of one unique square to one person, to up to 12 people simultaneously

I am now working on extending this to make it a playable and unique game which will allow you to build up settlements into villages and bigger, specialized to do something but completely unstoppable in their limits (you should be capable of upgrading all research topics up to 8196 times and be capable of upgrading buildings, resources, military aspects and domestic details that many times as well).

Now here is my biggest problem, because as you upgrade research centers, research is done faster which means research costs must increase with each level and as you upgrade the level to which hexagons (resource harvesters) can be upgraded the costs to upgrade them must increase.
How do i calculate or formulate a formula that could calculate a playable increcement per level for all of the possible research topics?

edit: i am also working on the following concepts:
• (advanced) square movement system that will allow me to mimic a round world
• pathfinding system (algorythm) that will allow units to navigate to far places in this square based maze
• lots of other details that go with a turn based strategy game
If you can help with one of these points it would be nice. I will do all the manual labor on this map, though.

#### map-maker

Level 4
this idea sounds quite a lot like a game i played a while back with some relatives...not to say i wasn't interested in the idea of how it would turn into a wc3 game being as it was quite...interesting as a board game. I being as lazy as i am never got around to trying to make it but if i am right your game is somewhat based on it. i can't remember the exact name but it was something like katan or something sounding similar. the idea sounds like it would be interesting and a break from the usual hero "i pwn j00" aos's and imabalanced arena. hope it turns out ok ^^

#### spiceant

Level 4
colonists of catan?

i am basing this the most off travian.com's game but also some others.

#### IggyZ

Level 5
Sounds awesome, but I'm wondering how you'll define the squares? How do you check what square a unit's in?
Loads of little regions would be stupid, so how are you planning on doing that?

#### VampireKB

Level 9
ye,we all played such a great game as a DEADLOCK 1 and DEADLOCK 2 (mb several remember Alpha Centaur or Civilisation,but i hate them ^_^ )

At WC3 Players wanna only 1 thing "Less talk,more action" (as i may see,when i'm looking for Russian guys.)

at least you may try to make that thing,by making regions,and use mana with "0" regeneration. and "blink" ability for moving forces.

#### spiceant

Level 4
Every square is a region and regions have corners, they have 4 of them (duh).
I (or my trigger) is determines how many squares over the X and Y axis must be placed before it you get to the target location, then it stops.
These triggers dont use WC3 world editor regions

ADU (acronym) = Azerothian Distance Units (one human farm is 128 ADU wide and high)

Gameplayconstantsreals 2 and 3 are the dimensions of one square (128 azerothian distance units)
constantreals 4 and 5 is the location of the bottom left corner (-9216,-9216 ADU)
constantintegers 3 and 4 are the maximum amount of squares over the X and Y axis, 88 and 88.
i can altar these constants at any time and warp my scenario's reality as i wish (as long as it fits within 128*88 ADU in both dimensions)

square controller movement
Events
Unit - A unit Is issued an order targeting a point <--X and Y location of the targettet square will be used to generate the squares its number
Conditions
(Unit-type of (Ordered unit)) Equal to Controller
(Mana of (Ordered unit)) Equal to 10.00
(AreaTheField <gen> contains (Target point of issued order)) Equal to True
Actions
-------- this first action determines which squares number is gonna be revealed and which square its numbers are gonna be used --------
Set TempUnit[4] = (Random unit from (Units owned by (Owner of (Ordered unit)) of type Controller)) <-- this function doesnt have a function at the moment
-------- Tempreal 4 is going to be the X coordinate of the target square --------
Set TempReal[4] = (X of (Target point of issued order)) <-- setting the X location of the target square
Set TempReal[4] = (TempReal[4] - GamePlayConstantsReals[4]) <--Making sure that you got 0 or above square numbers instead of numbers inbetween -4094 and +4094
Set TempReal[4] = (TempReal[4] / GamePlayConstantsReals[2])<-- dividing the X location by the width of the square in ADU
Set TempReal[4] = (Abs(TempReal[4]))<-- making it an integer
Set TempReal[4] = (Real((Integer(TempReal[4]))))
-------- tempreal 5 is going to be the Y location of the target square --------
Set TempReal[5] = (Y of (Target point of issued order))<--Same as X but this time the Y instead of the X from it
Set TempReal[5] = (TempReal[5] - GamePlayConstantsReals[5])<--Same as X
Set TempReal[5] = (TempReal[5] / GamePlayConstantsReals[3])<--same as X
Set TempReal[5] = (Real((Integer(TempReal[5]))))<--same as X
-------- and now tempreal[5] is being multiplied by the amount of squares that will be placed over the X (horizontal) axis --------
Set TempReal[5] = (TempReal[5] x (Real(GamePlayConstantsIntegers[4])))<--Here Y is multiplied by the maximum amount of squares over the X axis see comment 2 lines below this
Set TempReal[6] = (TempReal[5] + TempReal[4])<--Here Tempreal[6] is assigned the number of the targettet square
-------- the Y location is multiplied by the max amount of X squares over the X axis so that if you move up one over the Y axis you can still retain a unique location X that can be extracted from the one location number --------
Unit - Set the custom value of (Ordered unit) to (Integer(TempReal[6]))
Set TempReal[7] = TempReal[6] <-- tempreal[7] is the universal standard value that i use whenever i want to convert a squares number into a location - if you set this real to a number and run the trigger below it will give X and Y locations in the form of TempReal[1,2]
Trigger - Run Convert Number to Square <gen> (ignoring conditions)<--Converting the newfound number into the center of the targettet square
Game - Display to (All players) the text: (Custom Value: + (String((Custom value of (Ordered unit)))))Displaying the Square number
Set TempReal[1] = (TempReal[1] + (GamePlayConstantsReals[2] / 2.00))<-- adding half the width of a square to the location to get to the squares center
Set TempReal[2] = (TempReal[2] + (GamePlayConstantsReals[3] / 2.00))<-- adding half the width of a square to the location to get to the squares center
Unit - Move (Ordered unit) instantly to (Point(TempReal[1], TempReal[2]))

And now converting the X+(Y*MaxXsquares) number into a square location (back to where you started, but this time on the bottom left corner)
Convert Number to Square
Events
Conditions
Actions
Set TempReal[1] = TempReal[7] <-- Tempreal[7] is a holy standard inside the trigger, it is not altered and is a referance
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) the text: (XY: + (String((Integer(TempReal[1])))))Ingame check, used to make sure its using the right number - will be removed in final version
For each (Integer A) from 1 to GamePlayConstantsIntegers[3], do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TempReal[1] Greater than or equal to ((Real(GamePlayConstantsIntegers[3])) - 0.00)
Then - Actions
-------- this repeating function substracts the <Maxamount of X squares over the X axis> untill the Y location is factored out of the X calculation --------
Set TempReal[1] = (TempReal[1] - (Real(GamePlayConstantsIntegers[3]))) <-- beware, this is part of the loop function
Else - Actions
Set TempReal[1] = (Real((Integer(TempReal[1])))) <-- by converting the a real into an integer and into a real again you destroy everything behind the comma, 8,74217 -> 8,00000
Set TempReal[1] = (TempReal[1] x GamePlayConstantsReals[2])Multiplying the amount of X squares by the width of a square (in ADU)
Set TempReal[1] = (TempReal[1] + GamePlayConstantsReals[4]) <-- by adding this constant to it you let it calculate the distance from the bottom left corner instead of the middle of the map
-------- now the X location has been determined in azerothian distance units --------
Set TempReal[2] = TempReal[7]
Set TempReal[2] = (TempReal[2] / (Real(GamePlayConstantsIntegers[4]))) <-- undo what the 1rst trigger did, divide the Y location by which it was multiplied
Set TempReal[2] = (Real((Integer(TempReal[2]))))<-- removing the effect of the X location by the same principle as the X location trigger
Set TempReal[2] = (TempReal[2] x GamePlayConstantsReals[3])Multiplying the amount of X squares by the width of a square (in ADU)
Set TempReal[2] = (TempReal[2] + GamePlayConstantsReals[5])<-- by adding this constant to it you let it calculate the distance from the bottom left corner instead of the middle of the map
-------- now the Y location has been determined in azerothian distance units --------
i realize that the triggering might be hard to understand with my underlined comments all over it.
i couldnt format it really well because the code tag doesnt allow underlines and the quotes dont allow formatting.

the above 2 triggers work perfectly and i have moved on to other aspects of the game. This is the entire reason i made this post because one of these aspects is the math for infinitely upgradeable research topics and i dont have an remotest or faintest idea how to aproach such a prospect.

#### Graber

Level 11
Hmm

Good i am trying to do a TBS battle ( u just select some units from an building and send them into fight into a TBS style battle, just like on Heroes of Might and Magic 3 for exemple...)limited number of attacks spells, moves.But it it is not that easy anyway... Maybe if u can use jass it is possible to make something cool. If u have any ideea about the battle, tell .

Status
Not open for further replies.

[Minigame] Zuluhed's Challenge
Replies
9
Views
2K
Replies
7
Views
1K
Replies
3
Views
770
Replies
5
Views
1K
Replies
1
Views
725