Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Enchente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vytor Calixto
Enchente
Commits
0afea0d7
There was a problem fetching the pipeline summary.
Commit
0afea0d7
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add função para calcular bonus
parent
f7348d36
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/jogador.c
+18
-4
18 additions, 4 deletions
libs/jogador.c
libs/jogador.h
+2
-2
2 additions, 2 deletions
libs/jogador.h
with
20 additions
and
6 deletions
libs/jogador.c
+
18
−
4
View file @
0afea0d7
...
...
@@ -30,9 +30,9 @@ Lista Joga(Grafo g, Lista grupo){
return
jogadas
;
}
Lista
filhosGrupo
(
Lista
l
)
{
Lista
filhosGrupo
(
Lista
grupoPai
)
{
Lista
filhos
=
constroiLista
();
for
(
No
n
=
primeiroNoLista
(
l
);
n
;
n
=
getSucessorNo
(
n
))
{
for
(
No
n
=
primeiroNoLista
(
grupoPai
);
n
;
n
=
getSucessorNo
(
n
))
{
Vertice
pai
=
(
Vertice
)
getConteudo
(
n
);
for
(
No
m
=
primeiroNoLista
(
pai
->
filhos
);
m
;
m
=
getSucessorNo
(
m
))
{
Vertice
filho
=
(
Vertice
)
getConteudo
(
m
);
...
...
@@ -42,9 +42,21 @@ Lista filhosGrupo(Lista l) {
return
filhos
;
}
Lista
agrupaCores
(
Lista
l
)
{
int
calculaBonus
(
Vertice
v
,
Lista
filhos
)
{
int
bonus
=
0
;
for
(
No
n
=
primeiroNoLista
(
v
->
filhos
);
n
;
n
=
getSucessorNo
(
n
))
{
Vertice
filho
=
getConteudo
(
n
);
// Se o filho não está na lsita filhos e não está no grupo de vértices já consumidos
if
(
!
pertenceLista
(
filho
,
filhos
)
&&
!
filho
->
grupo
)
{
bonus
+=
filho
->
peso
;
}
}
return
bonus
;
}
Lista
agrupaCores
(
Lista
filhos
)
{
Lista
agrupa
=
constroiLista
();
for
(
No
n
=
primeiroNoLista
(
l
);
n
;
n
=
getSucessorNo
(
n
))
{
for
(
No
n
=
primeiroNoLista
(
filhos
);
n
;
n
=
getSucessorNo
(
n
))
{
Vertice
v
=
(
Vertice
)
getConteudo
(
n
);
// Verifica se a cor já está na lista
bool
estaNaLista
=
false
;
...
...
@@ -53,6 +65,7 @@ Lista agrupaCores(Lista l) {
// Se está, soma o peso do vértice
if
(
w
->
cor
==
v
->
cor
)
{
w
->
peso
+=
v
->
peso
;
w
->
bonus
+=
calculaBonus
(
v
,
filhos
);
estaNaLista
=
true
;
}
}
...
...
@@ -61,6 +74,7 @@ Lista agrupaCores(Lista l) {
Vertice
w
=
criaVertice
();
w
->
cor
=
v
->
cor
;
w
->
peso
=
v
->
peso
;
w
->
bonus
=
calculaBonus
(
v
,
filhos
);
insereLista
(
w
,
agrupa
);
}
}
...
...
This diff is collapsed.
Click to expand it.
libs/jogador.h
+
2
−
2
View file @
0afea0d7
...
...
@@ -10,8 +10,8 @@
Lista
Joga
(
Grafo
g
,
Lista
grupo
);
// Retorna todos os filhos de uma lista de vértices
Lista
filhosGrupo
(
Lista
l
);
Lista
filhosGrupo
(
Lista
grupoPai
);
// Retorna uma lista de vértices com as cores e pesos agrupadas a partir de l
Lista
agrupaCores
(
Lista
l
);
Lista
agrupaCores
(
Lista
filhos
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment