moveupdate.jl at [ccbbd60c90]

File moveupdate.jl artifact 943742159e part of check-in ccbbd60c90


using Tk

using SQLite
ARGS= ["patsChuTest3.db"]# used for easy testing
fileName = SQLite.DB(ARGS[1])

######
#DECLARATIONS - DICTIONARIES
######

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{String, Int64}("_" => 0, "lion" => 20, "queen" => 12, "dragon king" => 8, "soaring eagle" => 11, "dragon horse" => 7, "horned falcon" => 10, "rook" => 6, "bishop" => 5, "vertical mover" => 4, "flying ox" => 8, "side mover" => 4, "free boar" => 8, "king" => 50, "phoenix" => 3, "kirin" => 3, "reverse chariot" => 3, "whale" => 5 , "lance" => 3, "white horse" => 7, "drunk elephant" => 3, "gold general" => 3, "ferocious leopard" => 3, "blind tiger" => 3, "flying stag" => 6, "silver general" => 2, "copper general" => 2, "go between" => 1, "pawn" => 1)

global pieceVal = Dict{String,Int64}("_" => 0, "pawn"=>1, "pawn promoted" =>2, "lance" =>4, "lance promomted" =>5, "knight" =>6,
"knight promoted" =>7, "silver general" =>7,"silver general promoted" =>8, "gold general" =>8, "bishop" =>11, "rook" =>13, "bishop promoted" =>15, "rook promoted" =>17, "king"=>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" => "king", "ferocious leopard promoted" => "bishop",
  "go between promomted" => "drunk elephant", "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"  )

######
#DECLARATIONS - GLOBAL VARIABLES
######

global defEmpty = "_"
global defBishop = "bishop"
global defBishopGeneral = "bishop general"
global defBlindTiger = "blind tiger"
global defCopperGeneral = "copper general"
global defChariotSoldier = "chariot soldier"
global defDog = "dog"
global defDrunkElephant = "drunk elephant"
global defDragonHorse = "dragon horse"
global defDragonKing = "dragon king"
global defFerociousLeopard = "ferocious leopard"
global defFlyingOx = "flying ox"
global defFlyingStag = "flying stag"
global defFireDemon = "fire demon"
global defFreeBoar = "free boar"
global defFreeEagle = "free eagle"
global defGoBetween = "go between"
global defGoldGeneral = "gold general"
global defGreatGeneral = "great general"
global defHeavenlyTetrarch = "heavenly tetrarch"
global defHornedFalcon = "horned falcon"
global defIronGeneral = "iron general"
global defKing = "king"
global defPrince = "prince"
global defKirin = "kirin"
global defLance = "lance"
global defLionHawk = "lion hawk"
global defLion = "lion"
global defMultiGeneral = "multi general"
global defKnight = "knight"
global defPawn = "pawn"
global defPhoenix = "phoenix"
global defQueen = "queen"
global defRook = "rook"
global defReverseChariot = "reverse chariot"
global defRookGeneral = "rook general"
global defSilverGeneral = "silver general"
global defSoaringEagle = "soaring eagle"
global defSideMover = "side mover"
global defSideSoldier = "side soldier"
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 dim = 16
global tDim = 16
global cDim = 12
global sDim = 9
global mDim = 5

global tPrZoneB = 12
global cPrZoneB = 9
global sPrZoneB = 7
global mPrZoneB = 5

global tPrZoneW = 5
global cPrZoneW = 4
global sPrZoneW = 3
global mPrZoneW = 1



global moveChoice = Array{Int64}(8)
global validateMoveChoice = Array{Int64}(8)
global strength = -1
global whitePrison = String[]
global blackPrison = String[]
global chessboard
global tempChessboard

global currTurn = defBlack
global pieceImgWhite = Image("EmptyTile.gif")
global pieceImgBlack = Image("EmptyTileBlack.gif")
global royaltyTaken = false
global remainingRoyaltyBlack = 1
global remainingRoyaltyWhite = 1

######
#DECLARATIONS - MOVE CHOICES
######

type moveOffset
	row::Int64
	col::Int64
end

moveOption = Array{moveOffset}(17)

moveOption[1] = moveOffset(-1, -1)
moveOption[2] = moveOffset(-1, 0)
moveOption[3] = moveOffset(-1, 1)
moveOption[4] = moveOffset(0, -1)
moveOption[5] = moveOffset(0, 0)
moveOption[6] = moveOffset(0, 1)
moveOption[7] = moveOffset(1, -1)
moveOption[8] = moveOffset(1, 0)
moveOption[9] = moveOffset(1, 1)
moveOption[10] = moveOffset(-2, -1)
moveOption[11] = moveOffset(-2, 1)
moveOption[12] = moveOffset(2, -1)
moveOption[13] = moveOffset(2, 1)
moveOption[14] = moveOffset(-1, -2)
moveOption[15] = moveOffset(-1, 2)
moveOption[16] = moveOffset(1, -2)
moveOption[17] = moveOffset(1, 2)

