private IEnumerator calcularMovimiento(int posX, int posY, bool jugador) { DatoPos datoJugador = caballoEnjuego.GetComponent <DatoPos>(); Vector2 movimiento = iaScript.AlgoritmoMinimax((int[, ])representacion.Clone(), manzanasIA, manzanasJugador, posX, posY, (int)datoJugador.PosX, (int)datoJugador.PosY, profundidadIA); StartCoroutine(moverCaballo((int)movimiento.x, (int)movimiento.y, jugador)); yield return(null); }
void createObject(int tipo) { bool escrito = false; int posX; int posY; while (!escrito) { posX = Random.Range(0, 6); posY = Random.Range(0, 6); if (representacion[posX, posY] == VACIO) { escrito = true; GameObject elemento = new GameObject(); Vector3 pos = new Vector3(posX, 0.1f, posY); switch (tipo) { case MANZANA: GameObject man = Instantiate(manazana, pos, transform.rotation) as GameObject; ManzanaDatoPos datoPosManzana = man.GetComponent <ManzanaDatoPos>(); datoPosManzana.PosX = posX; datoPosManzana.PosY = posY; manzanas.Add(man); break; case CABALLOIA: caballoEnJuegoIA = Instantiate(CaballoIA, pos, transform.rotation) as GameObject; DatoPos datoPosIA = caballoEnJuegoIA.GetComponent <DatoPos>(); datoPosIA.PosX = posX; datoPosIA.PosY = posY; break; case CABALLOJUGADOR: caballoEnjuego = Instantiate(CaballoJugador, pos + Vector3.up * 2, transform.rotation) as GameObject; DatoPos datoPos = caballoEnjuego.GetComponent <DatoPos>(); datoPos.PosX = posX; datoPos.PosY = posY; break; } representacion[posX, posY] = tipo; } } }
public void movimientoIA() { DatoPos datos = caballoEnJuegoIA.GetComponent <DatoPos>(); hacerJugada(datos.PosX, datos.PosY, false); }