private void Init(Tuple <double[, ], string[], string> playerA, Tuple <double[, ], string[], string> playerB) { var pAlst = ConvertToList(playerA.Item1); var pBlst = ConvertToList(playerB.Item1); var payoffScores = pAlst.Zip(pBlst, (i1, i2) => i1.Zip(i2, (n, v) => new Tuple <double, double>(n, v))) .ToList(); var playerALabels = playerA.Item2; var playerBLabels = playerB.Item2; PlayerAChoices = playerALabels; PlayerBChoices = playerBLabels; var names = new Tuple <string, string>(playerA.Item3, playerB.Item3); for (var i = 0; i < payoffScores.Count; i++) { var row = payoffScores[i].ToList(); for (var j = 0; j < row.Count; j++) { var label = new Tuple <string, string>(playerALabels[i], playerBLabels[j]); var score = row[j]; var item = new PayoffMatrixItem(label, score, names); _items.Add(item); } } }
internal PayoffMatrixItem GetMyChoice(bool isPlayerA, string[] myChoices, string yourChoice) { var iChoose = new PayoffMatrixItem(); foreach (var myChoice in myChoices) { var playerAChoice = isPlayerA ? myChoice : yourChoice; var playerBChoice = isPlayerA ? yourChoice : myChoice; var match = _items.FirstOrDefault(i => i.Equals(new Tuple <string, string>(playerAChoice, playerBChoice))); if (match == null) { continue; } var thisScore = isPlayerA ? match.Scores.Item1 : match.Scores.Item2; var myScore = isPlayerA ? iChoose.Scores.Item1 : iChoose.Scores.Item2; if (thisScore > myScore) { iChoose = match; } } return(iChoose); }