Skip to content
Snippets Groups Projects
Commit 906c4423 authored by Luiza Wille's avatar Luiza Wille
Browse files

added explanations for old and new heuristic on test 5


Signed-off-by: default avatarLuiza Wille <lmwc14@inf.ufpr.br>
parent 9d89da4f
No related branches found
No related tags found
No related merge requests found
Pipeline #
File added
This is the REPO referring to our Artifitial Intelligence project: This is the REPO referring to our Artifitial Intelligence project:
* Given the Professor's base code, we will write our own Player code. Given the Professor's base code, we will write our own Player code.
* The Player will take in a Flood-It game board, and based on it, The Player will take in a Flood-It game board, and based on it,
* the Player will try to find (under 10 minutes) the best possible the Player will try to find (under 10 minutes) the best possible
set of color choices to win the game and return it. set of color choices to win the game and then return the sequence found.
First, compile the code by typing: First, compile the code by typing:
* `make` $ make
Second, run the code with the information about the x and y axis and the number of colours Second, run the code with the information about the x and y axis and the number of colours
* `./main < FILE.TXT` $ ./main < FILE.TXT
And the FILE.TXT should have the following model (all the itens should be integers): And the FILE.TXT should have the following model (all the itens should be integers):
```
[xaxis] [yaxis] [colors] [xaxis] [yaxis] [colors]
[posision 1,1] ............... [posision 1,1] ...............
.............................. ..............................
................[position xaxis, yaxis] ................[position xaxis, yaxis]
```
/----------ABOUT THE TESTS --------------/ /----------ABOUT THE TESTS --------------/
We've tested the efficiency of our algorithm with the professors implementation to genrate boards. We've tested the efficiency of our algorithm with the professors implementation to generate boards.
Those tests can be found inside the file "customTests".
And it is possible to check if our sequence is actually correct by typing ./exemploProfessor X Y Z W
Where X Y Z W correspond to the numbers found below next to each test.
Used as input to the professor's implementation were the sequences: Used as input to the professor's implementation were the sequences:
...@@ -61,6 +65,34 @@ Our code gave the sequence: ...@@ -61,6 +65,34 @@ Our code gave the sequence:
``` ```
It is a correct sequence. It is a correct sequence.
**Test 5- 50 50 6 2**
First heuristic, our code gave the correct sequence:
```
80
2 1 3 4 2 6 5 2 1 3 5 4 1 3 2 4 5 2 5 4 2 3 5 1 2 6 4 1 6 3 2 5 4 6 1 2 6 4 2 5 6 2 4 1 2 3 6 4 1 3 5 2 6 3 1 2 3 5 4 2 1 5 6 4 1 5 3 5 4 1 6 2 3 4 5 1 2 6 3 4
```
Second heuristic, our code gave the sequence:
```
88
2 1 3 6 2 4 1 2 4 5 4 6 1 4 3 2 1 4 5 3 6 2 5 4 6 2 5 3 1 4 6 3 2 4 5 1 3 6 4 2 5 1 6 4 2 1 3 6 4 2 5 1 3 2 6 4 1 3 5 4 2 6 3 5 1 4 6 2 5 3 1 4 5 6 2 1 4 3 2 1 5 6 4 3 5 2 1 6
```
**Test 6- 100 100 6 2**
First heuristic: our code gave the sequence(not tested):
```
172
5 2 1 5 3 2 4 1 4 2 3 1 4 5 3 6 4 1 2 4 6 2 5 1 3 6 4 5 6 1 4 3 2 5 6 4 2 1 3 6 5 3 4 2 1 5 3 4 2 1 5 4 6 1 3 5 2 4 1 6 2 4 5 3 4 2 3 5 4 1 2 6 5 3 1 4 5 2 1 4 3 6 5 2 4 1 3 2 4 6 2 1 3 5 6 4 3 1 5 6 4 2 1 3 5 2 6 4 1 3 2 4 5 1 3 6 4 5 1 3 6 2 5 1 4 6 3 1 2 6 5 3 2 4 1 5 6 4 3 6 1 3 6 5 4 1 6 5 3 2 6 5 2 1 3 1 6 3 4 2 3 1 6 5 2 3 6 4 1 5 3 2
```
Second heuristic, our code gave the sequence:
```
186
5 2 1 5 3 2 4 1 4 2 3 1 4 5 6 4 1 2 3 6 4 2 5 1 3 6 2 4 5 1 3 4 6 5 2 4 1 3 6 2 5 1 3 4 2 6 1 5 4 3 2 5 6 1 4 3 2 5 6 1 4 3 2 5 4 1 6 2 5 3 1 4 2 6 5 3 1 2 4 6 3 5 4 1 2 6 5 3 2 4 1 5 6 3 2 4 5 1 3 6 2 4 1 5 6 2 3 1 4 2 5 6 1 3 4 5 6 2 1 4 5 3 6 1 4 2 3 5 6 1 2 4 3 1 6 5 2 4 1 3 2 5 6 4 1 3 6 5 2 4 1 3 6 5 4 2 6 1 5 4 3 6 2 1 3 5 1 4 2 3 1 5 3 4 6 2 5 3 1 6 4 2 1 3 5 6
```
**Test 7- 5 5 4 3** **Test 7- 5 5 4 3**
Our code gave the sequence: Our code gave the sequence:
...@@ -82,22 +114,3 @@ It is a correct sequence, but the minimum sequence is: ...@@ -82,22 +114,3 @@ It is a correct sequence, but the minimum sequence is:
19 19
4 1 4 5 2 1 5 1 2 4 6 2 3 6 3 2 4 5 1 4 1 4 5 2 1 5 1 2 4 6 2 3 6 3 2 4 5 1
``` ```
**--------------- NOT ANALYSED yet --------------**
**Test 5- 50 50 6 2**
Our code gave the sequence:
```
80
2 1 3 4 2 6 5 2 1 3 5 4 1 3 2 4 5 2 5 4 2 3 5 1 2 6 4 1 6 3 2 5 4 6 1 2 6 4 2 5 6 2 4 1 2 3 6 4 1 3 5 2 6 3 1 2 3 5 4 2 1 5 6 4 1 5 3 5 4 1 6 2 3 4 5 1 2 6 3 4
```
**Test 6- 100 100 6 2**
Our code gave the sequence:
```
172
5 2 1 5 3 2 4 1 4 2 3 1 4 5 3 6 4 1 2 4 6 2 5 1 3 6 4 5 6 1 4 3 2 5 6 4 2 1 3 6 5 3 4 2 1 5 3 4 2 1 5 4 6 1 3 5 2 4 1 6 2 4 5 3 4 2 3 5 4 1 2 6 5 3 1 4 5 2 1 4 3 6 5 2 4 1 3 2 4 6 2 1 3 5 6 4 3 1 5 6 4 2 1 3 5 2 6 4 1 3 2 4 5 1 3 6 4 5 1 3 6 2 5 1 4 6 3 1 2 6 5 3 2 4 1 5 6 4 3 6 1 3 6 5 4 1 6 5 3 2 6 5 2 1 3 1 6 3 4 2 3 1 6 5 2 3 6 4 1 5 3 2
```
2 2 3
1 2
3 1
2 2 1
2 2
2 2
#!/bin/bash
# tempo máximo para executar, em milisegundos
tempo_max=10000 #10s
# tamanhos do tabuleiro
tams=(4)
# lista de cores
cores=(2)
#-- Cores do terminal
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # Sem cor
echo -ne "" > tabuleiros.txt
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
for j in $(seq 1 $i)
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
T_inicial=$(date +%s%N)
../main < "/tmp/${semente}.in" > /dev/null
T_gasto=$(($(date +%s%N) - $T_inicial))
T_soma_cor=$(($T_gasto + $T_soma_cor))
T_soma_total=$(($T_gasto + $T_soma_total))
# 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
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"
done
T_medio_cor=$(($T_soma_cor/$i))
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}
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[*]}) ))
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}
echo -e "s (${T_medio_total})${NC}\n"
echo -e "${i}\t${M_medio_total}" >> medias.txt
done
fs=$(cat tabuleiros.txt | 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
else
echo -e "${GREEN}Nenhum tabuleiro passou do tempo limite de ${tempo_max} milisegundos${NC}"
exit 0
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment