Skip to content

Commit

Permalink
Increased options
Browse files Browse the repository at this point in the history
+Quick discovery (lower quality but faster search)
+Allow excluded (acts as low priority)
+Max champions with 3 traits limiter (reduces bias)
+Spatula tab (can be sued to specify headliner)
+Faster search algorithm (n choose x)
+Printed comps now also include their synergy score
  • Loading branch information
dragitz committed Feb 15, 2024
1 parent d03e8f6 commit 33822a1
Show file tree
Hide file tree
Showing 8 changed files with 584 additions and 241 deletions.
6 changes: 5 additions & 1 deletion TFT Comp Creator 2/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.1" newVersion="7.0.0.1" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
493 changes: 325 additions & 168 deletions TFT Comp Creator 2/Form1.Designer.cs

Large diffs are not rendered by default.

41 changes: 37 additions & 4 deletions TFT Comp Creator 2/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,30 @@ public Form1()
include_trait,
exclude_champion,
default_champion,
include_champion
include_champion,
default_spatula,
include_spatula
);

// Setup part 2
Master = FirstRun();

SetFromScoring(Master, no_error, max_cost_5_amount, max_cost_4_amount, max_cost_3_amount, max_cost_2_amount, max_cost_1_amount, minTraits, minUpgrades, minRanged, maxRanged);
SetFromScoring(
Master,
no_error,
exclusion_allow_base_trait,
max_cost_5_amount,
max_cost_4_amount,
max_cost_3_amount,
max_cost_2_amount,
max_cost_1_amount,
minTraits,
minUpgrades,
minRanged,
maxRanged,
trait_3_limiter,
include_spatula
);

