| ︙ | | | ︙ | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
global sDim = 9
global mDim = 5
global dim = 16
global moveChoice = Array{Int64}(8)
#global tempMoveChoice1 = Array{Int64}(8)
#global tempMoveChoice2 = Array{Int64}(8) # Only used for double captures
global strength
global whitePrison = []
global blackPrison = []
global chessboard
global tempChessboard
type moveOffset
row::Int64
|
|
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
global sDim = 9
global mDim = 5
global dim = 16
global moveChoice = Array{Int64}(8)
#global tempMoveChoice1 = Array{Int64}(8)
#global tempMoveChoice2 = Array{Int64}(8) # Only used for double captures
global strength = -1
global whitePrison = []
global blackPrison = []
global chessboard
global tempChessboard
type moveOffset
row::Int64
|
| ︙ | | | ︙ | |
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
end
# tempMoveChoice[1] is going to store the type of attack, 1 = single capture, 2 = double capture, 3 = vice general/fire demon
# Have not coded changing capturing chessboard
function capture(tempMoveChoice)
global strength
global moveChoice
temp = 0
if tempMoveChoice[1] == 1
a = 4
b = 5
if dim == tDim
temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
|
|
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
end
# tempMoveChoice[1] is going to store the type of attack, 1 = single capture, 2 = double capture, 3 = vice general/fire demon
# Have not coded changing capturing chessboard
function capture(tempMoveChoice)
global strength
global moveChoice
temp = -1
if tempMoveChoice[1] == 1
a = 4
b = 5
if dim == tDim
temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
|
| ︙ | | | ︙ | |
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
temp += 50
end
end
end
elseif tempMoveChoice[1] == 2
a = 4
b = 5
print(tempMoveChoice)
while a != 0 && b != 0
if dim == tDim
if temp == 0
temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
println(a)
println(b)
temp += pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
elseif dim == cDim
if temp == 0
temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp += pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
else
if temp == 0
temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp += pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
end
if tempMoveChoice[a + 2] == 0 && tempMoveChoice[b + 2] == 0
if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
|
|
<
|
<
<
|
|
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
temp += 50
end
end
end
elseif tempMoveChoice[1] == 2
a = 4
b = 5
while tempMoveChoice[a] != 0 && tempMoveChoice[b] != 0
if dim == tDim
if temp == -1
temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp += pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
elseif dim == cDim
if temp == -1
temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp += pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
else
if temp == -1
temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp += pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
end
end
if tempMoveChoice[a + 2] == 0 && tempMoveChoice[b + 2] == 0
if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
|
| ︙ | | | ︙ | |
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
end
function stepMultiple(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, tempMoveChoice)
global tempChessboard
if jumps == 0
return
end
saveMoveChoice = tempMoveChoice
for i in 1:9
if (chessboard[srcRow, srcCol].name == defFreeEagle && (i == 1 || i == 3 || i == 7 || i == 9)) || (chessboard[srcRow, srcCol].name != defFreeEagle && i != 5)
tempMoveChoice = saveMoveChoice
newTempRow = tempRow + moveOption[i].row
newTempCol = tempCol + moveOption[i].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update" || option == "demon update"
|
|
>
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
end
function stepMultiple(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, tempMoveChoice)
global tempChessboard
if jumps == 0
return
end
saveMoveChoice = deepcopy(tempMoveChoice)
println(saveMoveChoice)
for i in 1:9
if (chessboard[srcRow, srcCol].name == defFreeEagle && (i == 1 || i == 3 || i == 7 || i == 9)) || (chessboard[srcRow, srcCol].name != defFreeEagle && i != 5)
tempMoveChoice = saveMoveChoice
newTempRow = tempRow + moveOption[i].row
newTempCol = tempCol + moveOption[i].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update" || option == "demon update"
|
| ︙ | | | ︙ | |
1313
1314
1315
1316
1317
1318
1319
1320
|
return false
end
createBoard()
add(7, 8, "lion", "Bl")
printBoard()
moveFunctions("capture")
printBoardBAttack()
|
>
|
1311
1312
1313
1314
1315
1316
1317
1318
1319
|
return false
end
createBoard()
add(7, 8, "lion", "Bl")
printBoard()
moveFunctions("capture")
strength = -1
printBoardBAttack()
|