-
-
Save parzibyte/a6f7c721f4bff2f957d917d633a5078e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int contarArriba(int x, int y, string jugador, string[,] tablero) | |
{ | |
int yInicio = (y - CONECTA >= 0) ? y - CONECTA + 1 : 0; | |
int contador = 0; | |
for (; yInicio <= y; yInicio++) | |
{ | |
if (tablero[yInicio, x] == jugador) | |
{ | |
contador++; | |
} | |
else | |
{ | |
contador = 0; | |
} | |
} | |
return contador; | |
} | |
static int contarDerecha(int x, int y, string jugador, string[,] tablero) | |
{ | |
int xFin = (x + CONECTA < COLUMNAS) ? x + CONECTA - 1 : COLUMNAS - 1; | |
int contador = 0; | |
for (; x <= xFin; x++) | |
{ | |
if (tablero[y, x] == jugador) | |
{ | |
contador++; | |
} | |
else | |
{ | |
contador = 0; | |
} | |
} | |
return contador; | |
} | |
static int contarArribaDerecha(int x, int y, string jugador, string[,] tablero) | |
{ | |
int xFin = (x + CONECTA < COLUMNAS) ? x + CONECTA - 1 : COLUMNAS - 1; | |
int yInicio = (y - CONECTA >= 0) ? y - CONECTA + 1 : 0; | |
int contador = 0; | |
while (x <= xFin && yInicio <= y) | |
{ | |
if (tablero[y, x] == jugador) | |
{ | |
contador++; | |
} | |
else | |
{ | |
contador = 0; | |
} | |
x++; | |
y--; | |
} | |
return contador; | |
} | |
static int contarAbajoDerecha(int x, int y, string jugador, string[,] tablero) | |
{ | |
int xFin = (x + CONECTA < COLUMNAS) ? x + CONECTA - 1 : COLUMNAS - 1; | |
int yFin = (y + CONECTA < FILAS) ? y + CONECTA - 1 : FILAS - 1; | |
int contador = 0; | |
while (x <= xFin && y <= yFin) | |
{ | |
if (tablero[y, x] == jugador) | |
{ | |
contador++; | |
} | |
else | |
{ | |
contador = 0; | |
} | |
x++; | |
y++; | |
} | |
return contador; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment