Example #1
0
    int Max(GameObject[][] tab, int alpha, int beta, int poda)
    {
        if (poda == MAX_ITE)
        {
            return(dificuldade == 1 ? UtilityFacil(tab) : UtilityDificil(tab));
        }

        int v = int.MinValue;

        for (int i = 0; i < tab.Length; i++)
        {
            for (int j = 0; j < tab[i].Length; j++)
            {
                if (tab[i][j] && tab[i][j].name.StartsWith(this.cor))
                {
                    List <Vector2> jogadasPossiveis = br.MovimentosPossiveis(tab, tab[i][j], new Vector2(i, j), true);
                    foreach (Vector2 jogada in jogadasPossiveis)
                    {
                        GameObject[][] tabCopy = br.copiar(tab);
                        tabCopy = br.AtualizaPosicoes(tabCopy, new Vector2(i, j), jogada, false);
                        // br.AtualizaPosicoesRelativas(tabCopy, tab[i][j], jogada);
                        int vLinha = Min(tabCopy, alpha, beta, poda + 1);
                        if (poda == 0 && vLinha == v)
                        {
                            this.jogadas.Add(jogada);
                            this.quem.Add(tab[i][j]);
                        }
                        if (vLinha > v)
                        {
                            v = vLinha;
                            if (poda == 0)
                            {
                                this.jogadas.Clear();
                                this.quem.Clear();
                                this.jogadas.Add(jogada);
                                this.quem.Add(tab[i][j]);
                            }
                        }
                        // if(vLinha >= beta){
                        //  return v;
                        // }
                        // if(vLinha>alpha){
                        //  alpha = vLinha;
                        // }
                    }
                }
            }
        }
        return(v);
    }
Example #2
0
    //função que faz o posicionamento dos movimentos possíveis
    public void makeTiles(GameObject peca)
    {
        movimentos = br.MovimentosPossiveis(peca);
        GameObject temp;

        foreach (Vector2 v in movimentos)
        {
            pos = findInList(int.Parse(v.x + ""), int.Parse(v.y + ""));
            //instancia o objeto tile na posição certa da cena
            temp = Instantiate(greenTile, tiles[pos].transform.position, tiles[pos].transform.localRotation);
            //ajusta o nome para ser a posição em que o objeto foi colocado na matriz
            temp.name = v.x + "," + v.y;
            auxList.Add(temp);
        }
    }