Sort with extra variables
Thomas Dybdahl Ahle
lobais at gmail.com
Fri Mar 2 20:35:22 EST 2007
Den Fri, 02 Mar 2007 16:46:05 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <lobais at gmail.com> writes:
>> 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?
>
> Yes, something like that. If you want to get, say, the five smallest
> values in a list, heapq lets you do that without having to sort the
> whole list.
Yeah, I use this now. The only think I don't really like, is the need of
creating a ton of tupples, but it doesn't show me too much it seams.
More information about the Python-list
mailing list