type piece
	#display::String # FOR TESTING
	name::String
	side::AbstractString
	BAttack::Int
	WAttack::Int
	promote::Bool
end

######
# MAIN FUNCTION
######

function coordinates(index::Int64)
	x = index % dim
	y = (index - x)/dim
	if x == 0
		x = dim
	end
  	return x, y
end


function moveFunctions(option::String)
	global chessboard
	if option == "update"
		for i in 1:dim
			for j in 1:dim
				chessboard[i, j].WAttack = 0
				chessboard[i, j].BAttack = 0
			end
		end
	end
	if option != "check" && option != "random" && option != "update single"
		for i in 1:dim
			for j in 1:dim
				if chessboard[i, j].side == currTurn
					if chessboard[i, j].name == defBishop
						defBishopMove(i, j, option)
					elseif chessboard[i, j].name == defBishopGeneral
						defBishopGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defBlindTiger
						defBlindTigerMove(i, j, option)
					elseif chessboard[i, j].name == defCopperGeneral
						defCopperGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defChariotSoldier
						defChariotSoldierMove(i, j, option)
					elseif chessboard[i, j].name == defDog
						defDogMove(i, j, option)
					elseif chessboard[i, j].name == defDrunkElephant
						defDrunkElephantrMove(i, j, option)
					elseif chessboard[i, j].name == defDragonHorse
						defDragonHorseMove(i, j, option)
					elseif chessboard[i, j].name == defDragonKing
						defDragonKingMove(i, j, option)
					elseif chessboard[i, j].name == defFerociousLeopard
						defFerociousLeopardMove(i, j, option)
					elseif chessboard[i, j].name == defFireDemon
						defFireDemonMove(i, j, option)
					elseif chessboard[i, j].name == defFlyingOx
						defFlyingOxMove(i, j, option)
					elseif chessboard[i, j].name == defFlyingStag
						defFlyingStagMove(i, j, option)
					elseif chessboard[i, j].name == defFreeBoar
						defFreeBoarMove(i, j, option)
					elseif chessboard[i, j].name == defFreeEagle
						defFreeEagleMove(i, j, option)
					elseif chessboard[i, j].name == defGoldGeneral
						defGoldGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defGreatGeneral
						defGreatGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defHeavenlyTetrarch
						defHeavenlyTetrarchMove(i, j, option)
					elseif chessboard[i, j].name == defHornedFalcon
						defHornedFalconMove(i, j, option)
					elseif chessboard[i, j].name == defIronGeneral
						defIronGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defKing
						defKingMove(i, j, option)
					elseif chessboard[i, j].name == defKirin
						defKirinMove(i, j, option)
					elseif chessboard[i, j].name == defLance
						defLanceMove(i, j, option)
					elseif chessboard[i, j].name == defLionHawk
						defLionHawkMove(i, j, option)
					elseif chessboard[i, j].name == defLion
						defLionMove(i, j, option)
					elseif chessboard[i, j].name == defMultiGeneral
						defMultiGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defKnight
						defKnightMove(i, j, option)
					elseif chessboard[i, j].name == defPawn
						defPawnMove(i, j, option)
					elseif chessboard[i, j].name == defPhoenix
						defPhoenixMove(i, j, option)
					elseif chessboard[i, j].name == defQueen
						defQueenMove(i, j, option)
					elseif chessboard[i, j].name == defRook
						defRookMove(i, j, option)
					elseif chessboard[i, j].name == defReverseChariot
						defReverseChariotMove(i, j, option)
					elseif chessboard[i, j].name == defRookGeneral
						defRookGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defSilverGeneral
						defGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defSoaringEagle
						defSoaringEagleMove(i, j, option)
					elseif chessboard[i, j].name == defSideMover
						defSideMoverMove(i, j, option)
					elseif chessboard[i, j].name == defSideSoldier
						defSideSoldierMove(i, j, option)
					elseif chessboard[i, j].name == defViceGeneral
						defViceGeneralMove(i, j, option)
					elseif chessboard[i, j].name == defVerticalMover
						defVerticalMoverMove(i, j, option)
					elseif chessboard[i, j].name == defVerticalSoldier
						defVerticalSoldierMove(i, j, option)
					elseif chessboard[i, j].name == defWaterBuffalo
						defWaterBuffaloMove(i, j, option)
					elseif chessboard[i, j].name == defWhale
						defWhaleMove(i, j, option)
					elseif chessboard[i, j].name == defWhiteHorse
						defWhiteHorseMove(i, j, option)
					end
				end
			end
		end
	elseif option == "check" || option == "random" || option == "pressure"
		saveOption = option
		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
			defBlindTigerMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defCopperGeneral
			defCopperGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defChariotSoldier
			defChariotSoldierMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defDog
			defDogMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defDrunkElephant
			defDrunkElephantrMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defDragonHorse
			defDragonHorseMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defDragonKing
			defDragonKingMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFerociousLeopard
			defFerociousLeopardMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFireDemon
			defFireDemonMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFlyingOx
			defFlyingOxMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFlyingStag
			defFlyingStagMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFreeBoar
			defFreeBoarMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFreeEagle
			defFreeEagleMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defGoldGeneral
			defGoldGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defGreatGeneral
			defGreatGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHeavenlyTetrarch
			defHeavenlyTetrarchMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHornedFalcon
			defHornedFalconMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defIronGeneral
			defIronGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defKing
			defKingMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defKirin
			defKirinMove(validateMoveChoice[1], validateMoveChoice[2], option)

		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLance
			defLanceMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLionHawk
			defLionHawkMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLion
			defLionMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defMultiGeneral
			defMultiGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defKnight
			defKnightMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defPawn
			defPawnMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defPhoenix
			defPhoenixMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defQueen
			defQueenMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defRook
			defRookMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defReverseChariot
			defReverseChariotMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defRookGeneral
			defRookGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSilverGeneral
			defGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSoaringEagle
			defSoaringEagleMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSideMover
			defSideMoverMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSideSoldier
			defSideSoldierMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defViceGeneral
			defViceGeneralMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defVerticalMover
			defVerticalMoverMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defVerticalSoldier
			defVerticalSoldierMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defWaterBuffalo
			defWaterBuffaloMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defWhale
			defWhaleMove(validateMoveChoice[1], validateMoveChoice[2], option)
		elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defWhiteHorse
			defWhiteHorseMove(validateMoveChoice[1], validateMoveChoice[2], option)
		end
		if saveOption == "check"
		i = 3
		while (validateMoveChoice[i] != 0 && validateMoveChoice[i + 1] != 0) && i <=7
			if validateMoveChoice[5] != 0 && validateMoveChoice[6] != 0 && validateMoveChoice[7] == 0 && validateMoveChoice[8] == 0# double capture exceptions
				tempRow = validateMoveChoice[3] - validateMoveChoice[1]
				tempCol = validateMoveChoice[4] - validateMoveChoice[2]
				tempRow2 = validateMoveChoice[5] - validateMoveChoice[3]
				tempCol2 = validateMoveChoice[6] - validateMoveChoice[4]
				if (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHornedFalcon)||
          (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSoaringEagle)||
          (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHeavenlyTetrarch)||
          (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFreeEagle)||
          (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLionHawk)||
          (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLion)
					if (validateMoveChoice[5] == validateMoveChoice[1]) && (validateMoveChoice[6] == validateMoveChoice[2]) # Check igui. Returns to same spot
						if (chessboard[validateMoveChoice[1], validateMoveChoice[2]].side != chessboard[validateMoveChoice[3], validateMoveChoice[4]].side)
							if (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLionHawk)||
                (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLion)||
                (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHeavenlyTetrarch)
								if (tempRow <= 1 && tempRow >= -1) && (tempCol <= 1 && tempCol >= -1)
									chessboard = saveChessboard
									return true
								end
							elseif ((chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHornedFalcon) && tempCol == 0)||
              ((chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSoaringEagle) && (tempCol == 1 || tempCol == -1))
								if chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defWhite && tempRow == -1||
                  chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defBlack && tempRow == 1
									chessboard = saveChessboard
									return true
								end
							elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFreeEagle
								if (tempRow == 1 || tempRow == -1) && (tempCol == 1 || tempCol == -1)
									chessboard = saveChessboard
									return true
								end
							end
						end
					elseif (chessboard[validateMoveChoice[1], validateMoveChoice[2]].side != chessboard[validateMoveChoice[3], validateMoveChoice[4]].side)&&  # Check if both squares valid
          (chessboard[validateMoveChoice[3], validateMoveChoice[4]].side != chessboard[validateMoveChoice[5], validateMoveChoice[6]].side)
						if ((chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defHornedFalcon) && tempCol == 0)||
              ((chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defSoaringEagle) && (tempCol == 1 || tempCol == -1))
							if tempRow == tempRow2 && tempCol == tempCol2
								if (chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defWhite && tempRow == -1)||
                  (chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defBlack && tempRow == 1)
									chessboard = saveChessboard
									return true
								end
							end
						elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defFreeEagle
							if (tempRow == 1 || tempRow == -1) && (tempCol == 1 || tempCol == -1) && (tempRow2 == 1 || tempRow2 == -1) &&(tempCol2 == 1 || tempCol2 == -1)
								chessboard = saveChessboard
								return true
							end
						elseif (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLionHawk)||
              (chessboard[validateMoveChoice[1], validateMoveChoice[2]].name == defLion)
							if (tempRow <= 1 && tempRow >= -1) && (tempCol <= 1 && tempCol >= -1) && (tempRow2 <= 1 && tempRow2 >= -1) &&(tempCol2 <= 1 && tempCol2 >= -1)
								chessboard = saveChessboard
								return true
							end
						end
					end
				end
			elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defBlack
				if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].BAttack == 0
					chessboard = saveChessboard
					return false
				end
				if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].side == chessboard[validateMoveChoice[1], validateMoveChoice[2]].side
					chessboard = saveChessboard
					return false
				end
			elseif chessboard[validateMoveChoice[1], validateMoveChoice[2]].side == defWhite
				if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].WAttack == 0
					chessboard = saveChessboard
					return false
				end
				if chessboard[validateMoveChoice[i], validateMoveChoice[i + 1]].side == chessboard[validateMoveChoice[1], validateMoveChoice[2]].side
					chessboard = saveChessboard
					return false
				end
			end
			i += 2
		end
		end 
		if saveOption == "pressure"
			for i in  1:dim
				for j in 1:dim
					if currTurn == defBlack && chessboard[i, j].BAttack == 1 && saveChessboard[i, j].WAttack == 0
							
					elseif currTurn == defWhite && chessboard[i, j].WAttack == 1 && saveChessboard[i, j].WAttack == 0
		end
		chessboard = saveChessboard
	end
