private async void DelPlayerButton_Click(object sender, EventArgs e)
{
// You can not delete a player if there are only two of them left
if (N < 3)
{
MessageBox.Show("Nah, come on, there are only two players and you want to delete one of 'em? Shame...");
return;
}
graphBox.Image = null;
await PutTaskDelayShort();
Random rand = new Random();
int playerId = rand.Next(N);
int edgeNrTmp = edgeNr;
int neighborNr = ncManager.NeighborCounter(N, playerId, checkMatrix);
edgeNrTmp -= neighborNr;
Tuple<int[,], int[,]> t = ncManager.DelPlayerGenGraph(edgeNrTmp, N, edgeNr, playerId, graph, checkMatrix);
int[,] tmpGraph = t.Item1;
int[,] tmpCheckMatrix = t.Item2;
int minusi = 0, minusj = 0;
for (int i = 0; i < N; i++)
{
minusj = 0;
if (i != playerId)
{
for (int j = 0; j < N; j++)
{
if (j != playerId)
{
tmpCheckMatrix[i - minusi, j - minusj] = checkMatrix[i, j];
}
else
{
minusj = 1;
}
}
}
else
{
minusi = 1;
}
}
N--;
NoPTB.Text = N + "";
checkMatrix = new int[N, N];
checkMatrix = tmpCheckMatrix;
graph = new int[edgeNrTmp, 2];
graph = tmpGraph;
edgeNr = edgeNrTmp;
if (colors[playerId] == 1)
{
nrDefTB.Text = (int.Parse(nrDefTB.Text) - 1) + "";
}
else
{
NrCoopTB.Text = (int.Parse(nrDefTB.Text) - 1) + "";
}
colors = ncManager.DelGenColors(N, playerId, colors);
selflesness = ncManager.DelGenSelflessness(N, playerId, selflesness);
DrawGraph();
}