1 # Copyright (C) 2005-2009, Parrot Foundation.
4 # recursive queens placement
5 # prints all 92 solutions in chess notation
9 .local pmc queen_row, queen_state
10 queen_row = new 'ResizableIntegerArray'
11 queen_state = new 'ResizableIntegerArray'
12 solve(0, queen_row, queen_state)
18 .param pmc queen_state
19 .local int col, is_free
22 is_free = check_free(col, row, queen_state)
23 unless is_free goto not_free
24 place_queen(col, row, queen_row, queen_state)
25 if row < 7 goto not_fin
26 print_solution(queen_row)
30 solve($I0, queen_row, queen_state)
32 remove_queen(col, row, queen_row, queen_state)
40 # 8..14 first diagonal := col + row
41 # 24.. second diagonal := col - row
45 .param pmc queen_state
46 $I0 = queen_state[col]
50 $I0 = queen_state[$I1]
54 $I0 = queen_state[$I1]
65 .param pmc queen_state
67 set_queen(col, row, queen_row, queen_state, $I0)
74 .param pmc queen_state
75 set_queen(col, row, queen_row, queen_state, 0)
82 .param pmc queen_state
85 queen_state[col] = val
88 queen_state[$I1] = val
91 queen_state[$I1] = val
116 # vim: expandtab shiftwidth=4 ft=pir: