Dota 2
Legion TD: Reborn
[Suggestion] Distribute summons fairly across the team
This idea came to me yesterday, when at level 2 I got 2 x 40 lumber units on my lane. This happened because I was player 1/4, and the summons in the enemy team were:
Troll, kobold, kobold, kobold, Troll.

I checked the code to make sure and I am right, at this moment you just spawn one unit on the first player's lane, the next unit on the others, and so on.

This is not quite fair since the difficulty of killing the units is not evenly spread across the enemy team. One guy can get 5 roshans and the others could get 4 kobolds each.

The file I examined is:
scripts\vscripts\gamespawner
The method:
line 56: function GameSpawner:SendIncomingUnits(team)

This is the second time I see this language so I am not familiar with it. I will only provide some comments.
My suggestion replaces the code starting with line 80:
local ind = 1
--------------------------
So here is how I suggest solving this problem:

// If there are no enemies, kill all the units and return

// Sort all the units descending on their lumber cost:

// initialize <count> lists, they will include summons for every player.
// initialize <count> sum values, they will contain the total lumber value of units being sent to each player

// For every unit:
....// Get the list with the least accumulated cost
....// Add this unit to the pile with the least accumulated cost and increase the cost

// Associate a player to each list of summons.
// This should be done at random
// If the first list would be associated to player 1 he would always get the biggest summon.

// For every pile
....// For every unit
........// Spawn unit
--------------------------
I know a dynamic programming approach would be more efficient, but this greedy algorithm is quick, easier to implement and adds a minimum of balance to the game.
--------------------------
Good job on the map, now that I've seen most of the files I appreciate your work even more.
Last edited by Mocofan neprihanit; 10 Nov, 2015 @ 12:22pm