2016年5月31日 星期二
滾珠的演算法
line : 690
function solve_board(board, step_callback, finish_callback) {
var solutions = new Array(ROWS * COLS);
var weights = get_weights();
var seed_solution = make_solution(board);
in_place_evaluate_solution(seed_solution, weights);
for (var i = 0, s = 0; i < ROWS; ++ i) {
for (var j = 0; j < COLS; ++ j, ++ s) {
solutions[s] = copy_solution_with_cursor(seed_solution, i, j);
}
}
var solve_state = {
step_callback: step_callback,
finish_callback: finish_callback,
max_length: get_max_path_length(),
dir_step: is_8_dir_movement_supported() ? 1 : 2,
p: 0,
solutions: solutions,
weights: weights,
};
solve_board_step(solve_state);
}
function copy_solution_with_cursor(solution, i, j, init_cursor) {
return {board: copy_board(solution.board),
cursor: make_rc(i, j),
init_cursor: init_cursor || make_rc(i, j),
path: solution.path.slice(),
is_done: solution.is_done,
weight: 0,
matches: []};
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言