diff --git a/.gitignore b/.gitignore index 0b30b8aa6846e4bbaf1cf6aef5e398df0d28946f..7354fa50ee7d0504018d3ca57bcb5766c4699104 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ tests/*.txt tests/*.png massif.out* *.out +!tests/tabuleiros.out +!tests/tabuleiros2.out diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dffaf75b7a016819bc9b1d5b32cd0bc6faeb7385..07c8ec614db288b5b9ff9500622c05076c345e3c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,18 +5,134 @@ before_script: - apt-get update - apt-get -y install build-essential make autoconf gcc gnuplot - make + - mv tests/runTests.sh.example tests/runTests.sh + - chmod +x tests/runTests.sh + - chmod +x tests/verifica + - gcc -std=c99 -o tests/test tests/geraMapa.c -test: +h1: stage: test script: - - make test - cd tests + - sed -i -e 's/tams=()/tams=(4 8 16 32 64)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(3 4 6 8 10)/g' runTests.sh + - ./runTests.sh -h "./floodit_h1" - gnuplot "tempos.plot" - gnuplot "medias.plot" - gnuplot "piores.plot" artifacts: paths: - - tests/tabuleiros.txt + - tests/tabuleiros*.txt + - tests/tempos.txt + - tests/medias.txt + - tests/piores.txt + - tests/tempos.png + - tests/medias.png + - tests/piores.png + tags: + - ubuntu +h2: + stage: test + script: + - cd tests + - sed -i -e 's/tams=()/tams=(4 8 16 32 64)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(3 4 6 8 10)/g' runTests.sh + - ./runTests.sh -h "./floodit_h2" + - gnuplot "tempos.plot" + - gnuplot "medias.plot" + - gnuplot "piores.plot" + artifacts: + paths: + - tests/tabuleiros*.txt + - tests/tempos.txt + - tests/medias.txt + - tests/piores.txt + - tests/tempos.png + - tests/medias.png + - tests/piores.png + tags: + - ubuntu +h4-min: + stage: test + script: + - cd tests + - sed -i -e 's/tams=()/tams=(4 8 16 32)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(3 4 8 10)/g' runTests.sh + - ./runTests.sh -h "./floodit_h4" + - gnuplot "tempos.plot" + - gnuplot "medias.plot" + - gnuplot "piores.plot" + artifacts: + paths: + - tests/tabuleiros*.txt + - tests/tempos.txt + - tests/medias.txt + - tests/piores.txt + - tests/tempos.png + - tests/medias.png + - tests/piores.png + tags: + - ubuntu + +h4-max: + stage: test + script: + - cd tests + - sed -i -e 's/tams=()/tams=(64 100)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(10)/g' runTests.sh + - sed -i -e 's/N_TESTES=100/N_TESTES=50/g' runTests.sh + - ./runTests.sh -h "./floodit_h4" + - gnuplot "tempos.plot" + - gnuplot "medias.plot" + - gnuplot "piores.plot" + artifacts: + paths: + - tests/tabuleiros*.txt + - tests/tempos.txt + - tests/medias.txt + - tests/piores.txt + - tests/tempos.png + - tests/medias.png + - tests/piores.png + tags: + - ubuntu + +h6-min: + stage: test + script: + - cd tests + - sed -i -e 's/tams=()/tams=(4 8 16 32)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(3 4 8 10)/g' runTests.sh + - ./runTests.sh -h "./floodit_h6" + - gnuplot "tempos.plot" + - gnuplot "medias.plot" + - gnuplot "piores.plot" + artifacts: + paths: + - tests/tabuleiros*.txt + - tests/tempos.txt + - tests/medias.txt + - tests/piores.txt + - tests/tempos.png + - tests/medias.png + - tests/piores.png + tags: + - ubuntu + +h6-max: + stage: test + script: + - cd tests + - sed -i -e 's/tams=()/tams=(64 100)/g' runTests.sh + - sed -i -e 's/cores=()/cores=(10)/g' runTests.sh + - sed -i -e 's/N_TESTES=100/N_TESTES=50/g' runTests.sh + - ./runTests.sh -h "./floodit_h6" + - gnuplot "tempos.plot" + - gnuplot "medias.plot" + - gnuplot "piores.plot" + artifacts: + paths: + - tests/tabuleiros*.txt - tests/tempos.txt - tests/medias.txt - tests/piores.txt diff --git a/Makefile b/Makefile index 7c05fe51a1b74208aa4d919384a1669fa8f09a20..6871ea698bc995f0ee5841ad5703ccd2db7d3c59 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,9 @@ -CFLAGS = -std=c99 -O2 -W -Wall -g +CFLAGS = -std=c99 -O2 -W -Wall -g .PHONY: all clean all: main -test: main - cd tests; \ - $(CC) -std=c99 -o test geraMapa.c; \ - chmod +x runTests.sh; \ - ./runTests.sh - main: main.c libs/jogador.o libs/tabuleiro.o libs/grafo.o libs/vertice.o libs/filha.o libs/lista.o libs/no.o $(CC) $(CFLAGS) -o $@ $^ -lm diff --git a/libs/filha.c b/libs/filha.c index 841081d1646162662f6adda58d0c8edbf2f54ff2..29a66732fbc7e4f64db3e882729aa3e0eeb7bd45 100644 --- a/libs/filha.c +++ b/libs/filha.c @@ -26,6 +26,7 @@ No primeiroNoFilha(Filha f) { } No n = f->primeiro; f->primeiro = getSucessorNo(f->primeiro); + --f->tamanho; setSucessorNo(n, NULL); setAntecessorNo(n, NULL); return n; @@ -37,6 +38,7 @@ No ultimoNoFilha(Filha f) { } No n = f->ultimo; f->ultimo = getAntecessorNo(f->ultimo); + --f->tamanho; setSucessorNo(n, NULL); setAntecessorNo(n, NULL); return n; @@ -48,7 +50,14 @@ No insereFilha(void *conteudo, Filha f) { if(!novo) return NULL; setConteudo(novo, conteudo); + + if(f->tamanho == 0) { + f->primeiro = novo; + } + setAntecessorNo(novo, f->ultimo); + setSucessorNo(f->ultimo, novo); + ++f->tamanho; return f->ultimo = novo; } diff --git a/libs/grafo.c b/libs/grafo.c index 160a15e72592ec60f0b6cee30045a2dd6b0b9201..dd81194df53b12dd4d18ddefab71e0e5460d6013 100644 --- a/libs/grafo.c +++ b/libs/grafo.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include "grafo.h" #include "lista.h" +#include "filha.h" #include "vertice.h" #include "tabuleiro.h" #include <stdio.h> @@ -42,6 +43,9 @@ Floodfill(celula, vertice) */ void tabuleiroParaGrafo(Tblr t, Grafo g) { + g->x = t->x; + g->y = t->y; + g->cores = t->cores; //Para cada celula do tabuleiro for(int i=0; i < t->x; ++i) { for(int j=0; j < t->y; ++j) { @@ -127,6 +131,42 @@ void floodFill(Tblr t, Vertice v, int i, int j){ return; } +int calculaAltura(Grafo g, Lista raiz) { + int alturaMax = 0; + for(No n = primeiroNoLista(g->vertices); n; n = getSucessorNo(n)) { + Vertice v = (Vertice) getConteudo(n); + v->altura = -1; + } + + Filha fila = constroiFilha(); + for(No n = primeiroNoLista(raiz); n; n = getSucessorNo(n)) { + Vertice v = (Vertice) getConteudo(n); + v->altura = 0; + insereFilha(v, fila); + } + + while(tamanhoFilha(fila) > 0) { + No n = primeiroNoFilha(fila); + if(!n) { + continue; + }; + Vertice v = (Vertice) getConteudo(n); + for(No m = primeiroNoLista(v->filhos); m; m = getSucessorNo(m)) { + Vertice filho = (Vertice) getConteudo(m); + if(filho->altura == -1) { + filho->altura = v->altura+1; + if(filho->altura > alturaMax) { + alturaMax = filho->altura; + } + insereFilha(filho, fila); + } + } + free(n); + } + destroiFilha(fila, NULL); + return alturaMax; +} + void destroiGrafo(Grafo g) { destroiLista(g->vertices, destroiVertice); free(g); @@ -144,10 +184,10 @@ void grafoParaDot(Grafo g, Lista grupo, FILE* fp) { // Imprime o grafo for(No n = primeiroNoLista(g->vertices); n; n = getSucessorNo(n)) { Vertice pai = (Vertice) getConteudo(n); - fprintf(fp, "\t\"%p\" [label=\"cor=%d,peso=%d\"];\n", pai, pai->cor, pai->peso); + fprintf(fp, "\t\"%p\" [label=\"cor=%d\npeso=%d\nbonus=%d\naltura=%d\"];\n", pai, pai->cor, pai->peso, pai->bonus, pai->altura); for(No m = primeiroNoLista(pai->filhos); m; m = getSucessorNo(m)) { Vertice filho = (Vertice) getConteudo(m); - fprintf(fp, "\t\"%p\" [label=\"cor=%d,peso=%d\"];\n", filho, filho->cor, filho->peso); + fprintf(fp, "\t\"%p\" [label=\"cor=%d\npeso=%d\nbonus=%d\naltura=%d\"];\n", filho, filho->cor, filho->peso, filho->bonus, filho->altura); fprintf(fp, "\t\"%p\" -- \"%p\";\n", pai, filho); } } diff --git a/libs/grafo.h b/libs/grafo.h index ad9a4a20469a93c6ba8db563d1b51a0828aae804..189edbf4a01c8e2f636141a76793729d08a10dfd 100644 --- a/libs/grafo.h +++ b/libs/grafo.h @@ -4,6 +4,7 @@ #include <stdio.h> struct Grafo { + int x, y, cores; Lista vertices; }; @@ -19,6 +20,8 @@ void tabuleiroParaGrafo(Tblr t, Grafo g); void floodFill(Tblr t, Vertice v, int i, int j); +int calculaAltura(Grafo g, Lista raiz); + void destroiGrafo(Grafo g); void grafoParaDot(Grafo g, Lista grupo, FILE* fp); diff --git a/libs/jogador.c b/libs/jogador.c index a15b6d3e1d933cb91fbac9ff0c9378adfc6d5c31..c1c832755d04b2314f0a431fbab1275f4b20fe7d 100644 --- a/libs/jogador.c +++ b/libs/jogador.c @@ -4,32 +4,38 @@ #include "jogador.h" #include "lista.h" #include "grafo.h" +#include <math.h> Lista Joga(Grafo g, Lista grupo){ Lista jogadas = constroiLista(); - //TODO: A Logica toda do jogo vai ficar aqui int counter = 1; + double max = 2*(g->x) + (sqrt(2*g->cores))*(g->x) + g->cores; + double min = (sqrt(g->cores - 1)*g->x/2) - (g->cores/2); + if (min < 1) min = 1; + int altura = calculaAltura(g, grupo); + int naoConsumidos = tamanhoLista(g->vertices) - tamanhoLista(grupo); + double razao = (altura/sqrt(naoConsumidos)); + int profundidade = (sqrt(max) * (sqrt(altura) / sqrt(min)) * razao); + if(profundidade < 1) profundidade = 1; + while(tamanhoLista(grupo) < tamanhoLista(g->vertices)) { - // Pega os filhos do grupo + // Calcula a altura + altura = calculaAltura(g, grupo); + Lista filhos = filhosGrupo(grupo); - // Monta a árvore de busca: - // - RAIZ: grupo - // - FILHOS: Cores alcancáveis a partir da raiz - // - NETOS: Cores alcançáveis a partir dos filhos que NÃO são alcançáveis a partir da raiz - // Só é necessário para calcular o bônus de cada filho - Lista coresFilhos = agrupaCores(filhos, g); + // printf("\tJOGADA %d\n", counter); - // printf("\tTamanho coresFilhos %d\n", tamanhoLista(coresFilhos)); - // for(No n = primeiroNoLista(coresFilhos); n; n = getSucessorNo(n)) { - // Vertice v = (Vertice) getConteudo(n); - // printf("\t\tVértice - cor: %d, peso: %d, bonus: %d\n", v->cor, v->peso, v->bonus); + // printf("\t\tProfundidade: %d\n", profundidade); + Lista coresFilhos = agrupaCores(filhos); + calculaBonus(coresFilhos, g, profundidade); + + // char prestr[32]; + // sprintf(prestr, "./prejogada%d.out", counter); + // FILE* predebug = fopen(prestr, "w+"); + // if(predebug) { + // grafoParaDot(g, grupo, predebug); // } - // Seleciona o melhor filho baseado em peso(filho) + bônus(filho) // (filho com a maior soma de filho e peso) - // O bônus é calculado da seguinte forma: - // - Soma o valor de cada neto (que não é alcançável pela raiz) - // - Em caso de empate da soma peso + bônus: - // - Escolher o filho que tem mais netos da mesma cor de um filho - // Após escolher um filho, repete o algoritmo até não terem mais filhos fora do grupo + // fclose(predebug); Vertice maior = (Vertice) getConteudo(primeiroNoLista(coresFilhos)); for(No n = primeiroNoLista(coresFilhos); n; n = getSucessorNo(n)) { @@ -40,12 +46,16 @@ Lista Joga(Grafo g, Lista grupo){ } else if((v->bonus) == (maior->bonus)) { if(v->peso > maior->peso) { maior = v; + } else if(v->peso == maior->peso) { + if(v->cor < maior->cor) { + maior = v; + } } } } // printf("\t\tCOR ESCOLHIDA: %d\n", maior->cor); insereLista(maior->cor, jogadas); - // "Pinta o tablueiro" + for(No n = primeiroNoLista(filhos); n; n = getSucessorNo(n)) { Vertice v = (Vertice) getConteudo(n); if(v->cor == maior->cor && !v->grupo) { @@ -54,19 +64,19 @@ Lista Joga(Grafo g, Lista grupo){ } } - // Limpa as coisas destroiLista(filhos, NULL); destroiLista(coresFilhos, destroiVertice); + calculaAltura(g, grupo); // PARA DEBUG!! Imprime as últimas 10 jogadas em um arquivo - // char str[32]; - // sprintf(str, "./jogada%d.out", counter ); - // FILE* debug = fopen(str, "w+"); - // if(debug) { - // grafoParaDot(g, grupo, debug); - // } - // fclose(debug); - ++counter; + // char str[32]; + // sprintf(str, "./jogada%d.out", counter ); + // FILE* debug = fopen(str, "w+"); + // if(debug) { + // grafoParaDot(g, grupo, debug); + // } + // fclose(debug); + ++counter; } return jogadas; @@ -78,7 +88,7 @@ Lista filhosGrupo(Lista grupoPai) { Vertice pai = (Vertice) getConteudo(n); for(No m = primeiroNoLista(pai->filhos); m; m = getSucessorNo(m)) { Vertice filho = (Vertice) getConteudo(m); - if(!filho->grupo) { + if(!filho->grupo && filho->altura > pai->altura) { insereUnicoLista(filho, filhos); } } @@ -86,33 +96,104 @@ Lista filhosGrupo(Lista grupoPai) { return filhos; } -Lista agrupaCores(Lista filhos, Grafo g) { +Lista agrupaCores(Lista vertices) { Lista agrupa = constroiLista(); - for(No n = primeiroNoLista(filhos); n; n = getSucessorNo(n)) { + for(No n = primeiroNoLista(vertices); n; n = getSucessorNo(n)) { Vertice v = (Vertice) getConteudo(n); - // Verifica se a cor já está na lista - bool estaNaLista = false; - for(No m = primeiroNoLista(agrupa); m; m = getSucessorNo(m)) { + // Verifica se a cor já está agrupada + bool estaAgrupado = false; + for(No m = primeiroNoLista(agrupa); m && !estaAgrupado; m = getSucessorNo(m)) { Vertice w = (Vertice) getConteudo(m); // Se está, soma o peso do vértice if(w->cor == v->cor) { w->peso += v->peso; - w->bonus += calculaBonus(v, filhos); - estaNaLista = true; + insereUnicoLista(v, w->pais); + for(No o = primeiroNoLista(v->filhos); o; o = getSucessorNo(o)) { + Vertice x = (Vertice) getConteudo(o); + if(x->altura > v->altura) insereUnicoLista(x, w->filhos); + } + estaAgrupado = true; } } - // Se não está, cria um vértice para a cor - if(!estaNaLista) { + + // Se não está agrupado... + if(!estaAgrupado) { Vertice w = criaVertice(); w->cor = v->cor; w->peso = v->peso; - w->bonus = calculaBonus(v, filhos); + w->altura = v->altura; + insereUnicoLista(v, w->pais); + for(No m = primeiroNoLista(v->filhos); m; m = getSucessorNo(m)) { + Vertice x = (Vertice) getConteudo(m); + if(x->altura > v->altura) insereUnicoLista(x, w->filhos); + } insereLista(w, agrupa); } } - // Depois de agrupar, verifica se alguma cor vai chegar ao fim nesta jogada - for(No n = primeiroNoLista(agrupa); n; n = getSucessorNo(n)) { + return agrupa; +} + + +bool corEstaNaLista(Lista l, int cor) { + for(No n = primeiroNoLista(l); n; n = getSucessorNo(n)) { + Vertice v = (Vertice) getConteudo(n); + if(v->cor == cor) { + return true; + } + } + return false; +} + +void calculaBonus(Lista grupo, Grafo g, int profundidade) { + for(No n = primeiroNoLista(grupo); n; n = getSucessorNo(n)) { + Vertice v = (Vertice) getConteudo(n); + v->bonus = 0; + for(No m = primeiroNoLista(v->filhos); m; m = getSucessorNo(m)) { + Vertice filho = (Vertice) getConteudo(m); + if((filho->altura > v->altura)) { + int bonus = filho->peso + calculaBonusRec(filho, v, g, profundidade); + if(corEstaNaLista(grupo, filho->cor)) bonus += 50; + v->bonus += bonus; + } + } + Lista vFilhos = agrupaCores(v->filhos); + v->bonus += (tamanhoLista(v->filhos) - tamanhoLista(vFilhos))*2; + + 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->altura < w->altura) continue; + if(x->cor == w->cor) { + somaCor += x->peso; + } + } + if(w->peso == somaCor) { + v->bonus += 150; + } + } + destroiLista(vFilhos, destroiVertice); + + int menorDistancia = v->altura; + for(No m = primeiroNoLista(g->vertices); m; m = getSucessorNo(m)) { + Vertice w = (Vertice) getConteudo(m); + if(w->grupo) continue; + if(w == v) continue; + if(w->cor == v->cor) { + if((w->altura < menorDistancia) || (menorDistancia == v->altura)) menorDistancia = w->altura; + } + } + + for(No m = primeiroNoLista(v->pais); m; m = getSucessorNo(m)) { + Vertice pai = (Vertice) getConteudo(m); + pai->bonus = v->bonus; + } + } + + for(No n = primeiroNoLista(grupo); n; n = getSucessorNo(n)) { Vertice v = (Vertice) getConteudo(n); int somaCor = 0; for(No m = primeiroNoLista(g->vertices); m; m = getSucessorNo(m)) { @@ -121,24 +202,26 @@ Lista agrupaCores(Lista filhos, Grafo g) { somaCor += w->peso; } } - // Se a soma de todos os vértices que não pertencem ao grupo for igual - // ao peso do vértice agrupado, esta é a última jogada com aquela cor + // Se a soma de todos os vértices que não pertencem ao grupo consumido + // 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 += 350; // Mais bonus para que essa cor seja a escolhida } + } - return agrupa; + return; } -int calculaBonus(Vertice v, Lista filhos) { +int calculaBonusRec(Vertice v, Vertice pai, Grafo g, int profundidade) { + if(profundidade <= 0) return 0; int bonus = 0; for(No n = primeiroNoLista(v->filhos); n; n = getSucessorNo(n)) { - Vertice filho = getConteudo(n); - // Se o filho não está na lista filhos e não está no grupo de vértices já consumidos - if(!filho->grupo && !pertenceLista(filho, filhos)) { - bonus += filho->peso; + Vertice filho = (Vertice) getConteudo(n); + if((filho->altura > v->altura)) { + bonus += filho->peso + calculaBonusRec(filho, v, g, profundidade-1); } } - return bonus; + return v->bonus = bonus; } diff --git a/libs/jogador.h b/libs/jogador.h index 8ec4d2d2f643e1344123525df22ce4289b9627f7..272b76203ec5a533d9969b5692942f5b0344f7b9 100644 --- a/libs/jogador.h +++ b/libs/jogador.h @@ -13,7 +13,7 @@ Lista Joga(Grafo g, Lista grupo); Lista filhosGrupo(Lista grupoPai); // Retorna uma lista de vértices com as cores e pesos agrupadas a partir de l -Lista agrupaCores(Lista filhos, Grafo g); +Lista agrupaCores(Lista vertices); -int calculaBonus(Vertice v, Lista filhos); +void calculaBonus(Lista grupo, Grafo g, int profundidade); #endif diff --git a/libs/lista.c b/libs/lista.c index 9178c23940ea2789675097c236e1df9d00c7c532..4a3eebb780b331b93726dcb58a8efd76e3f7bfc4 100644 --- a/libs/lista.c +++ b/libs/lista.c @@ -20,7 +20,13 @@ unsigned int tamanhoLista(Lista l) { return l->tamanho; } // devolve o primeiro nó da Lista l, // ou NULL, se l é vazia -No primeiroNoLista(Lista l) { return l->primeiro; } +No primeiroNoLista(Lista l) { + if(!l) return NULL; + if(l->tamanho == 0) { + return NULL; + } + return l->primeiro; +} //--------------------------------------------------------------------------- // cria uma Lista vazia e a devolve diff --git a/libs/no.c b/libs/no.c index b88cfce6e0a4b6e7d03fc8691f67014756a513b4..7627f4ec3c43d61d65bec4f348b6d7df6fc4ef7e 100644 --- a/libs/no.c +++ b/libs/no.c @@ -15,18 +15,22 @@ No criaNo() { } No getSucessorNo(No n) { + if(!n) return NULL; return n->proximo; } void setSucessorNo(No n, No p) { + if(!n) return; n->proximo = p; } No getAntecessorNo(No n) { + if(!n) return NULL; return n->anterior; } void setAntecessorNo(No n, No p) { + if(!n) return; n->anterior = p; } diff --git a/libs/vertice.c b/libs/vertice.c index 35fb0e53c4f912260563da858843b7767ced071b..28dc7c06b873a4ae91a5cea49d16b01acc690449 100644 --- a/libs/vertice.c +++ b/libs/vertice.c @@ -9,7 +9,9 @@ Vertice criaVertice() { v->cor = -1; v->peso = 0; v->bonus = 0; + v->altura = -1; v->grupo = false; + v->visitado = false; v->pais = constroiLista(); v->filhos = constroiLista(); return v; diff --git a/libs/vertice.h b/libs/vertice.h index 9ee344e46b561b35965563d85fdb2fa74ccc535c..56336e98635afe9bd5632306737ab66ef14d754e 100644 --- a/libs/vertice.h +++ b/libs/vertice.h @@ -6,8 +6,10 @@ struct Vertice { int cor; int peso; - int bonus; + unsigned long int bonus; + int altura; bool grupo; + bool visitado; Lista pais; Lista filhos; }; diff --git a/main.c b/main.c index 8d59c2b9591fc38e6e2616d8fd68c092533d8286..64059a996b32095e07962f62e899695f145e5cba 100644 --- a/main.c +++ b/main.c @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) { puts("Erro na leitura do tabuleiro"); return -1; } - + // Se colocar UMA e APENAS UMA coisa depois do main if(argc == 2) { // Calcula e imprime o número mÃnimo e máximo de jogadas diff --git a/tests/floodit_h4 b/tests/floodit_h4 new file mode 100755 index 0000000000000000000000000000000000000000..3b606ce4fb8e2b333d64c7db83c6f92d9e70b106 Binary files /dev/null and b/tests/floodit_h4 differ diff --git a/tests/floodit_h6 b/tests/floodit_h6 new file mode 100755 index 0000000000000000000000000000000000000000..5c679dea1db91e3e11db8bdd54099df9f8c4dc17 Binary files /dev/null and b/tests/floodit_h6 differ diff --git a/tests/runTests.sh b/tests/runTests.sh index 4bdc639c95d3fe0ffae0cc9d022bef9b8c73e179..0e38b7a29428ecf60370fe8cb771ba0e5cbfc0fe 100755 --- a/tests/runTests.sh +++ b/tests/runTests.sh @@ -1,13 +1,32 @@ #!/bin/bash +OPTIND=1 +MAIN="../main" +HEUR="./floodit_h6" + +while getopts ":m:h:" opt; do + case "$opt" in + m) MAIN=$OPTARG + ;; + h) HEUR=$OPTARG + ;; + esac +done + +shift $((OPTIND-1)) +[ "$1" = "--" ] && shift + +echo $MAIN +echo $HEUR + # tempo máximo para executar, em milisegundos -tempo_max=10000 #10s +tempo_max=120000 #120s # tamanhos do tabuleiro -tams=(16 32 64 128) +tams=(64) # lista de cores -cores=(4 8 10 16) +cores=(10) #-- Cores do terminal RED='\033[0;31m' @@ -16,7 +35,9 @@ BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' # Sem cor -echo -ne "" > tabuleiros.txt +TABULEIROS="tabuleiros_$(basename ${HEUR}).txt" + +echo -ne "" > $TABULEIROS echo -ne "#Tam tabuleiro\t#N cores\t#Tempo médio\n" > tempos.txt echo -ne "#Tam tabuleiro\t#Tempo médio\n" > medias.txt echo -ne "#Tam tabuleiro\t#N cores\t#Tempo médio\n" > piores.txt @@ -31,19 +52,42 @@ do echo "Número de cores: ${cor}" T_soma_cor=0 T_max_cor=0 - for j in $(seq 1 $i) + N_TESTES=100 + VIT=0 + EMP=0 + DER=0 + for j in $(seq 1 ${N_TESTES}) do - echo -ne "Tabuleiro com ${i} linhas e ${cor} cores: ${i}x${j} (T max: $(($T_max_cor/1000000000))." - printf "%03d" $(($T_max_cor/1000000)) - echo -ne ")"\\r semente=$RANDOM - # echo "Usando semente: ${semente}" - ./test $i $j $cor $semente + ./test $i $i $cor $semente + T_inicial=$(date +%s%N) - ../main < "/tmp/${semente}.in" > /dev/null + + eval $MAIN < "/tmp/${semente}.in" > "/tmp/resp${semente}.out" + T_gasto=$(($(date +%s%N) - $T_inicial)) T_soma_cor=$(($T_gasto + $T_soma_cor)) T_soma_total=$(($T_gasto + $T_soma_total)) + + eval $HEUR < "/tmp/${semente}.in" > "/tmp/heur${semente}.out" + + RESP=$(cat "/tmp/resp${semente}.out" | tail -n2 | head -n1) + HRESP=$(cat "/tmp/heur${semente}.out" | tail -n2 | head -n1) + + if [ $RESP -gt $HRESP ]; then + echo "${i} ${i} ${cor} ${semente} (${HRESP})" >> ${TABULEIROS} + DER=$(($DER + 1)) + fi + if [ $RESP -eq $HRESP ]; then + EMP=$(($EMP + 1)) + fi + if [ $RESP -lt $HRESP ]; then + VALIDO=$(cat "/tmp/${semente}.in" "/tmp/resp${semente}.out" | ./verifica) + if [[ $VALIDO -eq 1 ]]; then + echo -ne "${RED}Nossa resposta para ${i} ${i} ${cor} ${semente} não é válida!!!${NC}\n\n" + fi + VIT=$(($VIT + 1)) + fi # tempo em segundos S=$(($T_gasto/1000000000)) # tempo em milisegundos @@ -52,36 +96,37 @@ do if [ $T_max_cor -lt $T_gasto ]; then T_max_cor=$T_gasto fi - if (($M>$tempo_max)); then - echo -e "\n${RED}Tabuleiro ${i} ${j} ${cor} ${semente} levou mais de ${tempo_max} milisegundos: ${S}.${M}s${NC}" - echo "${i} ${j} ${cor} ${semente}" >> tabuleiros.txt - fi + rm "/tmp/${semente}.in" + rm "/tmp/resp${semente}.out" + rm "/tmp/heur${semente}.out" + + echo -ne "Tabuleiro ${i}x${i} com ${cor} cores: (${j}/${N_TESTES}) (T max: $(($T_max_cor/1000000000))." + printf "%03d" $(($T_max_cor/1000000%1000)) + echo -ne ") (${GREEN}${VIT}${NC}/${BLUE}${EMP}${NC}/${RED}${DER}${NC})"\\r done - T_medio_cor=$(($T_soma_cor/$i)) + T_medio_cor=$(($T_soma_cor/${N_TESTES})) S_medio_cor=$(($T_medio_cor/1000000000)) M_medio_cor=$(($T_medio_cor/1000000)) echo -ne "\n${CYAN}Tempo médio com ${cor} cores: ${S_medio_cor}." - printf "%03d" ${M_medio_cor} + printf "%03d" $((${M_medio_cor}%1000)) echo -e "s (${T_medio_cor})${NC}\n" echo -e "${i}\t${cor}\t${M_medio_cor}" >> tempos.txt echo -e "${i}\t${cor}\t$(($T_max_cor/1000000))" >> piores.txt done - T_medio_total=$(( $T_soma_total/($i * ${#cores[*]}) )) + T_medio_total=$(( $T_soma_total/(${N_TESTES} * ${#cores[*]}) )) S_medio_total=$(($T_medio_total/1000000000)) M_medio_total=$(($T_medio_total/1000000)) echo -ne "${BLUE}Tempo médio com tamanho ${i}: ${S_medio_total}." - printf "%03d" ${M_medio_total} + printf "%03d" $((${M_medio_total}%1000)) echo -e "s (${T_medio_total})${NC}\n" echo -e "${i}\t${M_medio_total}" >> medias.txt done -fs=$(cat tabuleiros.txt | wc -l) +fs=$(cat "${TABULEIROS}" | wc -l) if [ ${fs} -gt "1" ]; then - echo -e "${RED}${fs} tabuleiro(s) passou(passaram) do tempo limite de ${tempo_max} milisegundos:${NC}" - cat tabuleiros.txt - exit 1 + echo -e "${RED}${fs} tabuleiro(s) perdeu(perderam) para outras heurÃsticas${NC}" + cat ${TABULEIROS} else - echo -e "${GREEN}Nenhum tabuleiro passou do tempo limite de ${tempo_max} milisegundos${NC}" - exit 0 + echo -e "${GREEN}Nenhum tabuleiro perdeu para as outras heurÃsticas${NC}" fi diff --git a/tests/runTests.sh.example b/tests/runTests.sh.example new file mode 100644 index 0000000000000000000000000000000000000000..60455b60649441e43ea9be3c21c5587c4604b2b5 --- /dev/null +++ b/tests/runTests.sh.example @@ -0,0 +1,132 @@ +#!/bin/bash + +OPTIND=1 +MAIN="../main" +HEUR="./floodit_h6" + +while getopts ":m:h:" opt; do + case "$opt" in + m) MAIN=$OPTARG + ;; + h) HEUR=$OPTARG + ;; + esac +done + +shift $((OPTIND-1)) +[ "$1" = "--" ] && shift + +echo $MAIN +echo $HEUR + +# tempo máximo para executar, em milisegundos +tempo_max=120000 #120s + +# tamanhos do tabuleiro +tams=() + +# lista de cores +cores=() + +#-- Cores do terminal +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # Sem cor + +TABULEIROS="tabuleiros_$(basename ${HEUR}).txt" + +echo -ne "" > $TABULEIROS +echo -ne "#Tam tabuleiro\t#N cores\t#Tempo médio\n" > tempos.txt +echo -ne "#Tam tabuleiro\t#Tempo médio\n" > medias.txt +echo -ne "#Tam tabuleiro\t#N cores\t#Tempo médio\n" > piores.txt + +echo "Iniciado testes" +for i in ${tams[*]} +do + echo "Tamanho do tabuleiro: ${i}" + T_soma_total=0 + for cor in ${cores[*]} + do + echo "Número de cores: ${cor}" + T_soma_cor=0 + T_max_cor=0 + N_TESTES=100 + VIT=0 + EMP=0 + DER=0 + for j in $(seq 1 ${N_TESTES}) + do + semente=$RANDOM + ./test $i $i $cor $semente + + T_inicial=$(date +%s%N) + + eval $MAIN < "/tmp/${semente}.in" > "/tmp/resp${semente}.out" + + T_gasto=$(($(date +%s%N) - $T_inicial)) + T_soma_cor=$(($T_gasto + $T_soma_cor)) + T_soma_total=$(($T_gasto + $T_soma_total)) + + eval $HEUR < "/tmp/${semente}.in" > "/tmp/heur${semente}.out" + + RESP=$(cat "/tmp/resp${semente}.out" | tail -n2 | head -n1) + HRESP=$(cat "/tmp/heur${semente}.out" | tail -n2 | head -n1) + + if [ $RESP -gt $HRESP ]; then + echo "${i} ${i} ${cor} ${semente} (${HRESP})" >> ${TABULEIROS} + DER=$(($DER + 1)) + fi + if [ $RESP -eq $HRESP ]; then + EMP=$(($EMP + 1)) + fi + if [ $RESP -lt $HRESP ]; then + VALIDO=$(cat "/tmp/${semente}.in" "/tmp/resp${semente}.out" | ./verifica) + if [[ $VALIDO -eq 1 ]]; then + echo -ne "${RED}Nossa resposta para ${i} ${i} ${cor} ${semente} não é válida!!!${NC}\n\n" + fi + VIT=$(($VIT + 1)) + fi + # tempo em segundos + S=$(($T_gasto/1000000000)) + # tempo em milisegundos + M=$(($T_gasto/1000000)) + # tempo máximo por cor + if [ $T_max_cor -lt $T_gasto ]; then + T_max_cor=$T_gasto + fi + + rm "/tmp/${semente}.in" + rm "/tmp/resp${semente}.out" + rm "/tmp/heur${semente}.out" + + echo -ne "Tabuleiro ${i}x${i} com ${cor} cores: (${j}/${N_TESTES}) (T max: $(($T_max_cor/1000000000))." + printf "%03d" $(($T_max_cor/1000000%1000)) + echo -ne ") (${GREEN}${VIT}${NC}/${BLUE}${EMP}${NC}/${RED}${DER}${NC})"\\r + done + T_medio_cor=$(($T_soma_cor/${N_TESTES})) + S_medio_cor=$(($T_medio_cor/1000000000)) + M_medio_cor=$(($T_medio_cor/1000000)) + echo -ne "\n${CYAN}Tempo médio com ${cor} cores: ${S_medio_cor}." + printf "%03d" $((${M_medio_cor}%1000)) + echo -e "s (${T_medio_cor})${NC}\n" + echo -e "${i}\t${cor}\t${M_medio_cor}" >> tempos.txt + echo -e "${i}\t${cor}\t$(($T_max_cor/1000000))" >> piores.txt + done + T_medio_total=$(( $T_soma_total/(${N_TESTES} * ${#cores[*]}) )) + S_medio_total=$(($T_medio_total/1000000000)) + M_medio_total=$(($T_medio_total/1000000)) + echo -ne "${BLUE}Tempo médio com tamanho ${i}: ${S_medio_total}." + printf "%03d" $((${M_medio_total}%1000)) + echo -e "s (${T_medio_total})${NC}\n" + echo -e "${i}\t${M_medio_total}" >> medias.txt +done + +fs=$(cat "${TABULEIROS}" | wc -l) +if [ ${fs} -gt "1" ]; then + echo -e "${RED}${fs} tabuleiro(s) perdeu(perderam) para outras heurÃsticas${NC}" + cat ${TABULEIROS} +else + echo -e "${GREEN}Nenhum tabuleiro perdeu para as outras heurÃsticas${NC}" +fi diff --git a/tests/tabuleiros.out b/tests/tabuleiros.out new file mode 100644 index 0000000000000000000000000000000000000000..8bc4f3389d9229ee6e187d2cd439f6cc4188d8a3 --- /dev/null +++ b/tests/tabuleiros.out @@ -0,0 +1,322 @@ +3 3 8 26909 (h1: 5) +3 3 8 26909 (h2: 5) +4 4 10 14295 (h2: 8) +4 4 10 15795 (h1: 10) +4 4 10 15795 (h2: 10) +4 4 10 20490 (h1: 10) +4 4 10 20490 (h2: 10) +4 4 10 29581 (h1: 9) +4 4 10 4049 (h1: 8) +4 4 10 4049 (h2: 8) +4 4 16 1235 (h1: 10) +4 4 4 13848 (h2: 6) +4 4 4 17004 (h1: 6) +4 4 4 23024 (h1: 6) +4 4 4 25453 (h2: 5) +4 4 4 2597 (h1: 6) +4 4 4 27649 (h1: 7) +4 4 4 27649 (h2: 7) +4 4 4 6629 (h1: 6) +4 4 4 6629 (h1: 6) +4 4 8 20898 (h1: 8) +4 4 8 22414 (h2: 8) +4 4 8 27865 (h1: 8) +4 4 8 6846 (h1: 8) +4 4 8 6846 (h2: 8) +4 4 8 934 (h1: 8) +4 4 8 934 (h2: 8) +4 4 8 9699 (h1: 9) +4 4 8 9699 (h2: 9) +8 8 10 19467 (h1: 21) +8 8 10 28993 (h2: 19) +8 8 10 7105 (h2: 20) +8 8 4 11513 (h2: 7) +8 8 4 12332 (h2: 9) +8 8 4 12593 (h2: 9) +8 8 4 13507 (h1: 9) +8 8 4 13507 (h2: 9) +8 8 4 15307 (h2: 8) +8 8 4 15554 (h2: 11) +8 8 4 15903 (h2: 8) +8 8 4 17156 (h1: 9) +8 8 4 17203 (h2: 8) +8 8 4 17614 (h1: 10) +8 8 4 17614 (h2: 10) +8 8 4 19677 (h1: 7) +8 8 4 20183 (h2: 10) +8 8 4 21208 (h2: 8) +8 8 4 21352 (h1: 10) +8 8 4 21352 (h2: 10) +8 8 4 21946 (h1: 11) +8 8 4 21946 (h2: 11) +8 8 4 22652 (h1: 10) +8 8 4 22791 (h2: 9) +8 8 4 22893 (h2: 9) +8 8 4 25309 (h2: 7) +8 8 4 26112 (h2: 10) +8 8 4 30518 (h2: 8) +8 8 4 3970 (h1: 12) +8 8 4 496 (h2: 9) +8 8 4 5020 (h1: 8) +8 8 4 5427 (h1: 9) +8 8 4 5427 (h2: 9) +8 8 4 74 (h2: 9) +8 8 4 8073 (h1: 10) +8 8 4 853 (h1: 8) +8 8 4 9982 (h2: 9) +8 8 8 1111 (h2: 19) +8 8 8 11191 (h2: 17) +8 8 8 15190 (h1: 15) +8 8 8 15820 (h2: 17) +8 8 8 20926 (h2: 13) +8 8 8 5956 (h2: 15) +8 8 8 8458 (h2: 17) +16 16 4 12080 (h2: 15) +16 16 4 17382 (h2: 18) +16 16 4 19519 (h2: 18) +16 16 4 20629 (h2: 14) +16 16 4 22277 (h2: 17) +16 16 4 23645 (h2: 16) +16 16 4 24852 (h2: 16) +16 16 4 28245 (h2: 17) +16 16 4 3916 (h2: 18) +16 16 4 5514 (h2: 16) +16 16 8 1142 (h2: 29) +16 16 8 18339 (h2: 34) +16 16 8 7218 (h2: 35) +32 32 4 6052 (h2: 30) +3 3 4 20010 (h1: 4) +3 3 4 20010 (h2: 4) +3 3 4 5987 (h1: 5) +3 3 4 5987 (h2: 5) +3 3 8 20411 (h1: 4) +4 4 10 13182 (h1: 8) +4 4 10 15113 (h1: 8) +4 4 10 15113 (h2: 8) +4 4 10 17622 (h1: 9) +4 4 10 17622 (h2: 9) +4 4 10 26074 (h1: 9) +4 4 10 26074 (h2: 9) +4 4 10 29580 (h1: 10) +4 4 10 29580 (h2: 10) +4 4 10 30396 (h1: 9) +4 4 10 30396 (h2: 9) +4 4 10 4203 (h1: 10) +4 4 10 4203 (h2: 10) +4 4 16 4021 (h1: 10) +4 4 16 4021 (h2: 10) +4 4 4 12924 (h1: 5) +4 4 4 19886 (h2: 5) +4 4 4 25409 (h1: 5) +4 4 4 25409 (h2: 5) +4 4 4 25453 (h2: 5) +4 4 4 27649 (h1: 7) +4 4 4 27649 (h2: 7) +4 4 4 4016 (h1: 6) +4 4 4 4016 (h2: 6) +4 4 4 8294 (h2: 5) +4 4 4 8672 (h1: 5) +4 4 4 8672 (h2: 5) +4 4 8 22013 (h1: 9) +4 4 8 7793 (h1: 8) +4 4 8 7793 (h2: 8) +8 8 10 15701 (h1: 20) +8 8 10 19677 (h2: 18) +8 8 10 21121 (h2: 20) +8 8 10 25173 (h2: 18) +8 8 10 25636 (h2: 19) +8 8 10 28473 (h2: 20) +8 8 10 31628 (h2: 18) +8 8 10 5599 (h2: 17) +8 8 16 14392 (h2: 24) +8 8 16 25031 (h2: 24) +8 8 16 2700 (h2: 23) +8 8 16 27020 (h2: 23) +8 8 4 10041 (h1: 10) +8 8 4 1093 (h1: 9) +8 8 4 11071 (h2: 10) +8 8 4 11355 (h1: 10) +8 8 4 11355 (h2: 10) +8 8 4 12332 (h2: 9) +8 8 4 12400 (h1: 10) +8 8 4 13881 (h2: 9) +8 8 4 13936 (h2: 8) +8 8 4 15605 (h1: 9) +8 8 4 15605 (h2: 9) +8 8 4 16964 (h1: 9) +8 8 4 20245 (h1: 7) +8 8 4 20245 (h2: 7) +8 8 4 2025 (h1: 9) +8 8 4 2025 (h2: 9) +8 8 4 21823 (h2: 10) +8 8 4 21975 (h2: 7) +8 8 4 22199 (h1: 8) +8 8 4 22199 (h2: 8) +8 8 4 22366 (h1: 9) +8 8 4 23926 (h1: 7) +8 8 4 24376 (h2: 8) +8 8 4 26014 (h2: 8) +8 8 4 2639 (h1: 10) +8 8 4 26762 (h2: 8) +8 8 4 28291 (h2: 9) +8 8 4 30577 (h2: 11) +8 8 4 30613 (h2: 9) +8 8 4 30711 (h2: 10) +8 8 4 3085 (h2: 10) +8 8 4 31339 (h1: 8) +8 8 4 31339 (h2: 8) +8 8 4 3320 (h2: 10) +8 8 4 3559 (h2: 10) +8 8 4 4900 (h2: 8) +8 8 4 4986 (h1: 8) +8 8 4 4986 (h1: 8) +8 8 4 5030 (h2: 8) +8 8 4 5949 (h2: 8) +8 8 4 5988 (h1: 10) +8 8 4 6183 (h1: 10) +8 8 4 829 (h2: 8) +8 8 4 8665 (h1: 10) +8 8 8 14824 (h2: 15) +8 8 8 1489 (h2: 16) +8 8 8 15610 (h2: 14) +8 8 8 20262 (h2: 19) +8 8 8 23461 (h1: 17) +8 8 8 23461 (h2: 17) +8 8 8 28248 (h1: 16) +8 8 8 29853 (h1: 17) +8 8 8 31307 (h2: 15) +8 8 8 31586 (h2: 15) +8 8 8 6033 (h2: 16) +8 8 8 632 (h2: 17) +16 16 4 1199 (h2: 17) +16 16 4 12747 (h2: 19) +16 16 4 16762 (h2: 16) +16 16 4 17784 (h2: 18) +16 16 4 20739 (h2: 16) +16 16 4 25688 (h2: 18) +16 16 4 29043 (h2: 17) +16 16 4 3595 (h2: 19) +16 16 4 4552 (h2: 20) +16 16 4 8715 (h2: 17) +16 16 8 2925 (h2: 29) +3 3 4 30001 (h1: 4) +3 3 4 30001 (h2: 4) +3 3 8 12831 (h1: 5) +3 3 8 12831 (h2: 5) +3 3 8 12891 (h1: 4) +3 3 8 7096 (h1: 5) +3 3 8 7096 (h2: 5) +4 4 10 11135 (h1: 7) +4 4 10 11135 (h2: 7) +4 4 10 11196 (h1: 9) +4 4 10 11196 (h2: 9) +4 4 10 18982 (h1: 10) +4 4 10 18982 (h2: 10) +4 4 10 21895 (h1: 8) +4 4 10 26585 (h1: 10) +4 4 10 26585 (h2: 10) +4 4 10 27139 (h1: 8) +4 4 10 27139 (h2: 8) +4 4 10 27793 (h2: 9) +4 4 16 15048 (h1: 10) +4 4 16 15048 (h2: 10) +4 4 16 21518 (h1: 10) +4 4 16 21518 (h2: 10) +4 4 16 27610 (h1: 10) +4 4 16 27610 (h2: 10) +4 4 4 1089 (h2: 6) +4 4 4 1293 (h2: 5) +4 4 4 19021 (h1: 6) +4 4 4 22962 (h1: 5) +4 4 4 27765 (h1: 5) +4 4 4 2845 (h1: 6) +4 4 4 2845 (h2: 6) +4 4 4 5744 (h1: 5) +4 4 4 5744 (h2: 5) +4 4 4 7524 (h1: 5) +4 4 8 1420 (h1: 9) +4 4 8 1420 (h2: 9) +4 4 8 16874 (h2: 7) +4 4 8 25928 (h1: 7) +4 4 8 25928 (h2: 7) +4 4 8 3722 (h1: 9) +4 4 8 3722 (h2: 9) +4 4 8 8603 (h1: 9) +4 4 8 8603 (h2: 9) +8 8 10 10192 (h2: 18) +8 8 10 17877 (h1: 20) +8 8 10 23653 (h2: 20) +8 8 10 23660 (h1: 19) +8 8 10 23660 (h2: 19) +8 8 10 27684 (h2: 22) +8 8 10 5660 (h2: 18) +8 8 16 15390 (h2: 22) +8 8 16 18644 (h2: 24) +8 8 4 1044 (h2: 9) +8 8 4 11514 (h2: 10) +8 8 4 1276 (h2: 10) +8 8 4 12898 (h1: 10) +8 8 4 12898 (h2: 10) +8 8 4 1488 (h1: 9) +8 8 4 15559 (h1: 10) +8 8 4 15559 (h2: 10) +8 8 4 16082 (h2: 10) +8 8 4 17637 (h2: 9) +8 8 4 20457 (h2: 8) +8 8 4 21566 (h2: 11) +8 8 4 22549 (h2: 10) +8 8 4 25045 (h2: 9) +8 8 4 27315 (h2: 10) +8 8 4 27654 (h1: 10) +8 8 4 27654 (h2: 10) +8 8 4 27719 (h1: 8) +8 8 4 27719 (h2: 8) +8 8 4 27919 (h1: 11) +8 8 4 27919 (h2: 11) +8 8 4 28078 (h2: 10) +8 8 4 28536 (h1: 7) +8 8 4 28567 (h2: 8) +8 8 4 29660 (h2: 8) +8 8 4 30049 (h2: 8) +8 8 4 30239 (h1: 9) +8 8 4 31396 (h2: 10) +8 8 4 3259 (h1: 11) +8 8 4 3259 (h2: 10) +8 8 4 3360 (h1: 10) +8 8 4 3360 (h2: 10) +8 8 4 3612 (h2: 10) +8 8 4 7576 (h2: 11) +8 8 4 914 (h2: 8) +8 8 8 10087 (h1: 17) +8 8 8 10087 (h2: 17) +8 8 8 16149 (h2: 18) +8 8 8 18904 (h2: 18) +8 8 8 19447 (h2: 16) +8 8 8 22319 (h2: 18) +8 8 8 23399 (h2: 15) +8 8 8 25477 (h2: 16) +8 8 8 26199 (h2: 16) +8 8 8 26728 (h2: 16) +8 8 8 28639 (h2: 16) +8 8 8 29967 (h2: 18) +8 8 8 5152 (h2: 16) +8 8 8 6808 (h2: 19) +8 8 8 8012 (h1: 16) +8 8 8 8375 (h2: 17) +16 16 4 14252 (h2: 16) +16 16 4 14293 (h2: 17) +16 16 4 15621 (h1: 17) +16 16 4 15621 (h2: 16) +16 16 4 16716 (h2: 15) +16 16 4 17018 (h2: 17) +16 16 4 18172 (h2: 15) +16 16 4 20105 (h2: 16) +16 16 4 22607 (h2: 16) +16 16 4 25922 (h2: 18) +16 16 4 26202 (h2: 16) +16 16 4 27227 (h2: 17) +16 16 4 28222 (h2: 16) +16 16 4 31677 (h2: 17) +16 16 4 32428 (h2: 16) +16 16 4 5418 (h2: 17) +32 32 4 5482 (h2: 34) diff --git a/tests/tabuleiros2.out b/tests/tabuleiros2.out new file mode 100644 index 0000000000000000000000000000000000000000..a55a5156c7fe0c177af2f95998a060d6966657eb --- /dev/null +++ b/tests/tabuleiros2.out @@ -0,0 +1,342 @@ +3 3 10 22600 (h1: 5) +3 3 10 22600 (h2: 5) +3 3 16 19040 (h1: 6) +3 3 16 19040 (h2: 6) +3 3 16 30956 (h1: 5) +3 3 16 30956 (h2: 5) +3 3 4 1930 (h1: 4) +3 3 4 20600 (h1: 4) +3 3 4 8366 (h1: 5) +3 3 4 8366 (h2: 5) +3 3 8 18977 (h1: 5) +3 3 8 18977 (h2: 5) +3 3 8 8012 (h1: 5) +3 3 8 8012 (h2: 5) +4 4 10 11135 (h1: 7) +4 4 10 11135 (h2: 7) +4 4 10 14928 (h1: 9) +4 4 10 14928 (h2: 9) +4 4 10 18375 (h2: 8) +4 4 10 2070 (h1: 9) +4 4 10 23470 (h2: 9) +4 4 10 24772 (h2: 7) +4 4 10 6283 (h2: 9) +4 4 10 8479 (h2: 8) +4 4 16 12402 (h2: 9) +4 4 16 18295 (h1: 9) +4 4 16 18295 (h2: 9) +4 4 16 20112 (h1: 9) +4 4 16 21473 (h2: 10) +4 4 16 4696 (h2: 7) +4 4 16 9419 (h2: 10) +4 4 4 11579 (h1: 6) +4 4 4 11579 (h2: 6) +4 4 4 13320 (h1: 6) +4 4 4 14064 (h1: 5) +4 4 4 14064 (h2: 5) +4 4 4 1611 (h1: 4) +4 4 4 1611 (h2: 4) +4 4 4 17232 (h1: 6) +4 4 4 17232 (h2: 6) +4 4 4 25522 (h1: 5) +4 4 4 25522 (h2: 5) +4 4 4 25820 (h2: 5) +4 4 4 26508 (h2: 5) +4 4 4 2835 (h1: 7) +4 4 4 2835 (h2: 7) +4 4 4 9524 (h1: 6) +4 4 4 9639 (h1: 5) +4 4 4 9639 (h2: 5) +4 4 8 10019 (h1: 7) +4 4 8 10019 (h1: 7) +4 4 8 10019 (h2: 7) +4 4 8 10019 (h2: 7) +4 4 8 12901 (h1: 9) +4 4 8 12901 (h2: 9) +4 4 8 17301 (h1: 9) +4 4 8 17301 (h2: 9) +4 4 8 17998 (h2: 10) +4 4 8 19156 (h1: 8) +4 4 8 19156 (h2: 8) +4 4 8 20112 (h1: 8) +4 4 8 21593 (h1: 9) +4 4 8 22108 (h2: 9) +4 4 8 22780 (h2: 8) +4 4 8 23041 (h1: 8) +4 4 8 23041 (h2: 8) +4 4 8 24658 (h1: 8) +4 4 8 26632 (h1: 8) +4 4 8 28676 (h1: 7) +4 4 8 28676 (h2: 7) +4 4 8 2955 (h1: 9) +4 4 8 31369 (h1: 9) +4 4 8 4677 (h1: 9) +4 4 8 4677 (h2: 9) +4 4 8 4927 (h2: 7) +4 4 8 5649 (h1: 7) +4 4 8 5649 (h2: 7) +4 4 8 7834 (h1: 7) +4 4 8 7834 (h2: 7) +8 8 10 10366 (h1: 17) +8 8 10 10366 (h2: 16) +8 8 10 13138 (h1: 19) +8 8 10 13439 (h2: 17) +8 8 10 13765 (h1: 21) +8 8 10 13992 (h2: 18) +8 8 10 14350 (h1: 19) +8 8 10 15850 (h2: 18) +8 8 10 16457 (h2: 19) +8 8 10 19856 (h2: 19) +8 8 10 20352 (h2: 22) +8 8 10 20571 (h2: 18) +8 8 10 22262 (h2: 18) +8 8 10 22774 (h2: 20) +8 8 10 24320 (h1: 19) +8 8 10 24633 (h1: 20) +8 8 10 27756 (h2: 20) +8 8 10 30292 (h1: 20) +8 8 10 3083 (h2: 18) +8 8 10 3113 (h1: 21) +8 8 10 3358 (h1: 21) +8 8 10 3358 (h2: 21) +8 8 10 3821 (h1: 18) +8 8 10 5659 (h1: 20) +8 8 10 5659 (h2: 19) +8 8 10 5674 (h1: 18) +8 8 16 14476 (h2: 22) +8 8 16 21413 (h1: 26) +8 8 16 22007 (h1: 28) +8 8 16 22007 (h2: 28) +8 8 16 24721 (h1: 28) +8 8 16 24721 (h2: 28) +8 8 16 25688 (h2: 24) +8 8 16 32360 (h2: 26) +8 8 16 4205 (h1: 24) +8 8 16 5987 (h2: 25) +8 8 16 721 (h2: 27) +8 8 16 8509 (h2: 24) +8 8 16 8998 (h2: 24) +8 8 4 11036 (h2: 8) +8 8 4 11154 (h2: 10) +8 8 4 12695 (h2: 9) +8 8 4 137 (h1: 10) +8 8 4 137 (h2: 10) +8 8 4 15454 (h1: 8) +8 8 4 16065 (h1: 9) +8 8 4 16721 (h2: 9) +8 8 4 17457 (h2: 10) +8 8 4 18390 (h2: 10) +8 8 4 18416 (h2: 9) +8 8 4 19768 (h2: 10) +8 8 4 20348 (h2: 10) +8 8 4 22393 (h1: 10) +8 8 4 23132 (h2: 10) +8 8 4 23741 (h1: 9) +8 8 4 24629 (h2: 8) +8 8 4 25573 (h1: 6) +8 8 4 2594 (h2: 10) +8 8 4 27070 (h2: 9) +8 8 4 27841 (h1: 9) +8 8 4 30356 (h2: 10) +8 8 4 3432 (h2: 9) +8 8 4 3813 (h2: 9) +8 8 4 4010 (h2: 9) +8 8 4 4243 (h2: 7) +8 8 4 5895 (h2: 10) +8 8 4 7902 (h1: 9) +8 8 4 7902 (h2: 9) +8 8 4 8800 (h2: 9) +8 8 4 9400 (h2: 11) +8 8 8 10174 (h1: 16) +8 8 8 1081 (h2: 16) +8 8 8 12147 (h2: 16) +8 8 8 14142 (h2: 15) +8 8 8 15843 (h2: 19) +8 8 8 15926 (h2: 16) +8 8 8 17466 (h1: 19) +8 8 8 17466 (h2: 17) +8 8 8 18847 (h1: 16) +8 8 8 18847 (h2: 16) +8 8 8 21161 (h2: 18) +8 8 8 22073 (h1: 19) +8 8 8 22137 (h1: 16) +8 8 8 22539 (h2: 18) +8 8 8 22587 (h1: 17) +8 8 8 25730 (h2: 17) +8 8 8 27212 (h2: 18) +8 8 8 27763 (h2: 15) +8 8 8 28275 (h1: 17) +8 8 8 30297 (h2: 15) +8 8 8 30606 (h2: 17) +8 8 8 4983 (h1: 18) +8 8 8 4983 (h2: 18) +8 8 8 5201 (h2: 16) +8 8 8 5384 (h2: 17) +8 8 8 7086 (h1: 18) +8 8 8 9756 (h1: 15) +16 16 10 32616 (h2: 42) +16 16 10 6780 (h2: 39) +16 16 4 13965 (h1: 15) +16 16 4 14363 (h2: 15) +16 16 4 14531 (h2: 15) +16 16 4 14836 (h2: 20) +16 16 4 17640 (h2: 21) +16 16 4 18264 (h1: 18) +16 16 4 29199 (h2: 15) +16 16 4 3692 (h2: 15) +16 16 4 4421 (h1: 17) +16 16 4 8795 (h2: 16) +16 16 4 9696 (h2: 17) +32 32 4 11862 (h2: 31) +32 32 4 19445 (h2: 31) +32 32 4 24151 (h2: 36) +32 32 4 26052 (h2: 34) +32 32 4 27565 (h1: 34) +3 3 4 18761 (h1: 5) +3 3 4 18761 (h2: 5) +3 3 4 24397 (h1: 4) +3 3 4 24397 (h2: 4) +3 3 4 6764 (h1: 4) +3 3 4 6764 (h2: 4) +3 3 8 27050 (h2: 5) +4 4 10 12057 (h1: 9) +4 4 10 12057 (h2: 9) +4 4 10 13522 (h1: 9) +4 4 10 13522 (h2: 9) +4 4 10 26187 (h1: 8) +4 4 10 460 (h1: 10) +4 4 10 460 (h2: 10) +4 4 4 14247 (h1: 6) +4 4 4 14247 (h2: 6) +4 4 4 15919 (h1: 5) +4 4 4 15919 (h2: 5) +4 4 4 17320 (h1: 6) +4 4 4 17320 (h2: 6) +4 4 4 19855 (h2: 5) +4 4 4 21364 (h1: 6) +4 4 4 21364 (h2: 6) +4 4 4 22172 (h1: 7) +4 4 4 22172 (h2: 7) +4 4 4 23024 (h1: 6) +4 4 4 23973 (h1: 5) +4 4 4 23973 (h2: 5) +4 4 4 25004 (h1: 6) +4 4 4 26671 (h1: 6) +4 4 4 26671 (h2: 6) +4 4 4 30115 (h1: 5) +4 4 4 30160 (h1: 7) +4 4 4 30160 (h2: 7) +4 4 4 31044 (h1: 6) +4 4 4 31044 (h2: 6) +4 4 4 31751 (h1: 5) +4 4 4 4124 (h1: 5) +4 4 4 8414 (h1: 6) +4 4 4 8414 (h2: 6) +4 4 4 9605 (h1: 6) +4 4 4 9605 (h2: 6) +4 4 4 972 (h1: 7) +4 4 4 972 (h2: 7) +4 4 8 10442 (h2: 7) +4 4 8 18768 (h2: 9) +4 4 8 22889 (h2: 9) +4 4 8 25600 (h1: 7) +4 4 8 25600 (h2: 7) +4 4 8 28631 (h1: 9) +4 4 8 28631 (h2: 9) +4 4 8 29725 (h1: 8) +4 4 8 29725 (h2: 8) +4 4 8 3201 (h1: 7) +4 4 8 3201 (h2: 7) +4 4 8 5994 (h1: 8) +4 4 8 5994 (h2: 8) +4 4 8 9291 (h1: 9) +4 4 8 9291 (h2: 9) +8 8 10 19855 (h1: 23) +8 8 10 21834 (h2: 17) +8 8 10 21859 (h2: 17) +8 8 10 22691 (h2: 18) +8 8 10 25784 (h2: 20) +8 8 10 30669 (h2: 17) +8 8 10 32652 (h2: 18) +8 8 10 5426 (h2: 20) +8 8 10 5972 (h2: 20) +8 8 4 10155 (h1: 11) +8 8 4 10155 (h2: 11) +8 8 4 1051 (h2: 10) +8 8 4 11565 (h2: 9) +8 8 4 11880 (h1: 9) +8 8 4 11880 (h2: 9) +8 8 4 13820 (h2: 10) +8 8 4 14100 (h2: 9) +8 8 4 14528 (h2: 10) +8 8 4 15967 (h2: 10) +8 8 4 16122 (h2: 8) +8 8 4 16129 (h1: 11) +8 8 4 16129 (h2: 11) +8 8 4 17637 (h2: 9) +8 8 4 18285 (h2: 8) +8 8 4 18490 (h2: 11) +8 8 4 19159 (h2: 9) +8 8 4 19465 (h1: 11) +8 8 4 19465 (h2: 11) +8 8 4 20298 (h2: 8) +8 8 4 20542 (h1: 8) +8 8 4 20542 (h2: 8) +8 8 4 22039 (h2: 11) +8 8 4 22714 (h2: 9) +8 8 4 22778 (h2: 9) +8 8 4 23635 (h2: 9) +8 8 4 24537 (h2: 10) +8 8 4 2516 (h1: 9) +8 8 4 25421 (h2: 12) +8 8 4 26162 (h2: 11) +8 8 4 28920 (h2: 9) +8 8 4 29070 (h2: 9) +8 8 4 3038 (h1: 8) +8 8 4 3038 (h2: 8) +8 8 4 32082 (h2: 10) +8 8 4 32295 (h1: 9) +8 8 4 32295 (h2: 9) +8 8 4 6072 (h2: 11) +8 8 4 6546 (h2: 12) +8 8 4 7653 (h1: 8) +8 8 4 7674 (h2: 10) +8 8 4 8593 (h2: 12) +8 8 4 8713 (h1: 9) +8 8 4 8713 (h2: 9) +8 8 4 9963 (h2: 11) +8 8 8 16365 (h2: 17) +8 8 8 17006 (h2: 17) +8 8 8 17072 (h2: 17) +8 8 8 20290 (h2: 17) +8 8 8 21573 (h2: 15) +8 8 8 25051 (h2: 17) +8 8 8 25544 (h1: 18) +8 8 8 30072 (h1: 17) +8 8 8 30977 (h2: 17) +8 8 8 5008 (h2: 15) +8 8 8 6761 (h2: 16) +16 16 4 1308 (h2: 17) +16 16 4 14758 (h2: 17) +16 16 4 16610 (h2: 16) +16 16 4 19109 (h2: 20) +16 16 4 22066 (h2: 17) +16 16 4 26835 (h2: 18) +16 16 4 28186 (h2: 14) +16 16 4 32029 (h2: 15) +16 16 4 3351 (h1: 19) +16 16 4 3351 (h2: 18) +16 16 4 4113 (h2: 16) +16 16 4 4581 (h1: 18) +16 16 4 5002 (h2: 18) +16 16 4 6765 (h2: 18) +16 16 4 9558 (h2: 18) +16 16 8 18547 (h2: 32) +32 32 4 1200 (h2: 28) +32 32 4 14382 (h2: 32) +32 32 4 16897 (h2: 32) +32 32 4 17065 (h2: 28) +32 32 4 21166 (h2: 34) +32 32 4 29283 (h2: 33) +32 32 4 30020 (h2: 28) +32 32 4 3836 (h2: 35) diff --git a/tests/verifica b/tests/verifica new file mode 100755 index 0000000000000000000000000000000000000000..2e7509c77c7151258a56cf66fccd53a4b67ce349 Binary files /dev/null and b/tests/verifica differ