Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function WhoWon($pole) {
- $pionowo = array(0, 0, 0);
- foreach ($pole as $i) {
- $poziomo = 0;
- for ($j = 0; $j < 3; $j++) {
- $poziomo += $i[$j];
- $pionowo[$j] += $i[$j];
- }
- if ($poziomo == 3) return 1;
- else if ($poziomo == -3) return -1;
- }
- for ($i = 0; $i < 3; $i++) {
- if ($pionowo[$i] == 3) return 1;
- else if ($pionowo[$i] == -3) return -1;
- }
- $skosprawo = $pole[0][0] + $pole[1][1] + $pole[2][2];
- if ($skosprawo == 3) return 1;
- else if ($skosprawo == -3) return -1;
- $skoslewo = $pole[0][2] + $pole[1][1] + $pole[2][0];
- if ($skoslewo == 3) return 1;
- else if ($skoslewo == -3) return -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement