From 692f14a1d48abf0cf0ab34ca2719479847e1c852 Mon Sep 17 00:00:00 2001 From: Vytor Calixto <vytorcalixto@gmail.com> Date: Thu, 8 Jun 2017 11:33:59 -0300 Subject: [PATCH] =?UTF-8?q?Melhorando=20fun=C3=A7=C3=A3o=20que=20d=C3=A1?= =?UTF-8?q?=20b=C3=B4nus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/jogador.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/libs/jogador.c b/libs/jogador.c index d7880cf..ee8d15d 100644 --- a/libs/jogador.c +++ b/libs/jogador.c @@ -151,7 +151,23 @@ void calculaBonus(Lista grupo, Grafo g, int profundidade) { } } Lista vFilhos = agrupaCores(v->filhos); - v->bonus += tamanhoLista(v->filhos) - tamanhoLista(vFilhos); + v->bonus += (tamanhoLista(v->filhos) - tamanhoLista(vFilhos))*2; + // TODO: Se os filhos do grupo vão acabar na próxima jogada, dar bonus + // tabuleiro 3 3 4 1930 + for(No m = primeiroNoLista(vFilhos); m; m = getSucessorNo(m)) { + Vertice w = (Vertice) getConteudo(m); + int somaCor = 0; + for(No o = primeiroNoLista(g->vertices); o; o = getSucessorNo(o)) { + Vertice x = (Vertice) getConteudo(o); + if(x->grupo) continue; + if(x->cor == w->cor) { + somaCor += x->peso; + } + } + if(w->peso == somaCor) { + w->bonus += 150; + } + } destroiLista(vFilhos, NULL); int menorDistancia = v->altura; @@ -184,8 +200,9 @@ void calculaBonus(Lista grupo, Grafo g, int profundidade) { // for igual ao peso do vértice agrupado, esta é a // última jogada com aquela cor if(v->peso == somaCor) { - v->bonus += 100; // Mais bonus para que essa cor seja a escolhida + v->bonus += 250; // Mais bonus para que essa cor seja a escolhida } + } return; @@ -198,21 +215,6 @@ int calculaBonusRec(Vertice v, Vertice pai, Grafo g, int profundidade) { Vertice filho = (Vertice) getConteudo(n); if((filho->altura > v->altura)) { int preBonus = filho->peso + calculaBonusRec(filho, v, g, profundidade-1); - // for(No m = primeiroNoLista(g->vertices); m && (profundidade < 10); m = getSucessorNo(m)) { - // Vertice w = (Vertice) getConteudo(m); - // if(w == pai) continue; - // if(!w->grupo) { - // // Se existe alguém um nÃvel acima da mesma cor... - // if((w->altura == (filho->altura - 1)) && (w->cor == filho->cor)) { - // // preBonus += 25; - // } - // // // Se existe alguém dois nÃves acima com a mesma cor - // // else if((w->altura == (filho->altura - 2)) && (w->cor == filho->cor)) { - // // preBonus += 15; - // // } - // } - // } - bonus += preBonus; } } -- GitLab