2019-05-05 09:25:41 UNSELECTED

Unknown type code

Copy Copied! Full
local k = 3 function evaluate(board, __board) movablesScore = 70 * (#MovePossible(board) - #MovePossible(TableBoardCreate(__board))) lineScore = k * (calcLineScore(board) - calcLineScore(TableBoardCreate(__board))) return movablesScore + lineScore end function calcLineScore(board) local score = 0 for i = 1, #board.brd_ang do if board.brd_ang[i] == board.now_ang then if (i == 1) or (i == 8) or (i == 64) or (i == 57) then score = score + 15470 end if (i == 2) or (i == 7) or (i == 63) or (i == 58) then score = score - 4390 end if (i == 3) or (i == 5) or (i == 62) or (i == 59) then score = score + 50 end if (i == 10) or (i == 15) or (i == 50) or (i == 55) then score = score - 4303 end if (i == 19) or (i == 22) or (i == 46) or (i == 43) then score = score + 55 end end end return score end --サイトのを変換して持ってくる function alphaBetaEval(board, depth, a, b, __board) if depth == nil then depth = 0 end if depth <= 0 then return evaluate(TableBoardCreate(board), __board) end if board.now_ang == 180 then board.now_ang = 0 else board.now_ang = 180 end local movables = MovePossible(TableBoardCreate(board)) if #movables == 0 then return -alphaBetaEval(TableBoardCreate(board), depth - 1, -b, -a, __board) end for key, move_point in pairs(movables) do local aaa = -alphaBetaEval(move(TableBoardCreate(board), move_point), passes, -b, -a, board) if a < aaa then a = aaa end if a >= b then return a end end return a end function MovePossible(board) local move_table = {} for i = 1, #board.brd_flg do if board.brd_flg[i] == 0 then if true == PosibleSearch22(i, board.now_ang, board.brd_ang) then table.insert(move_table, i) end end end return move_table end --駒を置けるか探す処理 function PosibleSearch22(min, now_ang, brd_ang) --ここから横縦斜めの、駒置けるか判断する処理 ama = (min - 1) % 8 num = 0 FLG = false for i = 1, 7 - ama do if not (brd_ang[min + i] == now_ang) then if brd_ang[min + i] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end end if FLG == true then return true end num = 0 FLG = false for i = 1, ama do if not (brd_ang[min - i] == now_ang) then if brd_ang[min - i] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end end if FLG == true then return true end sho = math.floor((min - 1) / 8) num = 0 FLG = false for i = 1, 7 - sho do if not (brd_ang[min + i * 8] == now_ang) then if brd_ang[min + i * 8] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end end if FLG == true then return true end num = 0 FLG = false for i = 1, sho do if not (brd_ang[min - i * 8] == now_ang) then if brd_ang[min - i * 8] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end end if FLG == true then return true end --斜 num = 0 FLG = false if (7 - sho) < (7-ama) then data = 7 - sho else data = 7-ama end for i = 1, data do if min + i * 9 < 65 then if not (brd_ang[min + i * 9] == now_ang) then if brd_ang[min + i * 9] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end else break end end if FLG == true then return true end num = 0 FLG = false if sho < ama then data = sho else data = ama end for i = 1, data do if min - i * 9 > 0 then if not (brd_ang[min - i * 9] == now_ang) then if brd_ang[min - i * 9] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end else break end end if FLG == true then return true end num = 0 FLG = false if sho < (7 - ama) then data = sho else data = 7 - ama end for i = 1, data do if min - i * 7 > 0 then if not (brd_ang[min - i * 7] == now_ang) then if brd_ang[min - i * 7] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end else break end end if FLG == true then return true end num = 0 FLG = false if (7 - sho) < ama then data = 7 - sho else data = ama end for i = 1, data do if min + i * 7 < 65 then if not (brd_ang[min + i * 7] == now_ang) then if brd_ang[min + i * 7] == 90 then break else num = num + 1 end else if num > 0 then FLG = true end break end else break end end if FLG == true then return true end return false end
RECOMMEND