end




######
# FUNCTIONS TO MODIFY BOARD
######

function move()
	global moveChoice
	global strength
	moveChoice = [0, 0, 0, 0, 0, 0, 0, 0]
	strength = -1
	moveFunctions("capture")
	if moveChoice[1] == 0
		moveFunctions("random")
	end

end

function random()
	totalSquares = dim * dim
	while true
		i = rand(1:totalSquares)
		if chessboard[i] == currTurn
			moveChoice = [0, 0, 0, 0, 0, 0, 0, 0]
			moveFunction("random")
			if moveChoice[1] != 0
				return
			end
		end
	end
end


function updatePiece(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64, option::String)
	global tempChessboard
	global chessboard
	if option == "special update"
		if chessboard[srcRow, srcCol].side == defWhite
			tempChessboard[destRow, destCol].WAttack += 1
		elseif chessboard[srcRow, srcCol].side == defBlack
			tempChessboard[destRow, destCol].BAttack += 1
		end
	elseif option == "update"
		if chessboard[srcRow, srcCol].side == defWhite
			chessboard[destRow, destCol].WAttack += 1
		elseif chessboard[srcRow, srcCol].side == defBlack
			chessboard[destRow, destCol].BAttack += 1
		end
	end
end

function movePiece(srcRow, srcCol, destRow, destCol)
	#println("PATQA:: movePiece args: $srcRow $srcCol $destRow $destCol")
	pieceToMove = chessboard[srcRow, srcCol]
	pieceAttacked = chessboard[destRow, destCol]
	gamewin = false
	# Check if the pieceAttacked is opposing team
	if pieceToMove.side != pieceAttacked.side && pieceAttacked.side != defDummy && pieceAttacked.name != defEmpty
		gamewin = capturePiece(destRow, destCol)
	end
	setTile(destRow, destCol, pieceToMove.name, pieceToMove.side)
	clearTile(srcRow, srcCol)
	return gamewin
