Den Sat, 03 Mar 2007 11:26:08 +0100 skrev Diez B. Roggisch:
>> Well, you'd have to define the function inside the sortMoves function,
>> as it is where the variables exists.
>>
>> def sortMoves(board, table, ply, moves):
>> def sortKey(move):
>> return getMoveValue(board, table, ply,
> Well, you'd have to define the function inside the sortMoves function, as
> it is where the variables exists.
>
> def sortMoves(board, table, ply, moves):
> def sortKey(move):
> return getMoveValue(board, table, ply, move)
> moves.sort(key=sortKey, reverse=True) return moves
>
In <[EMAIL PROTECTED]>, Thomas Dybdahl Ahle wrote:
> Den Fri, 02 Mar 2007 21:13:02 +0100 skrev Bjoern Schliessmann:
>
>> Thomas Dybdahl Ahle wrote:
>>
>>> However I'd really like not to use the lambda, as it slows down the
>>> code.
>>
>> Did you check how much the slowdown is?
>
> Yes, the la
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> I have a sort function in a python chess program.
> Currently it looks like this:
>
> def sortMoves (board, table, ply, moves):
> f = lambda move: getMoveValue (board, table, ply, move)
> moves.sort(key=f, reverse=True)
> return moves
>
On Mar 2, 7:34 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> Well, you'd have to define the function inside the sortMoves function, as
> it is where the variables exists.
Oh, sorry, I wasn't thinking there!
Regards,
Jordan
--
http://mail.python.org/mailman/listinfo/python-list
Den Fri, 02 Mar 2007 16:46:05 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> 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,
Den Fri, 02 Mar 2007 16:27:47 -0800 skrev MonkeeSage:
> On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> I guess the thing is that I'd have to create a new callable no matter
>> how, as it is the only way to bring the extra variables into the
>> getValue function when called by
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> 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
On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> I guess the thing is that I'd have to create a new callable no matter
> how, as it is the only way to bring the extra variables into the getValue
> function when called by sort.
Yes, but you don't have to create it every time you
Den Fri, 02 Mar 2007 15:20:33 -0800 skrev MonkeeSage:
> On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
>> Wouldn't that be just as slow?
>
> Well, I'm not sure about speed, but with the lambda you're creating a
> new callable for f every time you call sortMoves. Intuitively, th
On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> Wouldn't that be just as slow?
Well, I'm not sure about speed, but with the lambda you're creating a
new callable for f every time you call sortMoves. Intuitively, that
seems like it would be more of a hit than just doing a lookup
Den Fri, 02 Mar 2007 20:33:45 +0100 skrev Diez B. Roggisch:
> Thomas Dybdahl Ahle schrieb:
>> I have a sort function in a python chess program. Currently it looks
>> like this:
>>
>> def sortMoves (board, table, ply, moves):
>> f = lambda move: getMoveValue (board, table, ply, move)
>> mo
Den Fri, 02 Mar 2007 11:44:27 -0800 skrev Paul Rubin:
> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> 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 th
Den Fri, 02 Mar 2007 21:13:02 +0100 skrev Bjoern Schliessmann:
> Thomas Dybdahl Ahle wrote:
>
>> However I'd really like not to use the lambda, as it slows down the
>> code.
>
> Did you check how much the slowdown is?
Yes, the lambda adds 50%
--
http://mail.python.org/mailman/listinfo/python-l
Thomas Dybdahl Ahle wrote:
> However I'd really like not to use the lambda, as it slows down
> the code.
Did you check how much the slowdown is?
Regards,
Björn
--
BOFH excuse #65:
system needs to be rebooted
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> 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 bes
Thomas Dybdahl Ahle schrieb:
> I have a sort function in a python chess program.
> Currently it looks like this:
>
> def sortMoves (board, table, ply, moves):
> f = lambda move: getMoveValue (board, table, ply, move)
> moves.sort(key=f, reverse=True)
> return moves
>
> However I'd rea
17 matches
Mail list logo