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

eha*_*aat -3 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
Run Code Online (Sandbox Code Playgroud)

Dav*_*rek 7

通过TA的办公时间或向教授寻求帮助.