Diff

Differences From Artifact [1250b852bf]:

To Artifact [858ec30f3f]:


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"
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
global defViceGeneral = "vice general"
global defVerticalMover = "vertical mover"
global defVerticalSoldier = "vertical soldier"
global defWaterBuffalo = "water buffalo"
global defWhale = "whale"
global defWhiteHorse = "white horse"

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 defDummy = "D"
global defWhite = "Wh"
global defBlack = "Bl"

global tDim = 16
global cDim = 12
global sDim = 9







<
<
<
<
<
<
<
<
<
<
<







61
62
63
64
65
66
67











68
69
70
71
72
73
74
global defViceGeneral = "vice general"
global defVerticalMover = "vertical mover"
global defVerticalSoldier = "vertical soldier"
global defWaterBuffalo = "water buffalo"
global defWhale = "whale"
global defWhiteHorse = "white horse"












global defDummy = "D"
global defWhite = "Wh"
global defBlack = "Bl"

global tDim = 16
global cDim = 12
global sDim = 9
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	end
	if captured.name == defKing # gamewin
		push!(capturedArray, captured.name)
		return true
	elseif captured.name == defGGen # Does not promote
		push!(capturedArray, captured.name)
		return false
	elseif contains(captured.name, "promoted")
		splitName = split(captured.name) # Demote captured piece.
		len = length(splitName)
		demoted = ""
		for i = 1:len-1
			demoted = demoted* splitName[i]*" "
		end
		strip(demoted)
		push!(capturedArray, demoted)
	  return false
	end
	return false
end

# Copy move into moveChoice if it is better
function demonBurn(destRow::Int64, destCol::Int64, temp::Int64)
	for i in 1:9







|
|
<
<
<
<
<
<
|
|







278
279
280
281
282
283
284
285
286






287
288
289
290
291
292
293
294
295
	end
	if captured.name == defKing # gamewin
		push!(capturedArray, captured.name)
		return true
	elseif captured.name == defGGen # Does not promote
		push!(capturedArray, captured.name)
		return false
	#elseif 65 <= UInt32(captured.name) <= 90
	#	captured.name += 32 # Demote captured piece.






	#	push!(capturedArray, captured.name)
	#	return false
	end
	return false
end

# Copy move into moveChoice if it is better
function demonBurn(destRow::Int64, destCol::Int64, temp::Int64)
	for i in 1:9
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
	if tempMoveChoice[1] == 1
		a = 4
		b = 5
		if dim == tDdim
			temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
			if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
				temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
			end
		elseif dim == cDim
			temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		else
			temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		end
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0







|







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
	if tempMoveChoice[1] == 1
		a = 4
		b = 5
		if dim == tDdim
			temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
			if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
				temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
			end		
		elseif dim == cDim
			temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		else
			temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		end
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
		a = 4
		b = 5
		while a != 0 && b != 0
			if dim == tDdim
				if temp == 0
					temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
				else
					temp += pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
			elseif dim == cDim
				if temp == 0
					temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
				else
					temp += pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
			else
				if temp == 0







|







356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
		a = 4
		b = 5
		while a != 0 && b != 0
			if dim == tDdim
				if temp == 0
					temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
				else
					temp += pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]	
			elseif dim == cDim
				if temp == 0
					temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
				else
					temp += pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
			else
				if temp == 0
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
	elseif tempMoveChoice[1] == 3
		a = 8
		b = 9
		while tempMoveChoice[a] == 0 && tempMoveChoice [b] == 0
			a -= 2
			a -= 2
		end
		if dim == tDdim
			temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
			if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
				temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
			end
		elseif dim == cDim
			temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		else
			temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		end
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0







|



|







408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
	elseif tempMoveChoice[1] == 3
		a = 8
		b = 9
		while tempMoveChoice[a] == 0 && tempMoveChoice [b] == 0
			a -= 2
			a -= 2
		end
		if dim == tDim
			temp = pieceValTen[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
			if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
				temp = demonBurn(tempMoveChoice[a], tempMoveChoice[b], temp)
			end		
		elseif dim == cDim
			temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		else
			temp = pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTen[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		end
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
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 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"
					update(srcRow, srcCol, newTempRow, newTempCol, option)
				end







|







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
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"
					update(srcRow, srcCol, newTempRow, newTempCol, option)
				end
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

605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end

function defGreatGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 5
			rangeJump(srcRow, srcCol, option, i)
		end
	end
end







|







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end
	
function defGreatGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 5
			rangeJump(srcRow, srcCol, option, i)
		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
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
				if chessboard[tempRow, tempCol].side == defDummy
					step(srcRow, srcCol, option, srcRow + 3*moveOption[i].row, srcCol + 3*moveOption[i].col)
				end
			end
		end
	end
end

function defWaterBuffaloMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 2 && i != 5 && i != 8
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 2 || i == 8
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col







|







816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
				if chessboard[tempRow, tempCol].side == defDummy
					step(srcRow, srcCol, option, srcRow + 3*moveOption[i].row, srcCol + 3*moveOption[i].col)
				end
			end
		end
	end
end
			
function defWaterBuffaloMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 2 && i != 5 && i != 8
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 2 || i == 8
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
				if chessboard[tempRow, tempCol].side == defDummy && ((chessboard[srcRow, srcCol].side == defWhite && i == 2) || (chessboard[srcRow, srcCol].side == defBlack && i == 8))
					step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
				end
			end
		end
	end
end

function defVerticalSoldierMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if (chessboard[srcRow, srcCol].side == defWhite && i == 2) || (chessboard[srcRow, srcCol].side == defBlack && i == 8)
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 4 || i == 6 || i == 8
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col







|







867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
				if chessboard[tempRow, tempCol].side == defDummy && ((chessboard[srcRow, srcCol].side == defWhite && i == 2) || (chessboard[srcRow, srcCol].side == defBlack && i == 8))
					step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
				end
			end
		end
	end
end
			
function defVerticalSoldierMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if (chessboard[srcRow, srcCol].side == defWhite && i == 2) || (chessboard[srcRow, srcCol].side == defBlack && i == 8)
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 4 || i == 6 || i == 8
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col
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"
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
function defDogMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if (chessboard[srcRow, srcCol].side == defWhite && (i == 2 || i == 7 || i == 9)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 1 || i == 3 || i == 8))
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

function defBlindTigerMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 5 && ((chessboard[srcRow, srcCol].side == defWhite && i != 2) || (chessboard[srcRow, srcCol].side == defBlack && i != 8))
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end







|







1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
function defDogMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if (chessboard[srcRow, srcCol].side == defWhite && (i == 2 || i == 7 || i == 9)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 1 || i == 3 || i == 8))
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end
		
function defBlindTigerMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 5 && ((chessboard[srcRow, srcCol].side == defWhite && i != 2) || (chessboard[srcRow, srcCol].side == defBlack && i != 8))
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end