0

请解释该[[[0]*64 for i in range(7)] for j in range(2)]部分以及如何编写 lisp 等效项。

pieceHashes = [[[0]*64 for i in range(7)] for j in range(2)]
    for color in WHITE, BLACK:
        for piece in PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING:
            for cord in range(64):
                pieceHashes[color][piece][cord] = randint(0, maxint)
4

2 回答 2

4
(let ((piece-array (make-array '(2 7 64) :initial-element 0)))
  (dolist (color `(,white ,black))
    (dolist (piece `(,pawn ,knight ,bishop ,rook ,queen ,king))
      (loop for cord below 64
            do (setf (aref piece-array color piece cord)
                     (random maxint))))))
于 2012-05-12T08:43:41.620 回答
0

它生成一个具有 64 x 7 x 2 元素的三维数组。然后在最后一行填充数组。

于 2012-05-12T06:26:37.683 回答