Lame wrote:
what exactly is the point of this?
the bets way to balance 2 vs 2 is always #1 and #4 vs #2,#3
If #1 vs #2 have better Game Quality to #1 vs #3.
New change :
- Code:
--
function joinMyTables(t1, t2)
for k,v in ipairs(t2) do
table.insert(t1, v)
end
return t1
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
local function permutation(a, n, cb)
if n == 0 then
cb(a)
else
for i = 1, n do
a[i], a[n] = a[n], a[i]
permutation(a, n - 1, cb)
a[i], a[n] = a[n], a[i]
end
end
end
--Usage
local function callback(a, i)
print('{'..table.concat(a, ', ')..'}')
--
index = index + 1
print('Index : '..index)
local TotalA = a[1]+a[2]
tableA[2] = TotalA
local TotalB = a[3]+a[4]
tableB[2] = TotalB
local Total = TotalA+TotalB
tableAB[2] = Total
local PurcentA = ((TotalA)*100)/Total
tableA[3] = PurcentA
local PurcentB = ((TotalB)*100)/Total
tableB[3] = PurcentB
local PurcentRatio = ''
if TotalA < TotalB then
PurcentRatio = (TotalA/TotalB)*100
else
PurcentRatio = (TotalB/TotalA)*100
end
tableAB[3] = PurcentRatio
if maxx < PurcentRatio then
maxx = PurcentRatio
if table.concat(a) == table.concat(tableAB[0]) then
print('ALL DEV : '..tableAB[0][1]..tableAB[0][2]..tableAB[0][3]..tableAB[0][4])
end
--max_index = i -- PROBLEM HERE, 'i' return Nil
end
--
--print('TotalA : '..TotalA..' / TotalB : '..TotalB)
--print('Total : '..Total)
print('A : '..round(PurcentA)..'% / B : '..round(PurcentB)..'%')
print('Ratio : '..round(PurcentRatio)..'%')
print('')
end
--
tableA = {} -- Team A
tableB = {{}} -- Team B
number = 4 -- Number of Player
maxx = 0 -- Max rating
max_index = '' -- Index du meilleur rating
index = 0
i = 0
tableA[0] = {10, 2} -- DEV
tableA[1] = {'A', 'B'} -- PlayerName
--tableA[2] -- Total A
--tableA[3] -- % A
tableB[0] = {5, 5} -- DEV
tableB[1] = {'C', 'D'} -- PlayerName
--tableB[2] -- Total B
--tableB[3] -- % B
tableAB = {}
tableAB[0] = joinMyTables(tableA[0], tableB[0]) -- ALL DEV
tableAB[1] = joinMyTables(tableA[1], tableB[1]) -- ALL PlayerName
--tableAB[2] -- Total
--tableAB[3] -- % Best Rating
--
permutation(tableAB[0], number, callback)
print('Meilleur rating : '..round(maxx, 2)..'%')
print('Index du meilleur rating : '..max_index..'NEED INFO HERE')
--
Statistics: Posted by Xinnony — 13 Jan 2014, 15:30
]]>