Diff

Differences From Artifact [f54ab3a34f]:

To Artifact [473991c03e]:


295
296
297
298
299
300
301

302
303
304
305
306






307
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
346

347
348
349
350

351
352
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
385
295
296
297
298
299
300
301
302





303
304
305
306
307
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
346
347

348
349

350
351

352
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
385
386
387
388
389
390
391

392
393

394
395
396
397
398
399
400
401







+
-
-
-
-
-
+
+
+
+
+
+














+




+











+
+
+

+
+
+

-
+

-
+

-
+

-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
+
-
-
+













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




-
+

-
+







	end
	return false
end

# Copy move into moveChoice if it is better
function demonBurn(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64, temp::Int64)
	for i in 1:9
		if i != 5
		tempRow = destRow + moveOption[i].row
		tempCol = destCol + moveOption[i].col
		if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
			if chessboard[tempRow, tempCol].side != defDummy && chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol].side
				temp += pieceValTenjiku[chessboard[tempRow, tempCol].name]
			tempRow = destRow + moveOption[i].row
			tempCol = destCol + moveOption[i].col
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				if chessboard[tempRow, tempCol].side != defDummy && chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol].side
					temp += pieceValTenjiku[chessboard[tempRow, tempCol].name]
				end
			end
		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
	local tempChessboard
	temp = -1
	if demonBurnVal != 0
		temp = demonBurnVal
	end
	#println(demonBurnVal)
	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 chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
		tempChessboard = deepcopy(chessboard)
	end
	if tempMoveChoice[1] == 1 || tempMoveChoice[1] == 3
		if temp == -1
			temp = 0
		end
		if dim == tDim
			temp = pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]		
			temp = 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]
			temp = 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]
			temp = 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
				if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == tDim
		if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defFireDemon
					temp += 600
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == cDim
					temp += 91
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing
			testMove(tempMoveChoice[2], tempMoveChoice[3], tempMoveChoice[a], tempMoveChoice[b])
					temp += 68
				elseif dim == tDim
					temp += 500
				else
					temp += 50
				end
		end
			end
		elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].side == defWhite
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].BAttack == 0
				if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == tDim
					temp += 600
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == cDim
					temp += 91
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing
					temp += 68
				elseif dim == tDim
					temp += 500
				else
					temp += 50
				end
			end
		elseif chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defBlack
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
				if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == tDim
					temp += 600
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == cDim
					temp += 91
				elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing
					temp += 68
				elseif dim == tDim
					temp += 500
				else
					temp += 50
				end
			end
		end
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].name == defFireDemon
			chessboard = tempChessboard # restore
		end
	elseif tempMoveChoice[1] == 2
		a = 4
		b = 5
		local tempChessboard = deepcopy(chessboard)
		tempChessboard = deepcopy(chessboard)
		while tempMoveChoice[a] != 0 && tempMoveChoice[b] != 0
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]] != defDummy && chessboard[tempMoveChoice[2], tempMoveChoice[3]].side != chessboard[tempMoveChoice[a], tempMoveChoice[b]].side
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side != defDummy && chessboard[tempMoveChoice[2], tempMoveChoice[3]].side != chessboard[tempMoveChoice[a], tempMoveChoice[b]].side
				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
395
396
397
398
399
400
401
402

403
404
405
406
407
408
409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
411
412
413
414
415
416
417

418
419
420
421
422
423
424
425
426
427
428
429
430
431

432
433
434
435
436
437
438
439







-
+













-
+







						temp += pieceVal[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name]
					end
				end
			end
			testMove(tempMoveChoice[a-2], tempMoveChoice[b-2], tempMoveChoice[a], tempMoveChoice[b])
			if tempMoveChoice[a + 2] == 0 && tempMoveChoice[b + 2] == 0
				if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
					if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
					if chessboard[tempMoveChoice[a], tempMoveChoice[b]].BAttack == 0
						if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == tDim
							temp += 600
						elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == cDim
							temp += 91
						elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing
							temp += 68
						elseif dim == tDim
							temp += 500
						else
							temp += 50
						end
					end
				elseif chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defBlack
					if chessboard[tempMoveChoice[a], tempMoveChoice[b]].BAttack == 0
					if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
						if chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == tDim
							temp += 600
						elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing && dim == cDim
							temp += 91
						elseif chessboard[tempMoveChoice[2], tempMoveChoice[3]].name == defKing
							temp += 68
						elseif dim == tDim
575
576
577
578
579
580
581
582

583
584
585
586
587
588
589
591
592
593
594
595
596
597

598
599
600
601
602
603
604
605







-
+







		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[srcRow, srcCol].side != chessboard[tempRow, tempCol] && chessboard[tempRow, tempCol].side != defDummy
		if chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol].side && 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
603
604
605
606
607
608
609
610
611
612
613
614
615
616







617
618
619
620
621
622
623
619
620
621
622
623
624
625







626
627
628
629
630
631
632
633
634
635
636
637
638
639







-
-
-
-
-
-
-
+
+
+
+
+
+
+







		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
		if option == "capture"
			if (chessboard[srcRow, srcCol].side != chessboard[newTempRow, newTempCol].side && chessboard[newTempRow, newTempCol].side != defDummy) || temp != 0
				tempMoveChoice = [1, srcRow, srcCol, newTempRow, newTempCol, 0, 0, 0, 0]
				capture(tempMoveChoice, temp)
			end
		end
		if chessboard[newTempRow, newTempCol].side != defDummy
			break
		end
	end
end

function defKingMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
1389
1390
1391
1392
1393
1394
1395
1396
1397


1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1405
1406
1407
1408
1409
1410
1411


1412
1413







1414
1415
1416
1417
1418
1419







-
-
+
+
-
-
-
-
-
-
-






	else
		return false
	end
	return false
end

createBoard()
add(8, 8, "lion", "Bl")
add(7, 7, "pawn", "Bl")
add(8, 8, "fire demon", "Bl")
add(16, 16, "rook", "Wh")
add(7, 8, "pawn", "Bl")
add(7, 9, "pawn", "Bl")
add(8, 7, "pawn", "Bl")
add(8, 9, "pawn", "Bl")
add(9, 7, "pawn", "Bl")
add(9, 8, "pawn", "Bl")
add(9, 9, "pawn", "Bl")
printBoard()
currTurn = "Bl"
moveFunctions("capture")
moveFunctions("update")
strength = -1
printBoardBAttack()