Skip to content

Commit

Permalink
AI customization for difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
kinoroy committed Dec 6, 2016
1 parent 03d3f3f commit 22a657f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions AI.jl
Expand Up @@ -6,7 +6,8 @@ using BM
global states = Array(Dict{Tuple{Int64,Int64},Tuple{Char,Char}},0)
global gameType,board,seed

function init(igameType,iboard,iseed)
function init(igameType,iboard,iseed,difficulty)
difficultyDict = Dict("normal"=>100,"hard"=>300,"suicidal"=>5,"protacted death"=>5)
global states
global gameType = igameType
global board = iboard
Expand All @@ -18,7 +19,7 @@ end


#seed = time()
calculationTime = 20 #Max calculation time permitted in seconds
calculationTime = difficultyDict[difficulty] #Max calculation time permitted in seconds
max_moves = 500
global wins = Dict()
global plays = Dict()
Expand Down
8 changes: 6 additions & 2 deletions AIHelp.jl
Expand Up @@ -800,7 +800,9 @@ function legalMoves(board,x,y)
target = board[(x,y)]
unit = target[1]
# println("$unit at $x , $y")
funDict = Dict('b' => bishop, 'g' => goldGeneral, 'k' => king, 'l' => lance, 'n' => knight, 'p' => pawn, 'r' => rook, 's' => silverGeneral)
funDict = Dict("bishop" => bishop, "gold general" => goldGeneral, "king" => king, "lance" => lance, "knight" => knight, "pawn" => pawn, "rook" => rook, "silver general" => silverGeneral,
"phoenix" => phoenix, "vertical mover" => verticalMover, "go-between" => goBetween, "queen" => queen, "lion" => lion, "dragon king" => dragonKing, "dragon horse", dragonHorse, "side mover" => sideMover,
"kirin" => kirin, "blind tiget"=> blindTiger, "reverse chariot" => reverseChariot, "drunk elephant" => drunkElephant, "ferocious leopard" => ferociousLeopard, "blind tiger" => blindTiger)
funDict[unit](board,x,y)
end

Expand All @@ -818,7 +820,9 @@ function legalMovesPlayer(board,team,shogiType)
end
end=#
for (x,y) in keys(board)
append!(legalC,legalMoves(board,x,y))
if y == currentTeam
append!(legalC,legalMoves(board,x,y))
end
end
return legalC
end
Expand Down

0 comments on commit 22a657f

Please sign in to comment.