Statistics: Posted by keyser — 05 Oct 2019, 15:24
Statistics: Posted by thecore — 24 Sep 2019, 09:48
Statistics: Posted by Geosearchef — 26 Dec 2018, 02:43
Statistics: Posted by nine2 — 26 Dec 2018, 02:10
Statistics: Posted by Katharsas — 19 Dec 2018, 19:41
Statistics: Posted by Geosearchef — 14 Dec 2018, 14:56
var playerArray: Array = [700, 783, 843, 953, 1100, 1253];
var temp: int;
var a;
var b;
var stringArray: Array = [];
var lastScore: int = 99999;
var fairestTeam: String = "";
var i: int;
var j: int;
var size: uint;
var myString: String = "";
var team1: int;
var team2: int;
var diff: int;
f_mutate(playerArray, 0, playerArray.length - 1);
//returns a string with the team
trace(fairestTeam);
//f_mutate function
function f_mutate(arr: Array, start: int, end: int)
{
if (start == end)
{
size = end + 1;
i = 0;
j = 0
myString = "";
team1 = 0;
team2 = 0;
diff = 0;
for (i = 0; i < size; i++)
{
myString += String(arr[i] + ",");
if (i < (size * 0.5))
{
team1 += arr[i];
}
else
{
team2 += arr[i];
}
}
if (team1 >= team2)
{
diff = team1 - team2;
}
else
{
diff = team2 - team1;
}
myString += " diff " + diff;
if (diff < lastScore)
{
fairestTeam = myString;
lastScore = diff;
}
myString = "";
return;
}
var k:int = 0;
for (k = start; k <= end; k++)
{
//change position in array
temp = arr[start];
arr[start] = arr[k];
arr[k] = temp;
f_mutate(arr, start + 1, end);
temp = arr[start];
arr[start] = arr[k];
arr[k] = temp;
}
}
Statistics: Posted by thecore — 14 Dec 2018, 14:35
Statistics: Posted by moonbearonmeth — 14 Dec 2018, 06:16
The lobby already has an option to mix spawns on start and balance teams although I don't know how well this works
If you want to take a look or implement sth take a look at the github repo
Statistics: Posted by thecore — 14 Dec 2018, 01:03
Statistics: Posted by Geosearchef — 13 Dec 2018, 18:02