1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| loop
-- go on only if we've not already used this piece
if (Piecemask and l_placedPieces) = 0 then
l_placedPieces := l_placedPieces or Piecemask;
for Iorient in 0 .. Allowed.nPieces (ipiece) loop
piecevec := Allowed.pieceVec (ipiece, Iorient);
--check if piece conflicts with other pieces
if (piecevec and l_boardVec) = 0 then
-- add the piece to the board
l_boardVec := l_boardVec or piecevec;
if Has_Bad_Islands (l_boardVec, l_Row) = Good then
pushPiece (m_curSoln, piecevec, ipiece, l_Row);
-- recur or record solution
if (l_placedPieces /= ALL_PIECE_MASK) then
Gen_All_Solutions
(l_boardVec,
l_placedPieces,
l_Row);
else
Record_Solution (m_curSoln);
popPiece (m_curSoln);
return;
end if;
if M_NSoln >= Max_NSoln then
return;
end if;
popPiece (m_curSoln);
end if;
-- remove the piece before continuing with a new piece
l_boardVec := l_boardVec xor piecevec;
end if;
end loop;
l_placedPieces := l_placedPieces xor Piecemask;
end if;
exit when ipiece = Piecenr'Last;
ipiece := ipiece + 1;
Piecemask := Shift_Left (Piecemask, 1);
end loop; |
Partager