腦力激盪

soulbacker

一般般會員
已加入
8/24/04
訊息
154
互動分數
0
點數
0
同事的課堂作業....
目標是在棋盤上排出8個西洋棋皇后
而彼此不能互相攻擊到
也就是直斜角上都無棋子
像下面的圖就是左上角跟右下角的衝到了......
聽說他們課堂上沒人做出來
小弟倒是花了約半小時做出來
po上來給大家玩一玩
過兩天再公布答案



8-queens problem:
States: Arrangements of n queens (0 ≤ n ≤ 8), one per column in the leftmost n columns, with no queen attacking another are states.
Successor function: Add a queen to any square in the leftmost empty column such that it is not attacked by any other queen.
Goal test: 8 queens are on the board, none attacked.
Almost a solution to the 8-queens problem:

03Sspsf05.jpg
 
▌延伸閱讀