Th69 Danke für die Schnelle Antwort.
Also Punkt 1 hast Recht ich weis nur nciht wie ich beides zurückgeben kann z.B so:
playerA,playerB = FindFour(ref playerA,ref playerB,field);
und in der Methode:
return playerA,playerB;
nur geht das leider nicht und einzeln funktioniert es auch nicht da es bei return sofort aus der Methode aussteigt.
Punkt 2 :
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| private static bool FindFour(ref bool playerA,ref bool playerB, int[,] field) { for (int rows = 0; rows < field.GetLength(0); rows++) { int sumR = 0; for (int col = 0; col < field.GetLength(1)|| col < col+4; col++) { sumR += field[rows, col]; if (sumR == 4) playerA = true; else if (sumR == -4) playerB = true; } } |
So müsste jetzt passen da leere Felder mit 0 ,PlayerA mit -1 und PlayerB mit 1 intialisiert ist.