end

function capturePiece(destRow::Int64, destCol::Int64)
	captured = chessboard[destRow, destCol]
	if captured.side == defBlack
		capturedArray = whitePrison # Record which side the piece is on being captured, prison is the colour of where drop can check from
	elseif captured.side == defWhite # Use splice!(array, object) splice returns the object that is removed
		capturedArray = blackPrison
	end
	if captured.name == defKing # gamewin
		push!(capturedArray, captured.name)
		return true
	elseif captured.name == defGoldGeneral # Does not promote
		push!(capturedArray, captured.name)
		return false
	else
    if contains(captured.name,"promoted")
      splitName = rsplit(name," ";limit = 2)
      captured.name = splitName[1]
    end
    push!(capturedArray, captured.name)
    return false
	end
	return false
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 saveChessboard
	temp = -1
	if demonBurnVal != 0
		temp = demonBurnVal
	end
	#println(demonBurnVal)
	if tempMoveChoice[1] == 1 || tempMoveChoice[1] == 4
		a = 4
		b = 5
	elseif tempMoveChoice[1] == 3 || tempMoveChoice[1] == 5
		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
		saveChessboard = deepcopy(chessboard)
	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 == 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[2], tempMoveChoice[3]].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
	elseif tempMoveChoice[1] == 2
		a = 4
		b = 5
		saveChessboard = deepcopy(chessboard)
		while tempMoveChoice[a] != 0 && tempMoveChoice[b] != 0
			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
					if temp == -1
						temp = pieceValChu[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
					else
						temp += pieceValChu[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]].BAttack == 0
						if 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 dim == tDim
							temp += 500
						else
							temp += 50
						end
					end
				end
			end
			a += 2
			b += 2
		end
		chessboard = saveChessboard # restore
	elseif tempMoveChoice[1] == 4 || tempMoveChoice[1] == 5
		if temp == -1
			temp = 0
		end
		temp = temp + pieceValTenjiku[chessboard[tempMoveChoice[a], tempMoveChoice[b]].name] - pieceValTenjiku[chessboard[tempMoveChoice[2], tempMoveChoice[3]].name]
		testMove(tempMoveChoice[2], tempMoveChoice[3], tempMoveChoice[a], tempMoveChoice[b])
		if chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defWhite # check if attack is safe
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].BAttack == 0
				temp += 500
			end
		elseif chessboard[tempMoveChoice[a], tempMoveChoice[b]].side == defBlack
			if chessboard[tempMoveChoice[a], tempMoveChoice[b]].WAttack == 0
				temp += 500
			end
		end
		chessboard = saveChessboard # restore
	end
	if temp > strength
		storeMoveChoice = [tempMoveChoice[2], tempMoveChoice[3], tempMoveChoice[4], tempMoveChoice[5], tempMoveChoice[6], tempMoveChoice[7], tempMoveChoice[8], tempMoveChoice[9]]
		strength = temp
		moveChoice = deepcopy(storeMoveChoice)
		println(strength)
		println(moveChoice)
	end
