Sort with extra variables
Paul Rubin
http
Fri Mar 2 19:46:05 EST 2007
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.
More information about the Python-list
mailing list