Sort with extra variables
Thomas Dybdahl Ahle
lobais at gmail.com
Fri Mar 2 18:08:19 EST 2007
Den Fri, 02 Mar 2007 11:44:27 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <lobais at gmail.com> writes:
>> Do you have any ideas how I can sort these moves the fastest?
>
> One idea: if you're using alpha-beta pruning, maybe you can use
> something like heapq instead of sorting, since a lot of the time you
> only have to look at the first few moves (ordered best-first).
Do you mean that I add my moves something like this?
from heapq import heappush, heappop
heap = []
for move in genAll():
heappush(heap, (-getMoveValue (board, table, ply, move), move))
And then use heappop(heap) in the alphabeta loop?
I don't know much of heap queues, but it actually looks very smart.
More information about the Python-list
mailing list