end

function createBoard()
	global chessboard
	grid = [piece(defEmpty, defDummy, 0, 0, false)]
	temp = deepcopy(grid)
	for i in 1:dim - 1
		temp = vcat(temp, deepcopy(grid))
	end
	chessboard = deepcopy(temp)
	for i in 1:dim -1
		chessboard = hcat(chessboard, deepcopy(temp))
	end
end

function add(srcRow::Int64, srcCol::Int64, piecetype::String, colour::String)
	chessboard[srcRow, srcCol].name = piecetype
	chessboard[srcRow, srcCol].side = colour
end

function delete(srcRow::Int64, srcCol::Int64)
	chessboard[srcRow,srcCol].name = defEmpty
	chessboard[srcRow,srcCol].side = defDummy
end

function testMove(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64) # copies move, runs update, modifies global chessboard
	global chessboard
	add(destRow, destCol, chessboard[srcRow, srcCol].name, chessboard[srcRow, srcCol].side)
	if chessboard[destRow, destCol].name == defFireDemon
		demonBurn(srcRow, srcCol, destRow, destCol, 0, "burn")
	end
	delete(srcRow, srcCol)
	moveFunctions("update")
end

######
# FIRE DEMON ONLY
######

function demonBurn(srcRow::Int64, srcCol::Int64, destRow::Int64, destCol::Int64, temp::Int64, option::String)
	global chessboard
	global tempChessboard
	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 option == "demon update"
					updatePiece(srcRow, srcCol, tempRow, tempCol, "special update")
				end
				if option == "burn"
					if chessboard[tempRow, tempCol].side != chessboard[destRow, destCol].side && chessboard[tempRow, tempCol].side != defDummy
						delete(tempRow, tempCol)
					end
				end
				if option == "calculate"
					if chessboard[tempRow, tempCol].side != defDummy && chessboard[srcRow, srcCol].side != chessboard[tempRow, tempCol].side
						temp += pieceValTenjiku[chessboard[tempRow, tempCol].name]
					end
				end
			end
		end
	end
	if option == "calculate"
		return temp
	end
end

######
# MOVE TYPES
######

