| ︙ | | | ︙ | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
end
end
return temp
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)
a = 0
b = 0
global strength
global moveChoice
global chessboard
temp = -1
if tempMoveChoice[1] == 1
a = 4
b = 5
elseif tempMoveChoice[1] == 3
a = 8
b = 9
while tempMoveChoice[a] == 0 && tempMoveChoice[b] == 0
a -= 2
b -= 2
end
end
if tempMoveChoice[1] == 1 || tempMoveChoice[1] == 3
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[2], tempMoveChoice[3], tempMoveChoice[a], tempMoveChoice[b], temp)
end
elseif dim == cDim
temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
end
if chessboard[tempMoveChoice[2], tempMoveChoice[3]].side == defBlack # check if attack is safe
if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
|
|
>
>
>
|
<
<
<
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
end
end
return temp
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, demonBurnVal::Int64)
a = 0
b = 0
global strength
global moveChoice
global chessboard
temp = -1
if demonBurnVal != 0
temp = demonBurnVal
end
if tempMoveChoice[1] == 1
a = 4
b = 5
elseif tempMoveChoice[1] == 3
a = 8
b = 9
while tempMoveChoice[a] == 0 && tempMoveChoice[b] == 0
a -= 2
b -= 2
end
end
if tempMoveChoice[1] == 1 || tempMoveChoice[1] == 3
if dim == tDim
temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
elseif dim == cDim
temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
else
temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
end
if chessboard[tempMoveChoice[2], tempMoveChoice[3]].side == defBlack # check if attack is safe
if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
|
| ︙ | | | ︙ | |
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
if destRow <= dim && destRow >= 1 && destCol <= dim && destCol >= 1
if option == "update" || option == "special update"
update(srcRow, srcCol, destRow, destCol, option)
end
if option == "capture"
if chessboard[srcRow, srcCol].side != chessboard[destRow, destCol].side && chessboard[destRow, destCol].side != defDummy
tempMoveChoice = [1, srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
end
end
end
function stepMultiple(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, tempMoveChoice)
global tempChessboard
|
|
|
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
if destRow <= dim && destRow >= 1 && destCol <= dim && destCol >= 1
if option == "update" || option == "special update"
update(srcRow, srcCol, destRow, destCol, option)
end
if option == "capture"
if chessboard[srcRow, srcCol].side != chessboard[destRow, destCol].side && chessboard[destRow, destCol].side != defDummy
tempMoveChoice = [1, srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
capture(tempMoveChoice, 0)
end
end
end
end
function stepMultiple(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, tempMoveChoice)
global tempChessboard
|
| ︙ | | | ︙ | |
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
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)
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)
end
end
if tempMoveChoice[1] == 3
if chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy
tempMoveChoice[a] = newTempRow
tempMoveChoice[b] = newTempCol
capture(tempMoveChoice)
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
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
|
|
|
>
>
>
>
|
|
|
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
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
temp = 0
if chessboard[srcRow, srcCol].name == defFireDemon
temp = demonBurn(srcRow, srcCol, newTempRow, newTempCol, temp)
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, 0)
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
stepMultiple(srcRow, srcCol, option, newTempRow, newTempCol, jumps - 1, tempMoveChoice)
|
| ︙ | | | ︙ | |
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
|
if option == "special update" || option == "demon 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)
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)
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
if option == "update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if option == "capture"
if (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[6] = newTempRow
tempMoveChoice[7] = newTempCol
capture(tempMoveChoice)
end
end
end
end
end
end
|
|
|
|
|
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
|
if option == "special update" || option == "demon 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
if option == "update"
update(srcRow, srcCol, newTempRow, newTempCol, option)
end
if option == "capture"
if (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[6] = newTempRow
tempMoveChoice[7] = newTempCol
capture(tempMoveChoice, 0)
end
end
end
end
end
end
|
| ︙ | | | ︙ | |
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
601
602
603
604
605
606
607
608
609
610
611
612
613
|
end
if option == "update" || option == "special update"
update(srcRow, srcCol, tempRow, tempCol, option)
end
if chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol] && 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"
if chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol] && chessboard[tempRow, tempCol].side != defDummy
tempMoveChoice = [1, srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
capture(tempMoveChoice)
end
end
break
end
end
end
|
|
>
>
>
>
|
|
|
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
|
end
if option == "update" || option == "special update"
update(srcRow, srcCol, tempRow, tempCol, option)
end
if chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol] && chessboard[tempRow, tempCol].side != defDummy
if option == "capture"
tempMoveChoice = [1, srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
capture(tempMoveChoice, 0)
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
temp = 0
if chessboard[srcRow, srcCol].name == defFireDemon
temp = demonBurn(srcRow, srcCol, newTempRow, newTempCol, temp)
end
if chessboard[newTempRow, newTempCol].side != defDummy
if option == "capture"
if (chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol] && chessboard[tempRow, tempCol].side != defDummy) || temp != 0
tempMoveChoice = [1, srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
capture(tempMoveChoice, temp)
end
end
break
end
end
end
|
| ︙ | | | ︙ | |