1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# limited move options
global pieceValTenjiku = Dict{String, Int64}("_" => 0, "bishop" => 10, "bishop general" => 21, "blind tiger" => 3, "copper general" => 2, "chariot soldier" => 18, "dog" => 1, "drunk elephant" => 3, "dragon horse" => 12, "dragon king" => 14, "ferocious leopard" => 3, "flying ox" => 16, "flying stag" => 9, "fire demon" => 83, "free boar" => 16, "free eagle" => 22, "gold general" => 3, "great general" => 45, "heavenly tetrarch" => 12, "horned falcon" => 19, "iron general" => 2, "king" => 500, "kirin" => 3, "lance" => 6, "lion hawk" => 25, "lion" => 18, "multi general" => 6, "knight" => 1, "pawn" => 1, "phoenix" => 3, "queen" => 22, "rook" => 12, "reverse chariot" => 6, "rook general" => 23, "silver general" => 2, "soaring eagle" => 18, "side mover" => 7, "side soldier" => 7, "vice general" => 39, "vertical mover" => 7, "vertical soldier" => 8, "water buffalo" => 17, "whale" => 10, "white horse" => 14)
global rangeJumpPriority = Dict{String, Int64}("_" => 0, "bishop" => 0, "bishop general" => 1, "blind tiger" => 0, "copper general" => 0, "chariot soldier" => 0, "dog" => 0, "drunk elephant" => 0, "dragon horse" => 0, "dragon king" => 0, "ferocious leopard" => 0, "flying ox" => 0, "flying stag" => 0, "fire demon" => 0, "free boar" => 0, "free eagle" => 0, "gold general" => 0, "great general" => 3, "heavenly tetrarch" => 0, "horned falcon" => 0, "iron general" => 0, "king" => 4, "kirin" => 0, "lance" => 0, "lion hawk" => 0, "lion" => 0, "multi general" => 0, "knight" => 0, "pawn" => 0, "phoenix" => 0, "queen" => 0, "rook" => 0, "reverse chariot" => 0, "rook general" => 1, "silver general" => 0, "soaring eagle" => 0, "side mover" => 0, "side soldier" => 0, "vice general" => 2, "vertical mover" => 0, "vertical soldier" => 0, "water buffalo" => 0, "whale" => 0, "white horse" => 0)
global pieceValChu = Dict{Char,Int64}('_' => 0, 'i'=> 20, 'q' => 12, 'd' => 8, 'D' => 11, 'h' => 7, 'H' => 10, 'r' => 6, 'R' => 8, 'b' => 5, 'B' => 7, 'v' => 4, 'V' => 8, 'm' => 4, 'M' => 8, 'k' => 50, 'x' => 3, 'X' => 12, 'n' => 3, 'N' => 20, 'a' => 3, 'A' => 5, 'l' => 3, 'L' => 7, 'e' => 3, 'E' => 50, 'g' => 3, 'G' => 6, 'f' => 3, 'F' => 5, 't' => 3, 'T' => 6, 's' => 2, 'S' => 4, 'c' => 2, 'C' => 4,'o' => 1, 'O' => 3, 'p' => 1, '3' => 3)
global pieceVal = Dict{Char,Int64}("pawn"=>1,'P'=>2,'l'=>4,'L'=>5,'n'=>6,
'N'=>7,'s'=>7,'S'=>8,'g'=>8,'b'=>11,'r'=>13,'B'=>15,'R'=>17, 'k'=>50)
global defEmpty = "_"
global defBishop = "bishop"
global defBishopGeneral = "bishop general"
global defBlindTiger = "blind tiger"
global defCopperGeneral = "copper general"
global defChariotSoldier = "chariot soldier"
global defDog = "dog"
|
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# limited move options
global pieceValTenjiku = Dict{String, Int64}("_" => 0, "bishop" => 10, "bishop general" => 21, "blind tiger" => 3, "copper general" => 2, "chariot soldier" => 18, "dog" => 1, "drunk elephant" => 3, "dragon horse" => 12, "dragon king" => 14, "ferocious leopard" => 3, "flying ox" => 16, "flying stag" => 9, "fire demon" => 83, "free boar" => 16, "free eagle" => 22, "gold general" => 3, "great general" => 45, "heavenly tetrarch" => 12, "horned falcon" => 19, "iron general" => 2, "king" => 500, "kirin" => 3, "lance" => 6, "lion hawk" => 25, "lion" => 18, "multi general" => 6, "knight" => 1, "pawn" => 1, "phoenix" => 3, "queen" => 22, "rook" => 12, "reverse chariot" => 6, "rook general" => 23, "silver general" => 2, "soaring eagle" => 18, "side mover" => 7, "side soldier" => 7, "vice general" => 39, "vertical mover" => 7, "vertical soldier" => 8, "water buffalo" => 17, "whale" => 10, "white horse" => 14)
global rangeJumpPriority = Dict{String, Int64}("_" => 0, "bishop" => 0, "bishop general" => 1, "blind tiger" => 0, "copper general" => 0, "chariot soldier" => 0, "dog" => 0, "drunk elephant" => 0, "dragon horse" => 0, "dragon king" => 0, "ferocious leopard" => 0, "flying ox" => 0, "flying stag" => 0, "fire demon" => 0, "free boar" => 0, "free eagle" => 0, "gold general" => 0, "great general" => 3, "heavenly tetrarch" => 0, "horned falcon" => 0, "iron general" => 0, "king" => 4, "kirin" => 0, "lance" => 0, "lion hawk" => 0, "lion" => 0, "multi general" => 0, "knight" => 0, "pawn" => 0, "phoenix" => 0, "queen" => 0, "rook" => 0, "reverse chariot" => 0, "rook general" => 1, "silver general" => 0, "soaring eagle" => 0, "side mover" => 0, "side soldier" => 0, "vice general" => 2, "vertical mover" => 0, "vertical soldier" => 0, "water buffalo" => 0, "whale" => 0, "white horse" => 0)
global pieceValChu = Dict{Char,Int64}('_' => 0, 'i'=> 20, 'q' => 12, 'd' => 8, 'D' => 11, 'h' => 7, 'H' => 10, 'r' => 6, 'R' => 8, 'b' => 5, 'B' => 7, 'v' => 4, 'V' => 8, 'm' => 4, 'M' => 8, 'k' => 50, 'x' => 3, 'X' => 12, 'n' => 3, 'N' => 20, 'a' => 3, 'A' => 5, 'l' => 3, 'L' => 7, 'e' => 3, 'E' => 50, 'g' => 3, 'G' => 6, 'f' => 3, 'F' => 5, 't' => 3, 'T' => 6, 's' => 2, 'S' => 4, 'c' => 2, 'C' => 4,'o' => 1, 'O' => 3, 'p' => 1, '3' => 3)
global pieceVal = Dict{Char,Int64}("pawn"=>1,'P'=>2,'l'=>4,'L'=>5,'n'=>6,
'N'=>7,'s'=>7,'S'=>8,'g'=>8,'b'=>11,'r'=>13,'B'=>15,'R'=>17, 'k'=>50)
global prStandard = Dict{String, String}("rook promoted" => "dragon king","bishop promoted" => "dragon horse","silver general promoted" => "gold general",
"knight promoted" => "gold general", "lance promoted" => "gold general", "pawn promoted" => "gold general")
global prTenjiku = Dict{String,String}("bishop promoted" => "dragon horse", "bishop general promoted" => "vice general",
"blind tiger promoted" => "flying stag", "chariot soldier promoted" => "heavenly tetrarch", "copper general promoted" => "side mover", "dog promoted" => "multi general",
"dragon horse promoted" => "horned falcon", "dragon king promoted" => "soaring eagle", "drunk elephant promoted" => "prince", "ferocious leopard promoted" => "bishop",
"gold general promoted" => "rook", "horned falcon promoted" => "bishop general", "iron general promoted" => "vertical soldier", "kirin promoted" => "lion", "knight promoted" => "side soldier",
"lance promoted" => "white horse", "lion promoted" => "lion hawk", "pawn promoted" => "gold general", "phoenix promoted" => "queen", "queen promoted" => "free eagle",
"reverse chariot promoted" => "whale", "rook promoted" => "dragon king", "rook general promoted" => "great general", "side mover promoted" => "free boar",
"side soldier promoted" => "water buffalo", "silver general promoted" => "vertical mover", "soaring eagle promoted" => "rook general", "vertical mover promoted" => "flying ox",
"vertical soldier promoted" => "chariot soldier", "water buffalo promoted" => "fire demon" )
global defEmpty = "_"
global defBishop = "bishop"
global defBishopGeneral = "bishop general"
global defBlindTiger = "blind tiger"
global defCopperGeneral = "copper general"
global defChariotSoldier = "chariot soldier"
global defDog = "dog"
|
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
end
end
end
end
end
function rangeJump(srcRow::Int64, srcCol::Int64, option::String, index::Int64)
tempRow = srcRow
tempCol = srcCol
while true
tempRow = tempRow + moveOption[index].row
tempCol = tempCol + moveOption[index].col
if tempRow > dim || tempRow < 1 || tempCol > dim || tempCol < 1
break
end
if option == "update" || option == "special update"
update(srcRow, srcCol, tempRow, tempCol, option)
end
if chessboard[tempRow, tempCol].side != defDummy
if option == "capture"
tempMoveChoice = [1, srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
end
if rangeJumpPriority[chessboard[srcRow, srcCol].name] < rangeJumpPriority[chessboard[tempRow, tempCol].name] # Not jumpable
break
end
end
end
function range(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, index::Int64)
newTempRow = tempRow
newTempCol = tempCol
while true
newTempRow = newTempRow + moveOption[index].row
newTempCol = newTempCol + moveOption[index].col
if newTempRow > dim || newTempRow < 1 || newTempCol > dim || newTempCol < 1
break
end
if option == "update" || option == "special update" || option == "demon update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if chessboard[newTempRow, newTempCol].side != defDummy
if option == "capture"
tempMoveChoice = [1, srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
break
end
end
end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
end
end
end
end
end
function stepMultipleLinear(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, index::Int64, tempMoveChoice)
global tempChessboard
if jumps == 0
return
end
saveMoveChoice = tempMoveChoice
if jumps == 2
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"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if option == "capture"
tempMoveChoice[4] = newTempRow
tempMoveChoice[5] = newTempCol
capture(tempMoveChoice)
end
stepMultipleLinear(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
end
elseif jumps == 1
newTempRow = tempRow - moveOption[i].row ## igui
newTempCol = tempCol - moveOption[i].col
if option == "capture"
tempMoveChoice[6] = newTempRow
tempMoveChoice[7] = newTempCol
capture(tempMoveChoice)
end
newTempRow = tempRow + moveOption[i].row
newTempCol = tempCol + moveOption[i].col
if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
if option == "update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if option == "capture"
tempMoveChoice[6] = newTempRow
tempMoveChoice[7] = newTempCol
capture(tempMoveChoice)
end
end
end
end
function rangeJump(srcRow::Int64, srcCol::Int64, option::String, index::Int64)
tempRow = srcRow
tempCol = srcCol
while true
tempRow = tempRow + moveOption[index].row
tempCol = tempCol + moveOption[index].col
if tempRow > dim || tempRow < 1 || tempCol > dim || tempCol < 1
break
end
if option == "update" || option == "special update"
update(srcRow, srcCol, tempRow, tempCol, option)
end
if chessboard[tempRow, tempCol].side != defDummy
if option == "capture"
tempMoveChoice = [1, srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
end
if rangeJumpPriority[chessboard[srcRow, srcCol].name] < rangeJumpPriority[chessboard[tempRow, tempCol].name] # Not jumpable
break
end
end
end
function range(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, index::Int64)
newTempRow = tempRow
newTempCol = tempCol
while true
newTempRow = newTempRow + moveOption[index].row
newTempCol = newTempCol + moveOption[index].col
if newTempRow > dim || newTempRow < 1 || newTempCol > dim || newTempCol < 1
break
end
if option == "update" || option == "special update" || option == "demon update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if chessboard[newTempRow, newTempCol].side != defDummy
if option == "capture"
tempMoveChoice = [1, srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
break
end
end
end
|
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defDragonKingMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 2 || i == 4 || i == 6 || i == 8
range(srcRow, srcCol, srcRow, srcCol, option, i)
elseif i == 1 || i == 3 || i == 7 || i == 9
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defBishopMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 1 || i == 3 || i == 7 || i == 9
range(srcRow, srcCol, option, srcRow, srcCol, i)
end
end
end
function defRookMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 2 || i == 4 || i == 6 || i == 8
range(srcRow, srcCol, option, srcRow, srcCol, i)
end
end
end
function defFerociousLeopardMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
|
|
|
|
|
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
|
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defDragonKingMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 2 || i == 4 || i == 6 || i == 8
range(srcRow, srcCol, srcRow, srcCol, option, i)
elseif i == 1 || i == 3 || i == 7 || i == 9
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defBishopMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 1 || i == 3 || i == 7 || i == 9
range(srcRow, srcCol, option, srcRow, srcCol, i)
end
end
end
function defRookMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
if i == 2 || i == 4 || i == 6 || i == 8
range(srcRow, srcCol, option, srcRow, srcCol, i)
end
end
end
function defFerociousLeopardMove(srcRow::Int64, srcCol::Int64, option::String)
for i in 1:9
|
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
|
if (chessboard[srcRow, srcCol].side == defWhite && (i == 1 || i == 2 || i == 3)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 7 || i == 8 || i == 9))
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defFreeEagleMove(srcRow::Int64, srcCol::Int64, option::String) # Need Exceptions
for i in 1:9
if i != 5
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
range(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col, i)
end
end
end
function defLionHawkMove(srcRow::Int64, srcCol::Int64, option::String)
global tempChessboard
if option == "update"
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
|
>
|
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
|
if (chessboard[srcRow, srcCol].side == defWhite && (i == 1 || i == 2 || i == 3)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 7 || i == 8 || i == 9))
step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
end
end
end
function defFreeEagleMove(srcRow::Int64, srcCol::Int64, option::String) # Need Exceptions
global tempChessboard
if option == "update"
tempChessboard = deepcopy(chessboard)
for i in 1:dim
for j in 1:dim
tempChessboard[i, j].WAttack = 0
tempChessboard[i, j].BAttack = 0
end
end
end
if option == "update"
option = "special update"
end
tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
stepMultiple(srcRow, srcCol, option, srcRow, srcCol, 2, tempMoveChoice)
for i in 1:9
if i != 5
if option == "update"
range(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col, i)
end
end
end
end
function defLionHawkMove(srcRow::Int64, srcCol::Int64, option::String)
global tempChessboard
if option == "update"
|