public Match FindMatch(Color col) { Match CurrentWinner = new Match(); CurrentWinner.NewMatch(new Colour("",Color.Black,0,0,true,""),int.MaxValue); for (int i = 0; i < Colours.Count; ++i) { int dif = Colours[i].Difference(col); if (dif < CurrentWinner.BestDif && Colours[i].Enabled) { CurrentWinner.NewMatch(Colours[i], dif); } } return CurrentWinner; }
public void UpdateColor(Colour col, Dictionary<Color, Match> FoundMatches) { Color BestMatch = col.Color; Match BestColour = new Match(); int lowest = int.MaxValue; for(int i = 0; i < FoundMatches.Keys.Count;++i) { if (FoundMatches.Values.ElementAt(i).BestMatch == col) { if (FoundMatches.Values.ElementAt(i).BestDif < lowest) { BestMatch = FoundMatches.Keys.ElementAt(i); BestColour = FoundMatches.Values.ElementAt(i); lowest = FoundMatches.Values.ElementAt(i).BestDif; } } } for (int i = 0; i < FoundMatches.Keys.Count; ++i) { if (FoundMatches.Values.ElementAt(i).BestMatch== col) { if (FoundMatches.Keys.ElementAt(i) != BestMatch && FoundMatches.Values.ElementAt(i).SecondDif < BestColour.SecondDif) { FoundMatches.Values.ElementAt(i).SwapMatches(); } } } }
public void AbsorbMatch(Match other) { SecondBest = other.SecondBest; SecondDif = other.SecondDif; BestMatch = other.BestMatch; BestDif = other.BestDif; }