解决N-Queen问题的最小冲突算法

时间:2010-01-25 01:14:42

标签: java algorithm artificial-intelligence

使用nQueens问题 如何将此算法转换为java代码

 function MIN-CONFLICTS(csp,max_steps) returns a solution or failure
   inputs: csp, a constraint satisfaction problem
           max_steps,the number of steps allowed before giving up
   current<-- an initial assignment for csp
   for i=1 to max_steps do
       if current is a solution of csp then return current
       var<-- a randomly chosen, conflicted variable from VARIABLES[csp]
       value<-- the value v for var that minimizes CONFLICTS(var,v,current,csp)
       set var = value in current
 return failure

1 个答案:

答案 0 :(得分:7)

到TA办公室工作时间或向教授寻求帮助。