function step(srcRow::Int64, srcCol::Int64, option::String, destRow::Int64, destCol::Int64)
	global moveChoice
	if destRow <= dim && destRow >= 1 && destCol <= dim && destCol >= 1
		if option == "update" || option == "special update"
			updatePiece(srcRow, srcCol, destRow, destCol, option)
		end
    if option == "GUI"
      indicateMoveOption(destRow, destCol)
    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
		if option == "random"
			if chessboard[srcRow, srcCol].side == defBlack
				if chessboard[destRow, destCol].WAttack == 0
					moveChoice = [srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
				end
			elseif chessboard[srcRow, srcCol].side == defWhite
				if chessboard[destRow, destCol].BAttack == 0
					moveChoice = [srcRow, srcCol, destRow, destCol, 0, 0, 0, 0]
				end
			end
		end
	end
end

function stepMultiple(srcRow::Int64, srcCol::Int64, option::String, tempRow::Int64, tempCol::Int64, jumps::Int64, tempMoveChoice)
	global tempChessboard
	a = 0
	b = 0
	if jumps == 0
		return
	end
	saveMoveChoice = deepcopy(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 = deepcopy(saveMoveChoice)
			newTempRow = tempRow + moveOption[i].row
			newTempCol = tempCol + moveOption[i].col
			if newTempRow <= dim && newTempRow >= 1 && newTempCol <= dim && newTempCol >= 1
				if option == "special update"
					updatePiece(srcRow, srcCol, newTempRow, newTempCol, option)
				elseif option == "demon update"
					demonBurn(srcRow, srcCol, newTempRow, newTempCol, 0, option)
				end
        if option == "GUI"
					indicateMoveOption(newTempRow, newTempCol)
				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
					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
	a = 0
	b = 0
	if jumps == 0
		return
	end
	saveMoveChoice = deepcopy(tempMoveChoice)
	if jumps == 2
		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"
				updatePiece(srcRow, srcCol, newTempRow, newTempCol, option)
			end
      if option == "GUI"
        indicateMoveOption(newTempRow, newTempCol)
      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"
					updatePiece(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

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"
			updatePiece(srcRow, srcCol, tempRow, tempCol, option)
		end
    if option == "GUI"
      indicateMoveOption(tempRow, tempCol)
    end
		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 option == "random"
			if chessboard[srcRow, srcCol].side == defBlack
				if chessboard[tempRow, tempCol].WAttack == 0
					moveChoice = [srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
				end
			elseif chessboard[srcRow, srcCol].side == defWhite
				if chessboard[destRow, destCol].BAttack == 0
					moveChoice = [srcRow, srcCol, tempRow, tempCol, 0, 0, 0, 0]
				end
			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)
	local tempMoveChoice
	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"
			updatePiece(srcRow, srcCol, newTempRow, newTempCol, option)
		elseif option == "demon update"
			demonBurn(srcRow, srcCol, newTempRow, newTempCol, 0, option)
		end
    if option == "GUI"
      indicateMoveOption(newTempRow, newTempCol)
    end
		temp = 0
		if option == "capture"
			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
				if chessboard[srcRow, srcCol].name == defFireDemon
					tempMoveChoice = [4, srcRow, srcCol, newTempRow, newTempCol, 0, 0, 0, 0]
				else
					tempMoveChoice = [1, srcRow, srcCol, newTempRow, newTempCol, 0, 0, 0, 0]
				end
				capture(tempMoveChoice, temp)
			end
		end
		if option == "random"
			if chessboard[srcRow, srcCol].side == defBlack
				if chessboard[destRow, destCol].WAttack == 0
					moveChoice = [srcRow, srcCol, newTempRow, newTempCol, 0, 0, 0, 0]
				end
			elseif chessboard[srcRow, srcCol].side == defWhite
				if chessboard[destRow, destCol].BAttack == 0
					moveChoice = [srcRow, srcCol, newTempRow, newTempCol, 0, 0, 0, 0]
				end
			end
		end
		if chessboard[newTempRow, newTempCol].side != defDummy
			break
		end
	end
end

######
# PROMOTiONS
######

function prPromote(destRow::Int64, destCol::Int64)
  chessboard[destRow,destCol].name = chessboard[destRow,destCol].name *" promoted"
  chessboard[destRow,destCol].promote = true
end

function canPromote(destRow::Int64, destCol::Int64)
  targetPie = chessboard[destRow,destCol]
  if !targetPie.promote #not promoted
    if dim == tDim && targetPie.name != defFireDemon && targetPie.name != defFreeEagle &&
      targetPie.name != defGreatGeneral && targetPie.name != defKing && targetPie.name != defLionHawk &&
      targetPie.name != defViceGeneral
      if targetPie.side == defWhite
        if destRow <= tPrZoneW
          return true
        end
      elseif targetPie.side == defBlack
        if destRow >= tPrZoneB
          return true
        end
      else
        return false
      end
    elseif dim == cDim && targetPie.name != defKing && targetPie.name != defQueen && targetPie.name != defLion
      if targetPie.side == defWhite
        if destRow <= cPrZoneW
          return true
        end
      elseif targetPie.side == defBlack
        if destRow >= cPrZoneB
          return true
        end
      else
        return false
      end
    elseif dim == sDim && get(prStandard,targetPie.name,"none") != "none"
      if targetPie.side == defWhite
        if destRow <= sPrZoneW
          return true
        end
      elseif targetPie.side == defBlack
        if destRow >= sPrZoneB
          return true
        end
      else
        return false
      end
    elseif dim == mDim && get(prStandard,targetPie.name,"none") != "none"
      if targetPie.side == defWhite
        if destRow <= mPrZoneW
          return true
        end
      elseif targetPie.side == defBlack
        if destRow >= mPrZoneB
          return true
        end
      else
        return false
      end
    end
  end
	return false
end
#

function autoPromote(destRow::Int64, destCol::Int64)  # Run function after pawn, lance or knight move. Check if auto promote.
	if chessboard[destRow, destCol].name == defPawn || chessboard[destRow, destCol].name == defLance
		if chessboard[destRow, destCol].side == defWhite
			if destRow == 1
			  prPromote(destRow, destCol)
				return true
			end
		elseif chessboard[destRow, destCol].side == defBlack
			if destRow == dim
				prPromote(destRow, destCol)
				return true
			end
		else
			return false
		end
	elseif dim != cDim && chessboard[destRow, destCol].name == defKnight
		if chessboard[destRow, destCol].side == defWhite
			if destRow <= 2
				prPromote(destRow, destCol)
				return true
			end
		elseif chessboard[destRow, destCol].side == defBlack
			if destRow >= dim - 1
				prPromote(destRow, destCol)
				return true
			end
		else
			return false
		end
	else
		return false
	end
	return false
end

######
# PIECE MOVES
######

function defKingMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 5
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

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

function defViceGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update"
		option = "special 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
	for i in 1:9
		if i == 1 || i == 3 || i == 7 || i == 9
			rangeJump(srcRow, srcCol, option, i)
		end
	end
	tempMoveChoice = [3, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
	stepMultiple(srcRow, srcCol, option, srcRow, srcCol, 3, tempMoveChoice)
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				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

function defBishopGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 1 || i == 3 || i == 7 || i == 9
			rangeJump(srcRow, srcCol, option, i)
		end
	end
end

function defRookGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 4 || i == 6 || i == 8
			rangeJump(srcRow, srcCol, option, i)
		end
	end
end

function defHornedFalconMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update"
		option = "special 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
	for i in 1:9
		if i != 5 && ((chessboard[srcRow, srcCol].side == defWhite && i != 2) || (chessboard[srcRow, srcCol].side == defBlack && i != 8))
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif (chessboard[srcRow, srcCol].side == defWhite && i == 2) || (chessboard[srcRow, srcCol].side == defBlack && i == 8)
			tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
			stepMultipleLinear(srcRow, srcCol, option, srcRow, srcCol, 2, i, tempMoveChoice)
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		end
	end
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end

function defSoaringEagleMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update"
		option = "special 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
	for i in 1:9
		if i != 5 && ((chessboard[srcRow, srcCol].side == defWhite && i != 1 && i != 3) || (chessboard[srcRow, srcCol].side == defBlack && i != 7 && i != 9))
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif (chessboard[srcRow, srcCol].side == defWhite && (i == 1 || i == 3)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 7 || i == 9))
			tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
			stepMultipleLinear(srcRow, srcCol, option, srcRow, srcCol, 2, i, tempMoveChoice)
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		end
	end
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end

function defDragonHorseMove(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)
		elseif i == 2 || i == 4 || i == 6 || i == 8
			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, option, srcRow, srcCol, 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
		if i != 4 && i != 5 && i != 6
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

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

function defPawnMove(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)
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

function defGoBetweenMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 8
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

function defFireDemonMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update" || option == "capture"
		if option == "update"
			option = "demon update"
		end
		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
	for i in 1:9
		if i != 2 && i != 5 && i != 8
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
	tempMoveChoice = [5, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
	stepMultiple(srcRow, srcCol, option, srcRow, srcCol, 3, tempMoveChoice)
	if option == "demon update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end

function defHeavenlyTetrarchMove(srcRow::Int64, srcCol::Int64, option::String) # Need Exceptions
	for i in 1:9
		if i != 5
			tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
			stepMultipleLinear(srcRow, srcCol, option, srcRow, srcCol, 2, i, tempMoveChoice)
		end
		if i != 4 && i != 5 && i != 6
			range(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col, i)
		elseif i == 4 || i == 6
			tempRow = srcRow + 2*moveOption[i].row
			tempCol = srcCol + 2*moveOption[i].col
			step(srcRow, srcCol, option, tempRow, tempCol)
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				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
			step(srcRow, srcCol, option, tempRow, tempCol)
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				if chessboard[tempRow, tempCol].side == defDummy
					step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
				end
			end
		end
	end
end

function defChariotSoldierMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 4 && i != 5 && i != 6
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 4 || i == 6
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col
			step(srcRow, srcCol, option, tempRow, tempCol)
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				if chessboard[tempRow, tempCol].side == defDummy
					step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
				end
			end
		end
	end
end

function defSideSoldierMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 4 || i == 6
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 2 || i == 8
			tempRow = srcRow + moveOption[i].row
			tempCol = srcCol + moveOption[i].col
			step(srcRow, srcCol, option, tempRow, tempCol)
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				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
			step(srcRow, srcCol, option, tempRow, tempCol)
			if tempRow <= dim && tempRow >= 1 && tempCol <= dim && tempCol >= 1
				if chessboard[tempRow, tempCol].side == defDummy && (i == 4 || i == 6)
					step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
				end
			end
		end
	end
end

function defKnightMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 10:13
		if (chessboard[srcRow, srcCol].side == defWhite && (i == 10 || i == 11)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 12 || i == 13))
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

function defIronGeneralMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		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"
		option = "special 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
	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
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end



function defLionHawkMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update"
		option = "special 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
	tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
	stepMultiple(srcRow, srcCol, option, srcRow, srcCol, 2, tempMoveChoice)
	for i in 1:17
		if i >= 1 && i <= 9 && i != 5
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		elseif i >= 10 && i <= 17
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
		if i == 1 || i == 3 || i == 7 || i == 9
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end


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

function defLionMove(srcRow::Int64, srcCol::Int64, option::String)
	global tempChessboard
	if option == "update"
		option = "special 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
	tempMoveChoice = [2, srcRow, srcCol, 0, 0, 0, 0, 0, 0]
	stepMultiple(srcRow, srcCol, option, srcRow, srcCol, 2, tempMoveChoice)
	for i in 1:17
		if i >= 1 && i <= 9 && i != 5
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		elseif i >= 10 && i <= 17
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
	if option == "special update"
		for i in 1:dim
			for j in 1:dim
				if i == srcRow && j == srcCol
				elseif chessboard[srcRow, srcCol].side == defWhite && tempChessboard[i, j].WAttack >= 1
					chessboard[i, j].WAttack += 1
				elseif chessboard[srcRow, srcCol].side == defBlack && tempChessboard[i, j].BAttack >= 1
					chessboard[i, j].BAttack += 1
				end
			end
		end
	end
end

function defPhoenixMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 4 || i == 6 || i == 8
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		elseif i == 1 || i == 3 || i == 7 || i == 9
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		end
	end
end

function defKirinMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 1 || i == 3 || i == 7 || i == 9
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		elseif i == 2 || i == 4 || i == 6 || i == 8
			step(srcRow, srcCol, option, srcRow + 2*moveOption[i].row, srcCol + 2*moveOption[i].col)
		end
	end
end

function defFreeBoarMove(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)
		end
	end
end

function defFlyingOxMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i != 4 && i != 5 && i != 6
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
end

function defSideMoverMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 4 || i == 6
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 2 || i == 8
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

function defVerticalMoverMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 8
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		elseif i == 4 || i == 6
			step(srcRow, srcCol, option, srcRow + moveOption[i].row, srcCol + moveOption[i].col)
		end
	end
end

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

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

function defMultiGeneralMove(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))
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
end

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

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

function defWhiteHorseMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 8 || (chessboard[srcRow, srcCol].side == defWhite && (i == 1 || i == 3)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 7 || i == 9))
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
end

function defWhaleMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 8 || (chessboard[srcRow, srcCol].side == defWhite && (i == 7 || i == 9)) || (chessboard[srcRow, srcCol].side == defBlack && (i == 1 || i == 3))
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
end

function defLanceMove(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)
		end
	end
end

function defReverseChariotMove(srcRow::Int64, srcCol::Int64, option::String)
	for i in 1:9
		if i == 2 || i == 8
			range(srcRow, srcCol, option, srcRow, srcCol, i)
		end
	end
end

######
# TEST FUNCTIONS
######

function printBoard()
	for i in 1:dim
		for j in 1:dim
			stringTest = chessboard[i,j].display
			print(" $stringTest")
		end
		println("")
	end
end

function printBoardBAttack()
	for i in 1:dim
		for j in 1:dim
			stringTest = chessboard[i,j].BAttack
			print(" $stringTest")
		end
		println("")
	end
end

function printBoardWAttack()
	for i in 1:dim
		for j in 1:dim
			stringTest = chessboard[i,j].WAttack
			print(" $stringTest")
		end
		println("")
	end
end

createBoard()
add(1, 1, "pawn", "Bl")
add(8, 8, "king", "Bl")
validateMoveChoice = [8, 8, 0, 0, 0, 0, 0, 0]
moveFunctions("update single")
printBoardBAttack()