SetNodes(
Master,
Expand Down Expand Up @@ -169,7 +186,7 @@ public void CreateButton_Click(object sender, EventArgs e)

public void Creation()
{

// Empty comp
List<string> comp = new List<string>();

Expand Down Expand Up @@ -215,6 +232,9 @@ public void Creation()
// Include champions from list of default traits as extra nodes
foreach (string champion in GetChampionsFromTrait(default_trait.Items[k].ToString()))
{
if (quick_discovery.Checked)
break;

if (!nodes.Contains(champion) && !comp.Contains(champion))
nodes.Add(champion);
}
Expand Down Expand Up @@ -245,6 +265,9 @@ public void Creation()
//FindCombinations(nodes, size, hashmap, comp);
FindCombinations2(size, nodes);

if (quick_discovery.Checked)
break;

}
Print("done");

Expand All @@ -265,7 +288,7 @@ public void Creation()




// Traits
private void Trait_default_to_exclude_Click(object sender, EventArgs e)
{
moveData(default_trait.SelectedItem, default_trait, exclude_trait);
Expand All @@ -282,6 +305,7 @@ private void Trait_include_to_default_Click(object sender, EventArgs e)
{
moveData(include_trait.SelectedItem, include_trait, default_trait);
}
// Champions
private void Champion_default_to_exclude_Click(object sender, EventArgs e)
{
moveData(default_champion.SelectedItem, default_champion, exclude_champion);
Expand All @@ -298,7 +322,16 @@ private void Champion_include_to_default_Click(object sender, EventArgs e)
{
moveData(include_champion.SelectedItem, include_champion, default_champion);
}
// Spatula
private void spatula_default_to_include_Click(object sender, EventArgs e)
{
moveData(default_spatula.SelectedItem, default_spatula, include_spatula);
}

private void spatula_include_to_default_Click(object sender, EventArgs e)
{
moveData(include_spatula.SelectedItem, include_spatula, default_spatula);
}
private void ClearButton_Click(object sender, EventArgs e)
{
output.Text = "";
Expand Down
148 changes: 124 additions & 24 deletions TFT Comp Creator 2/Scoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Scoring
{
public static dynamic Master = new JObject();
private static CheckBox no_error = new CheckBox();
private static CheckBox exclusion_allow_base_trait = new CheckBox();
private static NumericUpDown max_cost_5_amount = new NumericUpDown();
private static NumericUpDown max_cost_4_amount = new NumericUpDown();
private static NumericUpDown max_cost_3_amount = new NumericUpDown();
Expand All @@ -20,12 +21,30 @@ public class Scoring
private static NumericUpDown minUpgrades = new NumericUpDown();
private static NumericUpDown minRanged = new NumericUpDown();
private static NumericUpDown maxRanged = new NumericUpDown();
private static NumericUpDown trait_3_limiter = new NumericUpDown();

public static ListBox include_spatula = new ListBox();

public static bool ForceStop = false;
public static void SetFromScoring(dynamic M, CheckBox NO, NumericUpDown max_cost_5_amount_, NumericUpDown max_cost_4_amount_, NumericUpDown max_cost_3_amount_, NumericUpDown max_cost_2_amount_, NumericUpDown max_cost_1_amount_, NumericUpDown minActiveTRaits_, NumericUpDown minUpgrades_, NumericUpDown minRanged_, NumericUpDown maxRanged_)
public static void SetFromScoring(
dynamic M,
CheckBox NO,
CheckBox exclusion_allow_base_trait_,
NumericUpDown max_cost_5_amount_,
NumericUpDown max_cost_4_amount_,
NumericUpDown max_cost_3_amount_,
NumericUpDown max_cost_2_amount_,
NumericUpDown max_cost_1_amount_,
NumericUpDown minActiveTRaits_,
NumericUpDown minUpgrades_,
NumericUpDown minRanged_,
NumericUpDown maxRanged_,
NumericUpDown trait_3_limiter_,
ListBox include_spatula_)
{
Master = M;
no_error = NO;
exclusion_allow_base_trait = exclusion_allow_base_trait_;
max_cost_5_amount = max_cost_5_amount_;
max_cost_4_amount = max_cost_4_amount_;
max_cost_3_amount = max_cost_3_amount_;
Expand All @@ -35,6 +54,10 @@ public static void SetFromScoring(dynamic M, CheckBox NO, NumericUpDown max_cost
minUpgrades = minUpgrades_;
minRanged = minRanged_;
maxRanged = maxRanged_;
trait_3_limiter = trait_3_limiter_;

include_spatula = include_spatula_;

}

/// <summary>
Expand All @@ -58,6 +81,8 @@ public static int CalculateSynergy(List<string> comp)
// Access the property of the checkbox here.
bool isChecked = no_error.Checked;

JObject JTraits = new JObject();

try
{
// Create and populate championsData
Expand All @@ -83,7 +108,7 @@ public static int CalculateSynergy(List<string> comp)

foreach (var champ in comp)
{

var traits = championsData[champ];

// Loop through each trait and calculate its contribution to the synergy score
Expand All @@ -94,6 +119,16 @@ public static int CalculateSynergy(List<string> comp)

}

// Spatula traits / Headliners
foreach (var champTraits in championsData.Values)
{
// Increase synergy score if the trait is present in the List<string> comp
synergyScore += champTraits.Count(trait => include_spatula.Items.Contains(trait));
}





// Return the total synergy score
return synergyScore;
Expand Down Expand Up @@ -239,7 +274,7 @@ public static int GetScore(List<string> comp, int debug)

if (debug == 3)
{
PrintComp(comp);
PrintComp(comp, 9999);

return ActiveTraits + InactiveTraits;
}
Expand Down Expand Up @@ -470,8 +505,57 @@ public static bool CheckCompValidity(List<string> comp)
JTraits[CurrentTrait] = (int)JTraits[CurrentTrait] + 1;
}
}


}


int found = 0;
int mustFind = include_spatula.Items.Count;

// Spatula traits can be added here (to be coded)
for (int k = 0; k < include_spatula.Items.Count; k++)
{
string spatulaTrait = include_spatula.Items[k].ToString();


bool foundChamp = false;

foreach (var champion in comp)
{
dynamic Traits = Master["Champions"][champion]["Traits"];


foreach (string Trait in Traits)
{
if (Traits.Contains(spatulaTrait))
break;

foundChamp = true;
found++;
break;
}
if (foundChamp) { break; }
}

if (!foundChamp) { return false; }


if (TraitsInComp.Contains(spatulaTrait))
{
JTraits[spatulaTrait] = (int)JTraits[spatulaTrait] + 1;
}
else
{
TraitsInComp.Add(spatulaTrait);
JProperty item_properties = new JProperty(spatulaTrait, 0);
JTraits.Add(item_properties);
}
}
if (found < mustFind && mustFind > 0) { return false; }



// Ensure n amount of ranged
if (rangedAmount < Convert.ToInt32(minRanged.Value) || rangedAmount > Convert.ToInt32(maxRanged.Value)) { return false; }

Expand Down Expand Up @@ -502,19 +586,44 @@ public static bool CheckCompValidity(List<string> comp)
List<string> IncludedTraitFoundLIst = new List<string>();

int TotalUpgrades = 0;
int[] UpgradeLevels = { };

// Iterate through all
foreach (string Trait in TraitsInComp)
{
// Included / Excluded traits check

// Check if trait appears in the excluded list, as well as the included list
if (!exclusion_allow_base_trait.Checked)
{
if (exclude_trait.Items.Contains(Trait))
return false;
//for (int i = 0; i < exclude_trait.Items.Count; i++)
//{
// if (Trait == exclude_trait.Items[i].ToString())
// return false;
//}
}

for (int i = 0; i < include_trait.Items.Count; i++)
{
if (Trait == include_trait.Items[i].ToString() && !IncludedTraitFoundLIst.Contains(Trait))
IncludedTraitFoundLIst.Add(Trait);
}

int minBreakPoint = (int)Master["TraitList"][Trait]["Breakpoints"][0];
int totalBreakPoints = Master["TraitList"][Trait]["Breakpoints"].Count;

if (exclusion_allow_base_trait.Checked && (int)JTraits[Trait] > minBreakPoint && exclude_trait.Items.Contains(Trait) && totalBreakPoints > 1)
{
return false;
}

// Make sure the trait is active
// Trait must not be unique per champion (eg. a 5 cost that has its own trait does not count as having more active traits), aka more than 1 BP
if ((int)JTraits[Trait] >= minBreakPoint && totalBreakPoints > 1)
{
int maxBreakpoint = (int)Master["TraitList"][Trait]["Breakpoints"][Master["TraitList"][Trait]["Breakpoints"].Count - 1]; // This is a test, might leave it here

ActiveTraits++;

JTraits_active.Add(Trait);
Expand All @@ -525,45 +634,27 @@ public static bool CheckCompValidity(List<string> comp)
bool isBalanced = false;
for (int i = 0; i < BreakpointAmount; i++)
{
if ((int)Master["TraitList"][Trait]["Breakpoints"][i] == (int)JTraits[Trait])
if ((int)Master["TraitList"][Trait]["Breakpoints"][i] == (int)JTraits[Trait] || (int)Master["TraitList"][Trait]["Breakpoints"][i] > maxBreakpoint)
{

isBalanced = true;

if (BreakpointAmount > 1 && i > 0)
{
TotalUpgrades += i;
UpgradeLevels.Append(i);


}

}
}


if (!isBalanced && no_error.Checked) { return false; }

// Included / Excluded traits check

// Check if trait appears in the excluded list, as well as the included list
for (int i = 0; i < exclude_trait.Items.Count; i++)
{
if (Trait == exclude_trait.Items[i].ToString())
return false;
}

for (int i = 0; i < include_trait.Items.Count; i++)
{
if (Trait == include_trait.Items[i].ToString() && !IncludedTraitFoundLIst.Contains(Trait))
IncludedTraitFoundLIst.Add(Trait);
}

}
}



int championsWith_3_traits_or_more = 0;
// Ensure all champions have contributed to the active trait list at least once
foreach (string champion in comp)
{
Expand All @@ -576,6 +667,15 @@ public static bool CheckCompValidity(List<string> comp)
if (JTraits_active.Contains(Trait)) { has_contributed = true; break; };
}
if (!has_contributed) { return false; }


int NumberOfTraits = Master["Champions"][champion]["Traits"].Count;

if (NumberOfTraits >= 3)
championsWith_3_traits_or_more++;

if (championsWith_3_traits_or_more > Convert.ToInt32(trait_3_limiter.Value))
return false;
}


Expand Down
Loading

0 comments on commit 33822a1

Please sign in to comment.