Closed GoogleCodeExporter closed 9 years ago
From Canis:
I ran into the same exact problem. You need to apply multiple modifiers to by
card
group. So for a quick idea...
int values[]
double modifiers[]
int bestValue
int bestGroup
for each card in hand
values[card.group] += card.value
if values[card.group] > bestValue
bestValue = values[card.group]
bestGroup = card.group
end if
end for each
for each modifier in modifiers
-modifier = 1
end for each
for g1 = 0, g1 < values.length
for g2 = 0, g2 < values.length
if g1 != g2 && g2 != bestGroup
modifiers[g2] *= Group.getModifier(g1, g2)
end if
end for
end for
int value = 0;
for i = 0, i < values.length
value += (values[i] * modifiers[i])
end for
That is the basic idea. You can make your genetic smarter by giving each card a
team
and only have cards that are on the same team on the same hand. This makes
finiding
the modifier easy as if the two groups are the same then the modifier is 1, if
they
are different then the modifier is .5. Since the 0 and -.5 modifiers are part
of the
other team those get ignored since a hand has a specific team. It should
greatly
speed up your genetic by ignoring cards that dont work well together and should
make
calculating hand value much easier.
Original comment by jsva...@gmail.com
on 10 May 2009 at 3:43
This one is a pain. Following the suggestion seems to have my numbers skewed
for
some reason. I need to investigate further.
Original comment by jsva...@gmail.com
on 11 May 2009 at 7:06
Still working on this one. Major PITA.
Original comment by jsva...@gmail.com
on 11 May 2009 at 7:58
Finally resolved. The solution was to modify the getFitness() method of the
FanucciChromosome class to discourage either having more than 3 cards from a
single
suit or having more than 2 groups of suits in a given hand.
Unfortunately the above algorithm does not work in all situations, so it was
decided
it would be better to go with the original suggestion in the forums, namely to
avoid
using more than 2 groups of cards per hand/slot.
Original comment by jsva...@gmail.com
on 12 May 2009 at 4:02
Original issue reported on code.google.com by
jsva...@gmail.com
on 9 May 2009 at 7:20