236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
elseif chessboard[i, j].name == defWhiteHorse
defWhiteHorseMove(i, j, option)
end
end
end
end
end
elseif option == "check"
option = "update"
saveChessboard = deepcopy(chessboard)
if chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBishop
defBishopMove(validateMoveChoice[1], validateMoveChoice[2], option)
elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBishopGeneral
defBishopGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBlindTiger
|
>
|
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
elseif chessboard[i, j].name == defWhiteHorse
defWhiteHorseMove(i, j, option)
end
end
end
end
end
#=elseif option == "check"
option = "update"
saveChessboard = deepcopy(chessboard)
if chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBishop
defBishopMove(validateMoveChoice[1], validateMoveChoice[2], option)
elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBishopGeneral
defBishopGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defBlindTiger
|
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
end
if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].side == chessboard[validateMoveChoice[1], validateMoveChoice[2]].side
return false
end
end
end
chessboard = saveChessboard
return true
end
end
######
# FUNCTIONS TO MODIFY BOARD
######
function update(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64, option::String)
|
|
<
|
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
end
if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].side == chessboard[validateMoveChoice[1], validateMoveChoice[2]].side
return false
end
end
end
chessboard = saveChessboard
return true =#
end
######
# FUNCTIONS TO MODIFY BOARD
######
function update(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64, option::String)
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
|
newTempCol = tempCol + moveOption[i].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
elseif option == "demon update"
demonBurn(srcRow, srcCol, newTempRow, newTempCol, 0, option)
end
if option == "capture"
a = 4
b = 5
while tempMoveChoice[a] != 0 && tempMoveChoice[b] != 0
a += 2
b += 2
end
if tempMoveChoice[1] == 2
if (a == 4 && b == 5 && chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy)
tempMoveChoice[a] = newTempRow
tempMoveChoice[b] = newTempCol
capture(tempMoveChoice, 0)
elseif a == 6 && b == 7 && (chessboard[srcRow, srcCol].side != chessboard[tempMoveChoice[4], tempMoveChoice[5]].side && chessboard[tempMoveChoice[4], tempMoveChoice[5]].side != defDummy) || (chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy)
tempMoveChoice[a] = newTempRow
tempMoveChoice[b] = newTempCol
capture(tempMoveChoice, 0)
end
end
if tempMoveChoice[1] == 3 || tempMoveChoice[1] == 4 || tempMoveChoice[1] == 5
temp = 0
if chessboard[srcRow, srcCol].name == defFireDemon
temp = demonBurn(srcRow, srcCol, newTempRow, newTempCol, temp, "calculate")
end
if (chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy) || temp != 0
tempMoveChoice[a] = newTempRow
tempMoveChoice[b] = newTempCol
capture(tempMoveChoice, temp)
end
end
end
if (chessboard[srcRow, srcCol].name == defLion || chessboard[srcRow, srcCol].name == defLionHawk) && chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
elseif chessboard[newTempRow, newTempCol].side == defDummy
|
<
|
|
|
|
|
|
<
<
|
|
>
>
>
<
<
<
<
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
newTempCol = tempCol + moveOption[i].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
elseif option == "demon update"
demonBurn(srcRow, srcCol, newTempRow, newTempCol, 0, option)
end
a = 4
b = 5
while tempMoveChoice[a] != 0 && tempMoveChoice[b] != 0
a += 2
b += 2
end
tempMoveChoice[a] = newTempRow
tempMoveChoice[b] = newTempCol
if option == "capture"
if tempMoveChoice[1] == 2
if (a == 4 && b == 5 && chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy)
capture(tempMoveChoice, 0)
elseif a == 6 && b == 7 && (chessboard[srcRow, srcCol].side != chessboard[tempMoveChoice[4], tempMoveChoice[5]].side && chessboard[tempMoveChoice[4], tempMoveChoice[5]].side != defDummy) || (chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy)
capture(tempMoveChoice, 0)
end
end
if tempMoveChoice[1] == 3 || tempMoveChoice[1] == 4 || tempMoveChoice[1] == 5
temp = 0
if chessboard[srcRow, srcCol].name == defFireDemon
temp = demonBurn(srcRow, srcCol, newTempRow, newTempCol, temp, "calculate")
end
if (chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy) || temp != 0
capture(tempMoveChoice, temp)
end
end
end
if (chessboard[srcRow, srcCol].name == defLion || chessboard[srcRow, srcCol].name == defLionHawk) && chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
elseif chessboard[newTempRow, newTempCol].side == defDummy
|
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
|
tempMoveChoice = deepcopy(saveMoveChoice)
newTempRow = tempRow + moveOption[index].row
newTempCol = tempCol + moveOption[index].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update" || option == "update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if option == "capture"
if chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy
tempMoveChoice[4] = newTempRow
tempMoveChoice[5] = newTempCol
capture(tempMoveChoice, 0)
end
end
stepMultipleLinear(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, index, tempMoveChoice)
end
elseif jumps == 1
newTempRow = tempRow - moveOption[index].row # igui
newTempCol = tempCol - moveOption[index].col
if option == "capture"
if (chessboard[srcRow, srcCol].side != chessboard[tempMoveChoice[4], tempMoveChoice[5]].side && chessboard[tempMoveChoice[4], tempMoveChoice[5]].side != defDummy) # Check if either has occupied piece.
tempMoveChoice[6] = newTempRow
tempMoveChoice[7] = newTempCol
capture(tempMoveChoice, 0)
end
end
if chessboard[srcRow, srcCol].name != defHeavenlyTetrarch
newTempRow = tempRow + moveOption[index].row
newTempCol = tempCol + moveOption[index].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
|
<
<
|
|
>
>
>
<
<
|
|
>
>
|
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
|
tempMoveChoice = deepcopy(saveMoveChoice)
newTempRow = tempRow + moveOption[index].row
newTempCol = tempCol + moveOption[index].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "special update" || option == "update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
tempMoveChoice[4] = newTempRow
tempMoveChoice[5] = newTempCol
if option == "capture"
if chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy
capture(tempMoveChoice, 0)
end
end
stepMultipleLinear(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, index, tempMoveChoice)
end
elseif jumps == 1
println(tempMoveChoice)
newTempRow = tempRow - moveOption[index].row # igui
newTempCol = tempCol - moveOption[index].col
tempMoveChoice[6] = newTempRow
tempMoveChoice[7] = newTempCol
if option == "capture"
if (chessboard[srcRow, srcCol].side != chessboard[tempMoveChoice[4], tempMoveChoice[5]].side && chessboard[tempMoveChoice[4], tempMoveChoice[5]].side != defDummy) # Check if either has occupied piece.
capture(tempMoveChoice, 0)
end
end
if chessboard[srcRow, srcCol].name != defHeavenlyTetrarch
newTempRow = tempRow + moveOption[index].row
newTempCol = tempCol + moveOption[index].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
|
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
|
end
######
# MAIN
######
createBoard()
add(8, 8, "fire demon", "Bl")
add(16, 16, "rook", "Wh")
printBoard()
currTurn = "Bl"
moveFunctions("capture")
moveFunctions("update")
strength = -1
printBoardBAttack()
|
|
|
>
|
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
|
end
######
# MAIN
######
createBoard()
add(8, 8, "horned falcon", "Bl")
add(7, 8, "king", "Wh")
add(6, 8, "king", "Wh")
printBoard()
currTurn = "Bl"
moveFunctions("capture")
moveFunctions("update")
strength = -1
printBoardBAttack()
|