mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Refactoring - based on fc-solve.
This commit is contained in:
parent
bc25ff5574
commit
77a5b47e98
1 changed files with 11 additions and 14 deletions
|
@ -932,22 +932,19 @@ class Game(object):
|
||||||
cards, scards = self._shuffleHookMoveSorter(cards, func, ncards)
|
cards, scards = self._shuffleHookMoveSorter(cards, func, ncards)
|
||||||
return scards + cards
|
return scards + cards
|
||||||
|
|
||||||
def _shuffleHookMoveSorter(self, cards, func, ncards):
|
def _shuffleHookMoveSorter(self, cards, cb, ncards):
|
||||||
# note that we reverse the cards, so that smaller sort_orders
|
extracted, i, new = [], len(cards), []
|
||||||
# will be nearer to the top of the Talon
|
for c in cards:
|
||||||
sitems, i = [], len(cards)
|
select, ord_ = cb(c)
|
||||||
for c in cards[:]:
|
|
||||||
select, sort_order = func(c)
|
|
||||||
if select:
|
if select:
|
||||||
cards.remove(c)
|
extracted.append((ord_, i, c))
|
||||||
sitems.append((sort_order, i, c))
|
if len(extracted) >= ncards:
|
||||||
if len(sitems) >= ncards:
|
new += cards[(len(cards)-i+1):]
|
||||||
break
|
break
|
||||||
i = i - 1
|
else:
|
||||||
sitems.sort()
|
new.append(c)
|
||||||
sitems.reverse()
|
i -= 1
|
||||||
scards = [item[2] for item in sitems]
|
return new, [x[2] for x in reversed(sorted(extracted))]
|
||||||
return cards, scards
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# menu support
|
# menu support
|
||||||
|
|
Loading…
Add table
Reference in a new issue