Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

C# / C++ CLI Micro Chess (Huo Chess)

, 23 Aug 2014 CPOL
An article about Huo Chess, a chess program in C++ and C# that attempts to be smaller in size than the Commodore-era Microchess
c__v0.93__all_editions_.zip
C# v0.93 (all editions)
Huo Chess 0.93 (Kakos MiniMax depth 10)
Executable
Huo Chess 0.93 cs.exe
Source
Huo Chess 0.93 cs
Properties
Huo Chess 0.93 (Simple MiniMax)
Executable
Huo Chess 0.93 cs.exe
Source
Huo Chess 0.93 cs
bin
Properties
Huo Chess 0.94 (Kakos MiniMax depth 20)
Executable
Huo Chess 0.93 cs.exe
Source
Huo Chess 0.93 cs
Properties
executable.zip
Executable
Huo Chess 0.94 cs.exe
executables.zip
Executables
Huo Chess version 0.3
Huo Chess Opening Book
HuoChessConsole.exe
Huo Chess version 0.4
Huo Chess Opening Book
HuoChessConsole.exe
Executable_microEdition.zip
Executable_microEdition
HuoChess094cs.exe
huochess093cs.zip
HuoChess093cs.exe
huo_chess_0.6_micro_edition__source_and_exe_.zip
Huo Chess 0.6 micro edition (source and exe)
Executable
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
huo_chess_0.6__source_and_exe_.zip
Huo Chess 0.6 (source and exe)
Executable
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
huo_chess_0.721__executable_.zip
Huo Chess 0.721 (executable)
HuoChessConsole.exe
huo_chess_0.721__source_.zip
Huo Chess 0.721 (source)
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo_Chess_0.722_and_older_versions.zip
Huo Chess 0.722 and older versions
Huo Chess 0.5
Huo Chess 0.5 (Executable).zip
Huo Chess 0.5 (Source).zip
Huo Chess 0.6
Huo Chess 0.6 (Executable).zip
Huo Chess 0.6 (Source code).zip
Huo Chess Opening Book.zip
Huo Chess 0.6_micro
Huo Chess 0.6 - micro edition (Executable).zip
Huo Chess 0.6 - micro edition (Source code).zip
Huo Chess Opening Book.zip
Huo Chess 0.721
Huo Chess 0.721 (executable).zip
Huo Chess 0.721 (source).zip
Huo Chess Opening Book.zip
Huo Chess 0.722
Huo Chess 0.722 Executable.zip
Huo Chess 0.722 Source.zip
Huo_Chess_0.722__all_editions_.zip
Huo Chess 0.722 (all editions)
Huo Chess 0.722 (C++ edition)
Executable
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess 0.722 (CS edition)
Executable
Huo Chess 0.721 cs.exe
Source
Huo Chess 0.722 cs
Huo Chess 0.6 cs
bin
Properties
Huo Chess 0.722 (GUI edition)
Executable
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
XNAHuoChessGame.exe
Source
XNAHuoChessGame
Content
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
bin
x86
Debug
Release
Xbox 360
Debug
Release
Zune
Debug
Release
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
Content.contentproj
obj
x86
Debug
TempPE
Release
TempPE
Xbox 360
Debug
Release
Zune
Debug
Release
SpriteFont1.spritefont
Thumbs.db
Game.ico
GameThumbnail.png
Properties
Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
huo_chess_0.82_all_editions.zip
Huo Chess 0.82 all editions
Huo Chess 0.81 cpp edition
Executable
Huo Chess Opening Book
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess 0.82 cs edition
Executable
Huo Chess 0.721 cs.exe
Huo Chess Opening Book
Source
Huo Chess 0.6 cs
bin
Properties
Huo Chess 0.82 vb edition
Executable
HuoChessVB.exe
Source
HuoChessVB
My Project
Application.myapp
Settings.settings
Huo Chess 0.82 XNA edition
Executable
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo Chess Opening Book
Huo_Chess_XNA.exe
Source
XNAHuoChessGame
Content
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
bin
x86
Release
Xbox 360
Release
Zune
Release
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
Content.contentproj
SpriteFont1.spritefont
Game.ico
GameThumbnail.png
Properties
Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
huo_chess_0.82_micro_version.zip
Huo Chess 0.82 micro version
Huo Chess 0.721 cs.exe
Huo_Chess_0.82_VS_2008-noexe.zip
Huo Chess 0.82_VS 2008
Huo Chess 0.81 cpp edition
Executable
Huo Chess Opening Book
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess 0.82 cs edition
Executable
Huo Chess Opening Book
Source
Huo Chess 0.6 cs
Properties
Huo Chess 0.82 vb edition
Source
HuoChessVB
My Project
Application.myapp
Settings.settings
Huo Chess 0.82 XNA edition
Executable
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo Chess Opening Book
Source
XNAHuoChessGame
Content
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
Content.contentproj
SpriteFont1.spritefont
Game.ico
GameThumbnail.png
Properties
Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
Huo_Chess_0.82_VS_2008.zip
HuoChessConsole.exe
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess 0.721 cs.exe
Executable
HuoChessVB.exe
Application.myapp
Settings.settings
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo_Chess_XNA.exe
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
Content.contentproj
SpriteFont1.spritefont
Game.ico
GameThumbnail.png
Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
Huo_Chess_0.82__all_editions_.zip
Huo Chess 0.82 (all editions)
Huo Chess 0.81 cpp edition
Executable
Huo Chess Opening Book
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess 0.82 cs edition
Executable
Huo Chess 0.721 cs.exe
Huo Chess Opening Book
Source
Huo Chess 0.6 cs
bin
Properties
Huo Chess 0.82 XNA edition
Executable
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo Chess Opening Book
Huo_Chess_XNA.exe
Source
XNAHuoChessGame
Content
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
bin
x86
Debug
Release
Xbox 360
Debug
Release
Zune
Debug
Release
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
Content.contentproj
obj
x86
Debug
Refactor
TempPE
Release
TempPE
Xbox 360
Debug
Release
Zune
Debug
ResolveAssemblyReference.cache
Release
SpriteFont1.spritefont
Game.ico
GameThumbnail.png
Properties
Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Debug.cachefile
Zune Copy of Xbox 360 Copy of XNAHuoChessGame.csproj.Release.cachefile
Huo_Chess_0.93_VS2010-noexe.zip
Huo Chess 0.93_VS2010
Huo Chess 0.93_CS (official)
Huo Chess 0.93 (Simple MiniMax)
Source
Huo Chess 0.93 cs
Properties
Huo Chess 0.94 (Kakos MiniMax depth 20)
Source
Huo Chess 0.93 cs
Properties
Huo Chess 0.93_XNA (official)
Huo Chess 0.93 XNA edition - huoMinimax 20 v2
Huo Chess XNA 0.93 Executable.zip
Huo Chess XNA 0.93 Source.zip
Huo_Chess_0.93_VS2010.zip
Executable
Huo Chess 0.93 cs.exe
Executable
Huo Chess 0.93 cs.exe
Huo Chess XNA 0.93 Executable.zip
Huo Chess XNA 0.93 Source.zip
huo_chess_0.94.zip
Huo Chess 0.94
Executable
Huo Chess 0.94 cs.exe
Executable_microEdition
HuoChess094cs.exe
Source
Huo Chess 0.94 cs
bin
Release
Huo Chess 0.94 cs.exe
huochess.ico
Properties
Huo_Chess_0.95_cs_VS2012-noexe.zip
Huo Chess 0.95 cs_VS2012
Source
Huo Chess 0.95 cs
Properties
Huo_Chess_0.95_cs_VS2012.zip
Executable
Huo Chess 0.95 cs.exe
bin
Release
Huo Chess 0.95 cs.exe
Huo_Chess_0.95_cs_with_GUI_VS2012-noexe.zip
Huo Chess 0.95 cs with GUI_VS2012
Executable
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Source
HuoChessW8
Properties
Settings.settings
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Huo_Chess_0.95_cs_with_GUI_VS2012.zip
HuoChessW8.exe
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Settings.settings
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Huo_Chess_0.95_with_GUI_VS2012-noexe.zip
Huo Chess 0.95 with GUI_VS2012
Executable
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Source
HuoChessW8
bin
Release
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Properties
Settings.settings
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Huo_Chess_0.95_with_GUI_VS2012.zip
HuoChessW8.exe
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Settings.settings
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
HUO_CHESS_0.961-noexe.zip
HUO CHESS 0.961
Huo Chess 0.961 with GUI_VS2012
Executable
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Source
HuoChessW8
bin
Debug
Release
HuoChessW8.pdb
HuoChessW8.vshost.exe.manifest
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
obj
Properties
Settings.settings
Resources
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Huo Chess Thought process v0.7.docx
~$o Chess Thought process v0.41.docx
~$o Chess Thought process v0.5.docx
~WRL0266.tmp
HUO_CHESS_0.961.zip
HuoChessW8.exe
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
HuoChessW8.exe
HuoChessW8.pdb
HuoChessW8.vshost.exe
HuoChessW8.vshost.exe.manifest
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Settings.settings
BBishop.gif
BKing.gif
BKnight.gif
BKnight1.GIF
blacksquare.gif
BPawn.gif
BQueen.gif
BRook.gif
nothing.gif
WBishop - Copy.gif
WBishop.gif
whitesquare.gif
WKing.gif
WKnight.gif
WPawn.gif
WQueen.gif
WRook.gif
Huo Chess Thought process v0.7.docx
~$o Chess Thought process v0.41.docx
~$o Chess Thought process v0.5.docx
~WRL0266.tmp
Huo_Chess_0.961_cs-noexe.zip
Huo Chess 0.961 cs
Executable
Huo Chess Thought process v0.7.docx
Source
Huo Chess 0.95 cs
bin
Release
Huo Chess 0.95 cs.pdb
Huo Chess 0.95 cs.vshost.exe.manifest
obj
Properties
~$o Chess Thought process v0.7.docx
Huo_Chess_0.961_cs.zip
Huo Chess 0.95 cs.exe
Huo Chess Thought process v0.7.docx
Huo Chess 0.95 cs.exe
Huo Chess 0.95 cs.pdb
Huo Chess 0.95 cs.vshost.exe
Huo Chess 0.95 cs.vshost.exe.manifest
~$o Chess Thought process v0.7.docx
huo_chess_new_article.zip
Huo Chess new article
Files
Executable
Huo Chess Opening Book
HuoChessConsole.exe
Source
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.KAKOS-BROS-HY.Spiros.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Thumbs.db
huo_chess_opening_book.zip
Huo Chess Opening Book
Huo_Chess_Opening_Book_Editor_0.1-noexe.zip
Huo Chess Opening Book Editor 0.1
Executable
Huo Chess Opening Book
Source
Huo Chess Opening Book Editor
app.ico
Huo Chess Opening Book
Huo Chess Opening Book Editor.vcproj.HUB7381LCL.spyridon.kakos.user
Huo Chess Opening Book Editor.vcxproj.filters
Release
Huo Chess Opening Book
Huo_Chess_Opening_Book_Editor_0.1.zip
Huo Chess Opening Book Editor.exe
app.ico
Huo Chess Opening Book Editor.vcproj.HUB7381LCL.spyridon.kakos.user
Huo Chess Opening Book Editor.vcxproj.filters
Huo Chess Opening Book Editor.exe
huo_chess_with_gui__xna__v0.93.zip
Huo Chess with GUI (XNA) v0.93
Executable
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo_Chess_XNA.exe
Huo_Chess_XNA.pdb
Source
XNAHuoChessGame
bin
x86
Debug
Release
Content
a_black_bishop.xnb
a_black_king.xnb
a_black_knight.xnb
a_black_pawn.xnb
a_black_queen.xnb
a_black_rook.xnb
a_skakiera_empty.xnb
a_skakiera_startingPosition.xnb
a_white_bishop.xnb
a_white_king.xnb
a_white_knight.xnb
a_white_pawn.xnb
a_white_queen.xnb
a_white_rook.xnb
b_black_bishop.xnb
b_black_king.xnb
b_black_knight.xnb
b_black_pawn.xnb
b_black_queen.xnb
b_black_rook.xnb
b_white_bishop.xnb
b_white_king.xnb
b_white_knight.xnb
b_white_pawn.xnb
b_white_queen.xnb
b_white_rook.xnb
chess_columns.xnb
chess_columns_v2.xnb
chess_ranks.xnb
chess_ranks_v2.xnb
chess_white.xnb
chess_white_v2.xnb
SpriteFont1.xnb
Huo_Chess_XNA.exe
Huo_Chess_XNA.pdb
ClassDiagram1.cd
Content
a_black_bishop.PNG
a_black_king.PNG
a_black_knight.PNG
a_black_pawn.PNG
a_black_queen.PNG
a_black_rook.PNG
a_skakiera_empty.bmp
a_skakiera_startingPosition.bmp
a_white_bishop.PNG
a_white_king.PNG
a_white_knight.PNG
a_white_pawn.PNG
a_white_queen.PNG
a_white_rook.PNG
b_black_bishop.PNG
b_black_king.PNG
b_black_knight.PNG
b_black_pawn.PNG
b_black_queen.PNG
b_black_rook.PNG
b_white_bishop.PNG
b_white_king.PNG
b_white_knight.PNG
b_white_pawn.PNG
b_white_queen.PNG
b_white_rook.PNG
chess_columns.bmp
chess_columns_v2.bmp
chess_ranks.bmp
chess_ranks_v2.bmp
chess_white.bmp
chess_white_v2.bmp
SpriteFont1.spritefont
XNAHuoChessGameContent.contentproj
XNAHuoChessGameContent.contentproj.user
Game.ico
GameThumbnail.png
huochess.ico
HuoChessPng.png
Properties
XNAHuoChessGame.csproj.Debug.cachefile
XNAHuoChessGame.csproj.Release.cachefile
XNAHuoChessGame.csproj.user
source.zip
Source
Huo Chess 0.94 cs
bin
Release
Huo Chess 0.94 cs.exe
huochess.ico
Properties
source_code.zip
Source code
Huo Chess version 0.3
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
Huo Chess version 0.4
HuoChessConsole
HuoChessConsole
app.ico
HuoChessConsole.vcproj.HUB7381LCL.spyridon.kakos.user
HuoChessConsole.vcproj.HZQWB1J.spyridon.kakos.user
HuoChessConsole.vcproj.STASP.Stavros Kakos.user
using System;
using System.Collections.Generic;
//using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
// Variables for Huo Chess
using System.IO;
using System.Text;
using System.Threading;

// INSTRUCTIONS
// 1. Press SPACE to move on through messages.

namespace XNAHuoChessGame
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        ////////////////////////////////////////////////////////////////////////////////////////////////////////
        // DECLARE VARIABLES
        ////////////////////////////////////////////////////////////////////////////////////////////////////////

        // Variable to show if HY is thinking
        public static bool thinking;
        public bool ok;
        // Variable which states at which stage the user input is.
        // State 0: User has not chosen if he/she wants white or black colour yet. Game hasn't started.
        // State 1: User has chosen colour and the program is waiting for the user to enter starting column.
        // State 2: User has entered starting column.
        // State 3: User has entered starting rank.
        // State 4: User has entered finishing column.
        // State 5: User has entered finishing rank.
        public static int state_of_game_progress;
        // Variable to say if you have to wait for the user to press SPACE
        public static bool wait_for_space;

        // UNCOMMENT TO SHOW THINKING TIME!
        // (this and the other commands that use 'start' variable to record thinking time...)
        // public static int start; 

        // the chessboard (=skakiera in Greek)
        public static String[,] Skakiera = new String[8, 8];  // ������ ������ ��� �������������� �� ��������

        // CODE FOR COMPARISON
        public static int number_of_moves_analysed;

        // Variable to note if the computer moves its piece to a square threatened by a pawn
        public static bool knight_pawn_threat;
        public static bool bishop_pawn_threat;
        public static bool rook_pawn_threat;
        public static bool queen_pawn_threat;
        public static bool checked_for_pawn_threats;

        // Arrays to use in ComputerMove function
        // Changed in version 0.5
        // Penalty for moving the only piece that defends a square to that square (thus leavind the defender
        // alone in the square he once defended, defenceless!)
        // This penalty is also used to indicate that the computer loses its Queen with the move analyzed
        public static bool Danger_penalty;
        //bool LoseQueen_penalty;
        // Penalty for moving your piece to a square that the human opponent can hit with more power than the computer.
        public static bool Attackers_penalty;
        // Penalty if the pieces of the human defending a square in which the computer movies in, have much less
        // value than the pieces the computer has to support the attack on that square
        public static bool Defenders_value_penalty;

        public static String m_PlayerColor;
        public static String m_ComputerLevel = "Kakos";
        public static String m_WhoPlays;
        public static String m_WhichColorPlays;
        public static String MovingPiece;

        // variable to store temporarily the piece that is moving
        public static String ProsorinoKommati;
        public static String ProsorinoKommati_KingCheck;

        // variables to check the legality of the move
        public static bool exit_elegxos_nomimothtas = false;
        public static int h;
        public static int p;
        public static int how_to_move_Rank;
        public static int how_to_move_Column;
        public static int hhh;

        // NEW
        public static int kopa = 1;
        public static bool KingCheck = false;

        // coordinates of the starting square of the move
        public static String m_StartingColumn;
        public static int m_StartingRank;
        public static String m_FinishingColumn;
        public static int m_FinishingRank;

        // variable for en passant moves
        public static bool enpassant_occured;

        // move number
        public static int Move;

        // variable to show if promotion of a pawn occured
        public static bool Promotion_Occured = false;

        // variable to show if castrling occured
        public static bool Castling_Occured = false;

        // variables to help find out if it is legal for the computer to perform castling
        public static bool White_King_Moved = false;
        public static bool Black_King_Moved = false;
        public static bool White_Rook_a1_Moved = false;
        public static bool White_Rook_h1_Moved = false;
        public static bool Black_Rook_a8_Moved = false;
        public static bool Black_Rook_h8_Moved = false;
        public static bool Can_Castle_Big_White;
        public static bool Can_Castle_Big_Black;
        public static bool Can_Castle_Small_White;
        public static bool Can_Castle_Small_Black;

        // variables to show where the kings are in the chessboard
        public static int WhiteKingColumn;
        public static int WhiteKingRank;
        public static int BlackKingColumn;
        public static int BlackKingRank;

        // variables to show if king is in check
        public static bool WhiteKingCheck;
        public static bool BlackKingCheck;

        // variables to show if there is a possibility for mate
        public static bool WhiteMate = false;
        public static bool BlackMate = false;
        public static bool Mate;

        // variable to show if a move is found for the hy to do
        public static bool Best_Move_Found;

        // variables to help find if a king is under check.
        // (see CheckForWhiteCheck and CheckForBlackCheck functions)
        public static bool DangerFromRight;
        public static bool DangerFromLeft;
        public static bool DangerFromUp;
        public static bool DangerFromDown;
        public static bool DangerFromUpRight;
        public static bool DangerFromDownRight;
        public static bool DangerFromUpLeft;
        public static bool DangerFromDownLeft;

        // initial coordinates of the two kings
        // (see CheckForWhiteCheck and CheckForBlackCheck functions)
        public static int StartingWhiteKingColumn;
        public static int StartingWhiteKingRank;
        public static int StartingBlackKingColumn;
        public static int StartingBlackKingRank;

        // column number inserted by the user
        public static int m_StartingColumnNumber;
        public static int m_FinishingColumnNumber;

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        // ���������� ��� ��� ������ ��� "���������" ��� ��� "�����������" ���� ������� ��� ������
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        // variable for the correctness of the move
        public static bool m_OrthotitaKinisis;
        // variable for the legality of the move
        public static bool m_NomimotitaKinisis;
        // has the user entered a wrong column?
        public static bool m_WrongColumn;

        // variables for 'For' loops
        public static int i;
        public static int j;

        public static int ApophasiXristi = 1;

        //////////////////////////////////////
        // Computer Thought
        //////////////////////////////////////
        // Chessboards used for the computer throught
        public static String[,] Skakiera_Move_0 = new String[8, 8]; // ������ ������ ��� �������������� �� ��������
        public static String[,] Skakiera_Move_After = new String[8, 8];
        public static String[,] Skakiera_Thinking = new String[8, 8];
        //static array<String, 2> Skakiera_Move_After = new array<String, 2>(8,8);  // ������ ������ ��� �������������� �� ��������
        //static array<String, 2> Skakiera_Thinking = new array<String, 2>(8,8);  // ������ ������ ��� ��������������� ��� ����� ��� ����������.
        // rest of variables used for computer thought
        public static double Best_Move_Score;
        public static double Current_Move_Score;
        public static int Best_Move_StartingColumnNumber;
        public static int Best_Move_FinishingColumnNumber;
        public static int Best_Move_StartingRank;
        public static int Best_Move_FinishingRank;
        public static int Move_Analyzed;
        public static bool Stop_Analyzing;
        public static int Thinking_Depth;
        public static int m_StartingColumnNumber_HY;
        public static int m_FinishingColumnNumber_HY;
        public static int m_StartingRank_HY;
        public static int m_FinishingRank_HY;
        public static bool First_Call;
        public static String Who_Is_Analyzed;
        public static String MovingPiece_HY;

        // for writing the computer move
        public static String HY_Starting_Column_Text;
        public static String HY_Finishing_Column_Text;

        // variables which help find the best move of the human-opponent
        // during the HY thought analysis
        public static String[,] Skakiera_Human_Move_0 = new String[8, 8];
        public static String[,] Skakiera_Human_Thinking = new String[8, 8];
        //static array<String, 2> Skakiera_Human_Move_0 = new array<String, 2>(8,8);
        //static array<String, 2> Skakiera_Human_Thinking = new array<String, 2>(8,8);
        public static bool First_Call_Human_Thought;
        // 2009 version 1 change
        //public static int iii_Human;
        //public static int jjj_Human;
        public static String MovingPiece_Human = "";
        public static int m_StartingColumnNumber_Human = 1;
        public static int m_FinishingColumnNumber_Human = 1;
        public static int m_StartingRank_Human = 1;
        public static int m_FinishingRank_Human = 1;
        public static double Current_Human_Move_Score;
        public static double Best_Human_Move_Score;
        public static int Best_Move_Human_StartingColumnNumber;
        public static int Best_Move_Human_FinishingColumnNumber;
        public static int Best_Move_Human_StartingRank;
        public static int Best_Move_Human_FinishingRank;
        public static bool Best_Human_Move_Found;

        // does the HY eats the queen of his opponent with the move it analyzes?
        // Changed in version 0.5
        public static bool eat_queen;

        // where the player can perform en passant
        public static int enpassant_possible_target_rank;
        public static int enpassant_possible_target_column;

        // is there a possible mate?
        public static bool Human_is_in_check;
        public static bool Possible_mate;

        // does the HY moves its King with the move it is analyzing?
        public static bool moving_the_king;

        public static int choise_of_user;

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        // END OF HUO CHESS ENGINE VARIABLES DECLARATION
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        ////////////////////
        // GUI Variables
        ////////////////////

        // Text to display
        public static String text_to_display;
        public static String text_to_display_2;
        // Create the "device" (= adapter that connects to your graphic card)
        static GraphicsDevice device;
        static GraphicsDeviceManager graphics;
        static SpriteBatch spriteBatch;
        // Variable for the chessboard in the background.
        static Texture2D backgroundTexture;
        // Variables for the chessboard ranks and columns images.
        static Texture2D chessboard_ranks;
        static Texture2D chessboard_columns;
        // Variable which defines if the square is black or white
        static bool square_white;
        // Variable for white area (used to fill-in areas for decoration)
        static Texture2D white_area;
        // Variables for the pieces of the chessboard
        // Chesspieces in white font
        static Texture2D white_pawn;
        static Texture2D white_rook;
        static Texture2D white_knight;
        static Texture2D white_bishop;
        static Texture2D white_queen;
        static Texture2D white_king;
        static Texture2D black_pawn;
        static Texture2D black_rook;
        static Texture2D black_knight;
        static Texture2D black_bishop;
        static Texture2D black_queen;
        static Texture2D black_king;
        // Chesspieces in black font
        static Texture2D white_pawn_bl;
        static Texture2D white_rook_bl;
        static Texture2D white_knight_bl;
        static Texture2D white_bishop_bl;
        static Texture2D white_queen_bl;
        static Texture2D white_king_bl;
        static Texture2D black_pawn_bl;
        static Texture2D black_rook_bl;
        static Texture2D black_knight_bl;
        static Texture2D black_bishop_bl;
        static Texture2D black_queen_bl;
        static Texture2D black_king_bl;
        // Dimentions of the screen.
        static int screenWidth;
        static int screenHeight;
        // Text in screen
        static SpriteFont font;
        // Variable for mouse position detection
        static MouseState currentMouseState;
        static MouseState PreviousMouseState;
        static float currentMouseState_X;
        static float currentMouseState_Y;
        // Variables which show in which square the mouse is in
        static public int i_MouseIsIn;
        static public int j_MouseIsIn;
        // Variable which indicates if the program has to redraw the chessboard
        // before it calls the ComputerMove function
        //static public bool needRedrawNOW;
        // Is there a pawn under promotion?
        static public bool wait_for_pawn_promotion;
        static public int promotion_choise_of_user;
        static public bool pawn_promotion_is_chosen;
        static public String pawn_promotion_colour;
        static public int i_pawn_promotion;

        ///////////////////////////
        // End of GUI variables
        ///////////////////////////

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            // Initial values for the game appearance.
            // Set the game to be run in a 500x500 window (not full screen).
            graphics.PreferredBackBufferWidth = 520;
            graphics.PreferredBackBufferHeight = 600;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            // Set this to true to make the mouse cursor visible.
            // Use the default (false) if you are drawing your own
            // cursor or don't want a cursor.
            this.IsMouseVisible = true;
            Window.Title = "Huo Chess v0.722 (GUI edition 2) by Spiros I. Kakos";
            base.Initialize();

            state_of_game_progress = 0;

            Thinking_Depth = 8;

            // initial values
            White_King_Moved = false;
            Black_King_Moved = false;
            White_Rook_a1_Moved = false;
            White_Rook_h1_Moved = false;
            Black_Rook_a8_Moved = false;
            Black_Rook_h8_Moved = false;
            Can_Castle_Big_White = true;
            Can_Castle_Big_Black = true;
            Can_Castle_Small_White = true;
            Can_Castle_Small_Black = true;
            Move = 0;
            m_WhichColorPlays = "White";

            // fix startup position
            Starting_position();

            text_to_display = "Huo Chess v0.722 by Spiros I.Kakos (huo) [GUI v2]";
            wait_for_space = true; // Wait for key SPACE to be pressed
            text_to_display_2 = "Press SPACE to continue...";

            base.Initialize();
        }

        private void MouseInput()
        {
            currentMouseState = Mouse.GetState();
            currentMouseState_X = (Int32)currentMouseState.X;
            currentMouseState_Y = (Int32)currentMouseState.Y;

            // IF the user presses the left button, find out in which i and j the mouse cursor is in.
            if (currentMouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released)
            {
                // Find i and j
                for (int iii = 0; iii < 8; iii++)
                {
                    for (int jjj = 0; jjj < 8; jjj++)
                    {
                        if((currentMouseState_X > (13 + 7 * 62 - iii * 62 + 20)) && (currentMouseState_X < (13 + 7 * 62 - iii * 62 + 20 + 62)))
                            i_MouseIsIn = iii;

                        if ((currentMouseState_Y > (13 + jjj * 62)) && (currentMouseState_Y < (13 + (jjj + 1) * 62)))
                            j_MouseIsIn = jjj;
                    }
                }

                // Record the user input (starting/finishing column/rank depending
                // on the stage the game is in).

                    if(state_of_game_progress == 1)
                    {
                        if (i_MouseIsIn == 0)
                            m_StartingColumn = "A";
                        else if (i_MouseIsIn == 1)
                            m_StartingColumn = "B";
                        else if (i_MouseIsIn == 2)
                            m_StartingColumn = "C";
                        else if (i_MouseIsIn == 3)
                            m_StartingColumn = "D";
                        else if (i_MouseIsIn == 4)
                            m_StartingColumn = "E";
                        else if (i_MouseIsIn == 5)
                            m_StartingColumn = "F";
                        else if (i_MouseIsIn == 6)
                            m_StartingColumn = "G";
                        else if (i_MouseIsIn == 7)
                            m_StartingColumn = "H"; 
                        state_of_game_progress++;

                        if (j_MouseIsIn == 0)
                            m_StartingRank = 1;
                        else if (j_MouseIsIn == 1)
                            m_StartingRank = 2;
                        else if (j_MouseIsIn == 2)
                            m_StartingRank = 3;
                        else if (j_MouseIsIn == 3)
                            m_StartingRank = 4;
                        else if (j_MouseIsIn == 4)
                            m_StartingRank = 5;
                        else if (j_MouseIsIn == 5)
                            m_StartingRank = 6;
                        else if (j_MouseIsIn == 6)
                            m_StartingRank = 7;
                        else if (j_MouseIsIn == 7)
                            m_StartingRank = 8;
                        state_of_game_progress++;
                    }
                    else if(state_of_game_progress== 3)
                    {
                        if (i_MouseIsIn == 0)
                            m_FinishingColumn = "A";
                        else if (i_MouseIsIn == 1)
                            m_FinishingColumn = "B";
                        else if (i_MouseIsIn == 2)
                            m_FinishingColumn = "C";
                        else if (i_MouseIsIn == 3)
                            m_FinishingColumn = "D";
                        else if (i_MouseIsIn == 4)
                            m_FinishingColumn = "E";
                        else if (i_MouseIsIn == 5)
                            m_FinishingColumn = "F";
                        else if (i_MouseIsIn == 6)
                            m_FinishingColumn = "G";
                        else if (i_MouseIsIn == 7)
                            m_FinishingColumn = "H";
                        state_of_game_progress++;

                        if (j_MouseIsIn == 0)
                            m_FinishingRank = 1;
                        else if (j_MouseIsIn == 1)
                            m_FinishingRank = 2;
                        else if (j_MouseIsIn == 2)
                            m_FinishingRank = 3;
                        else if (j_MouseIsIn == 3)
                            m_FinishingRank = 4;
                        else if (j_MouseIsIn == 4)
                            m_FinishingRank = 5;
                        else if (j_MouseIsIn == 5)
                            m_FinishingRank = 6;
                        else if (j_MouseIsIn == 6)
                            m_FinishingRank = 7;
                        else if (j_MouseIsIn == 7)
                            m_FinishingRank = 8;
                        state_of_game_progress++;
                    }
            }
        }

        public static void DrawText()
        {
            spriteBatch.DrawString(font, text_to_display, new Vector2(4, 535), Color.White);
            spriteBatch.DrawString(font, text_to_display_2, new Vector2(4, 560), Color.White);

            spriteBatch.DrawString(font, "A", new Vector2(45 + 7 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "B", new Vector2(45 + 6 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "C", new Vector2(45 + 5 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "D", new Vector2(45 + 4 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "E", new Vector2(45 + 3 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "F", new Vector2(45 + 2 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "G", new Vector2(45 + 1 * 62, 500), Color.Black);
            spriteBatch.DrawString(font, "H", new Vector2(45 + 0 * 62, 500), Color.Black);

            spriteBatch.DrawString(font, "1", new Vector2(4, 21 + 0 * 62), Color.Black);
            spriteBatch.DrawString(font, "2", new Vector2(4, 21 + 1 * 62), Color.Black);
            spriteBatch.DrawString(font, "3", new Vector2(4, 21 + 2 * 62), Color.Black);
            spriteBatch.DrawString(font, "4", new Vector2(4, 21 + 3 * 62), Color.Black);
            spriteBatch.DrawString(font, "5", new Vector2(4, 21 + 4 * 62), Color.Black);
            spriteBatch.DrawString(font, "6", new Vector2(4, 21 + 5 * 62), Color.Black);
            spriteBatch.DrawString(font, "7", new Vector2(4, 21 + 6 * 62), Color.Black);
            spriteBatch.DrawString(font, "8", new Vector2(4, 21 + 7 * 62), Color.Black);
            spriteBatch.DrawString(font, "%", new Vector2(4, 500), Color.Black);
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            // The SpriteBatch is what its name implies: it allows us to render a batch of sprites, of 2D images. We can use a single SpriteBatch to render a huge amount of images. Best of all, this is done using the hardware acceleration of your video card!
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the text font
            font = Content.Load<SpriteFont>("SpriteFont1");

            // TODO: use this.Content to load your game content here
            device = graphics.GraphicsDevice;
            // Load the background chessboard image. This only allocates a variable to the background image. The image is drawn (rendered) with the SpriteBatch.
            backgroundTexture = Content.Load<Texture2D>("a_skakiera_empty");
            // Load the chessboard ranks.
            chessboard_ranks = Content.Load<Texture2D>("chess_ranks_v2");
            // Load the chessboards columns.
            chessboard_columns = Content.Load<Texture2D>("chess_columns_v2");
            // White area
            white_area = Content.Load<Texture2D>("chess_white_v2");
            // Load the images of chesspieces in white font
            white_pawn = Content.Load<Texture2D>("a_white_pawn");
            white_rook = Content.Load<Texture2D>("a_white_rook");
            white_knight = Content.Load<Texture2D>("a_white_knight");
            white_bishop = Content.Load<Texture2D>("a_white_bishop");
            white_queen = Content.Load<Texture2D>("a_white_queen");
            white_king = Content.Load<Texture2D>("a_white_king");
            black_pawn = Content.Load<Texture2D>("a_black_pawn");
            black_rook = Content.Load<Texture2D>("a_black_rook");
            black_knight = Content.Load<Texture2D>("a_black_knight");
            black_bishop = Content.Load<Texture2D>("a_black_bishop");
            black_queen = Content.Load<Texture2D>("a_black_queen");
            black_king = Content.Load<Texture2D>("a_black_king");
            // Load the images of chesspieces in black font
            white_pawn_bl = Content.Load<Texture2D>("b_white_pawn");
            white_rook_bl = Content.Load<Texture2D>("b_white_rook");
            white_knight_bl = Content.Load<Texture2D>("b_white_knight");
            white_bishop_bl = Content.Load<Texture2D>("b_white_bishop");
            white_queen_bl = Content.Load<Texture2D>("b_white_queen");
            white_king_bl = Content.Load<Texture2D>("b_white_king");
            black_pawn_bl = Content.Load<Texture2D>("b_black_pawn");
            black_rook_bl = Content.Load<Texture2D>("b_black_rook");
            black_knight_bl = Content.Load<Texture2D>("b_black_knight");
            black_bishop_bl = Content.Load<Texture2D>("b_black_bishop");
            black_queen_bl = Content.Load<Texture2D>("b_black_queen");
            black_king_bl = Content.Load<Texture2D>("b_black_king");
            // Read the dimentions of the screen and save them in the respective variables.
            screenWidth = device.PresentationParameters.BackBufferWidth;
            screenHeight = device.PresentationParameters.BackBufferHeight;
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here

            // if it is the turn of HY to play, then call the respective function
            // to implement HY thought

            //bool exit_game = false;

            // Wait for key SPACE to be pressed
            if (wait_for_space == true)
            {
                KeyboardState keybState = Keyboard.GetState();
                if (keybState.IsKeyDown(Keys.Space))
                    wait_for_space = false;
            }

            // If the program does not have to wait for the SPACE to be pressed,
            // then check the user input via keyboard and mouse.
            // The program "reads" different things from the user input, depending
            // on which stage the game is in (e.g. if the program is in the stage
            // where the user must enter the initial/starting column for his/her move,
            // then that is what it will "read" from the keyboard or mouse).

            ///////////////
            // MOUSE
            ///////////////
            MouseInput();

            ///////////////
            // KEYBOARD
            ///////////////

            /////////////////////
            // Setup game
            /////////////////////
            if ((state_of_game_progress == 0)&&(wait_for_space == false))
            {
                text_to_display = "Choose color (w/b)";
                text_to_display_2 = "Please select your colour of choice.";
                KeyboardState keybState = Keyboard.GetState();
                if (keybState.IsKeyDown(Keys.W))
                {
                    m_PlayerColor = "White";
                    m_WhoPlays = "Human";
                    text_to_display_2 = "";
                    state_of_game_progress++;
                }
                else if (keybState.IsKeyDown(Keys.B))
                {
                    m_PlayerColor = "Black";
                    m_WhoPlays = "HY";
                    text_to_display_2 = "";
                    state_of_game_progress++;
                }
            }


            /////////////////////////////////
            // Check for pawn promotion
            /////////////////////////////////
            if (wait_for_pawn_promotion == true)
            {
                text_to_display = "Promote pawn to: 1. Queen, 2. Rook, 3. Knight, 4. Bishop";
                text_to_display_2 = "Please select (1-4)...";
                KeyboardState keybState = Keyboard.GetState();
                if (keybState.IsKeyDown(Keys.NumPad1))
                {
                    promotion_choise_of_user = 1;
                    pawn_promotion_is_chosen = true;
                }
                else if (keybState.IsKeyDown(Keys.NumPad2))
                {
                    promotion_choise_of_user = 2;
                    pawn_promotion_is_chosen = true;
                }
                else if (keybState.IsKeyDown(Keys.NumPad3))
                {
                    promotion_choise_of_user = 3;
                    pawn_promotion_is_chosen = true;
                }
                else if (keybState.IsKeyDown(Keys.NumPad4))
                {
                    promotion_choise_of_user = 4;
                    pawn_promotion_is_chosen = true;
                }

                if (pawn_promotion_is_chosen == true)
                {
                    if (pawn_promotion_colour.CompareTo("white") == 0)
                    {
                        switch (promotion_choise_of_user)
                        {
                            case 1:
                                Skakiera[(i_pawn_promotion), (7)] = "White Queen";
                                break;

                            case 2:
                                Skakiera[(i_pawn_promotion), (7)] = "White Rook";
                                break;

                            case 3:
                                Skakiera[(i_pawn_promotion), (7)] = "White Knight";
                                break;

                            case 4:
                                Skakiera[(i_pawn_promotion), (7)] = "White Bishop";
                                break;
                        };

                        wait_for_pawn_promotion = false;
                    }
                    else if(pawn_promotion_colour.CompareTo("black")==0)
                    {
                        switch (promotion_choise_of_user)
                        {
                            case 1:
                                Skakiera[(i_pawn_promotion), (0)] = "Black Queen";
                                break;

                            case 2:
                                Skakiera[(i_pawn_promotion), (0)] = "Black Rook";
                                break;

                            case 3:
                                Skakiera[(i_pawn_promotion), (0)] = "Black Knight";
                                break;

                            case 4:
                                Skakiera[(i_pawn_promotion), (0)] = "Black Bishop";
                                break;
                        };

                        wait_for_pawn_promotion = false;
                    }
                }

            }

            /////////////////////
            // Play game
            /////////////////////
            if (wait_for_pawn_promotion == false)
            {
                if ((state_of_game_progress > 0) && (wait_for_space == false))
                {
                    if (m_WhoPlays.CompareTo("HY") == 0)
                    {
                        // call HY Thought function
                        Move = 0;

                        Move_Analyzed = 0;
                        Stop_Analyzing = false;
                        First_Call = true;
                        Best_Move_Found = false;
                        Who_Is_Analyzed = "HY";
                        wait_for_space = false;
                        ComputerMove(Skakiera);
                    }
                    else if (m_WhoPlays.CompareTo("Human") == 0)
                    {
                        text_to_display_2 = "Make your move and wait for the computer to think.";
                        ////////////////////////////////////////////////
                        // Check if human enters his move via keyboard
                        ////////////////////////////////////////////////

                        if (state_of_game_progress == 1)
                        {
                            text_to_display = "Starting column (A to H)...";
                            KeyboardState keybState = Keyboard.GetState();
                            if (keybState.IsKeyDown(Keys.A))
                            {
                                m_StartingColumn = "A";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.B))
                            {
                                m_StartingColumn = "B";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.C))
                            {
                                m_StartingColumn = "C";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.D))
                            {
                                m_StartingColumn = "D";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.E))
                            {
                                m_StartingColumn = "E";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.F))
                            {
                                m_StartingColumn = "F";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.G))
                            {
                                m_StartingColumn = "G";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.H))
                            {
                                m_StartingColumn = "H";
                                state_of_game_progress++;
                            }
                        }
                        else if (state_of_game_progress == 2)
                        {
                            text_to_display = "Starting rank (1 to 8).....";
                            KeyboardState keybState = Keyboard.GetState();
                            if (keybState.IsKeyDown(Keys.NumPad1))
                            {
                                m_StartingRank = 1;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad2))
                            {
                                m_StartingRank = 2;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad3))
                            {
                                m_StartingRank = 3;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad4))
                            {
                                m_StartingRank = 4;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad5))
                            {
                                m_StartingRank = 5;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad6))
                            {
                                m_StartingRank = 6;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad7))
                            {
                                m_StartingRank = 7;
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad8))
                            {
                                m_StartingRank = 8;
                                state_of_game_progress++;
                            }
                        }
                        else if (state_of_game_progress == 3)
                        {
                            text_to_display = "Finishing column (A to H)...";
                            KeyboardState keybState = Keyboard.GetState();
                            if (keybState.IsKeyDown(Keys.A))
                            {
                                m_FinishingColumn = "A";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.B))
                            {
                                m_FinishingColumn = "B";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.C))
                            {
                                m_FinishingColumn = "C";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.D))
                            {
                                m_FinishingColumn = "D";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.E))
                            {
                                m_FinishingColumn = "E";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.F))
                            {
                                m_FinishingColumn = "F";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.G))
                            {
                                m_FinishingColumn = "G";
                                state_of_game_progress++;
                            }
                            if (keybState.IsKeyDown(Keys.H))
                            {
                                m_FinishingColumn = "H";
                                state_of_game_progress++;
                            }
                        }
                        else if (state_of_game_progress == 4)
                        {
                            text_to_display = "Finishing rank (1 to 8).....";
                            KeyboardState keybState = Keyboard.GetState();
                            if (keybState.IsKeyDown(Keys.NumPad1))
                            {
                                m_FinishingRank = 1;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad2))
                            {
                                m_FinishingRank = 2;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad3))
                            {
                                m_FinishingRank = 3;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad4))
                            {
                                m_FinishingRank = 4;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad5))
                            {
                                m_FinishingRank = 5;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad6))
                            {
                                m_FinishingRank = 6;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad7))
                            {
                                m_FinishingRank = 7;
                                state_of_game_progress = 5;
                            }
                            if (keybState.IsKeyDown(Keys.NumPad8))
                            {
                                m_FinishingRank = 8;
                                state_of_game_progress = 5;
                            }
                        }

                        if (state_of_game_progress == 5)
                        {
                            // show the move entered
                            String huoMove = String.Concat("Your move: ", m_StartingColumn, m_StartingRank.ToString(), " -> ");
                            text_to_display = "Thinking...";
                            text_to_display_2 = "Please wait.";

                            // check the move entered by the human for correctness (='Orthotita' in Greek)
                            // and legality (='Nomimotita' in Greek)
                            Enter_move();
                            state_of_game_progress = 1;
                        }
                    }
                }
            }

            PreviousMouseState = Mouse.GetState();
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            // Initialize SpriteBatch -> Call drawing functions so as to add images to the list in SpriteBatch (list of images to be drawn in the next step) -> Render images with SpriteBatch.
            spriteBatch.Begin();
            DrawScenery();
            DrawText();
            spriteBatch.End();
            //needRedrawNOW = false;

            base.Draw(gameTime);
        }

        public static void DrawScenery()
        {
            // Create a rectangle with dimentions equal to the dimentions of the screen.
            Rectangle screenRectangle = new Rectangle(20, 0, (screenWidth-20), (screenHeight-100));
            // Draw the chessboard in the screen rectangle.
            spriteBatch.Draw(backgroundTexture, screenRectangle, Color.White);

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    // Create rectangle for square to be drawn
                    Rectangle square_screenRectangle = new Rectangle((13+7*62-j*62+20), (13+i*62), 40, 40);

                    // Find out if the square is white or black
                    if (Math.IEEERemainder((j + i), 2) == 0)
                        square_white = false;
                    else
                        square_white = true;

                    if (square_white == true)
                    {
                        if(Skakiera[(j),(i)].CompareTo("White Pawn")==0)
                            spriteBatch.Draw(white_pawn, square_screenRectangle, Color.White);
                        else if(Skakiera[(j),(i)].CompareTo("White Rook")==0)
                            spriteBatch.Draw(white_rook, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Knight") == 0)
                            spriteBatch.Draw(white_knight, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Bishop") == 0)
                            spriteBatch.Draw(white_bishop, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Queen") == 0)
                            spriteBatch.Draw(white_queen, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White King") == 0)
                            spriteBatch.Draw(white_king, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Pawn") == 0)
                            spriteBatch.Draw(black_pawn, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Rook") == 0)
                            spriteBatch.Draw(black_rook, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Knight") == 0)
                            spriteBatch.Draw(black_knight, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Bishop") == 0)
                            spriteBatch.Draw(black_bishop, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Queen") == 0)
                            spriteBatch.Draw(black_queen, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black King") == 0)
                            spriteBatch.Draw(black_king, square_screenRectangle, Color.White);
                    }
                    else if (square_white == false)
                    {
                        if (Skakiera[(j), (i)].CompareTo("White Pawn") == 0)
                            spriteBatch.Draw(white_pawn_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Rook") == 0)
                            spriteBatch.Draw(white_rook_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Knight") == 0)
                            spriteBatch.Draw(white_knight_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Bishop") == 0)
                            spriteBatch.Draw(white_bishop_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White Queen") == 0)
                            spriteBatch.Draw(white_queen_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("White King") == 0)
                            spriteBatch.Draw(white_king_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Pawn") == 0)
                            spriteBatch.Draw(black_pawn_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Rook") == 0)
                            spriteBatch.Draw(black_rook_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Knight") == 0)
                            spriteBatch.Draw(black_knight_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Bishop") == 0)
                            spriteBatch.Draw(black_bishop_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black Queen") == 0)
                            spriteBatch.Draw(black_queen_bl, square_screenRectangle, Color.White);
                        else if (Skakiera[(j), (i)].CompareTo("Black King") == 0)
                            spriteBatch.Draw(black_king_bl, square_screenRectangle, Color.White);
                    }
                }
            }

        }

        public static bool CheckForBlackCheck(string[,] BCSkakiera)
        {
            // TODO: Add your control notification handler code here

            bool KingCheck;

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������ ��� ������������� ��� �������.
            // �� �� ������ ��������� ������ ��� ������� ���� ��������, ���� ���� ������������ � ���� ��� �� ����
            // ���������� ���� ����������� ���������� ��� �������� �� ����� ��� �� ������ ���� ����� ������� ������
            // ��������.
            // �������: ����� (i+1) ���� ��� i ��� (j+1) ���� ��� j ����� �� ����� �������� ��� ������ BCSkakiera[(8),(8)]
            // ����� �� BCSkakiera[(0),(0)] ��� ��� �� BCSkakiera[(1),(1)]!
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

            for (i = 0; i <= 7; i++)
            {
                for (j = 0; j <= 7; j++)
                {

                    if (BCSkakiera[(i), (j)].CompareTo("Black King") == 0)
                    {
                        BlackKingColumn = (i + 1);
                        BlackKingRank = (j + 1);
                    }

                }
            }

            ///////////////////////////////////////////////////////////////
            // ������� ��� �� � ������ �������� ��������� "���"
            ///////////////////////////////////////////////////////////////

            KingCheck = false;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ��������� ������ �� ������� �������� ��� �� ����� ������� ��� �� ����� ���. ��� �� ��� ������ ��� ��� ��
            // ���� ��� BCSkakiera[(8),(8)] ������ ��������� ��� ������ (BlackKingColumn + 1) <= 8 ��� "if". ������ � "��������"
            // ��� �� "�����" ����� ��������, ��� DangerFromRight = true. ������ �� ������ ��� ��� ����� ��� ������ ����-
            // ��� ������� ������ ����� �������, ���� ��� ����� ������� � �� ���� �������� �� ��������� ��� ��� �� �����
            // ��� (���� �� "�������������" ��� �� ������� ����� ��������), ����� � DangerFromRight = false ��� � �������
            // ��� ������� ��� �� ����� ��������� (��� ���� ��� ��� ��������� ��� ���������� (DangerFromRight == true) ���
            // "if" ��� ������ ����� ��� ������).
            // �� ���� ��� ������� ������ ����� ������� ����� ��� ������� ��� �� ��� �����������, ���� ��������� ��
            // ������� ���������� �� ���������� � �������� ��� �� ����� ���, ����� � ������� �����������.
            // ��������: � ������� ������� ��� ������ ��� ��� ����� � ��������� ��������� ��������.
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn + klopa) <= 8) && (DangerFromRight == true))
                {
                    if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("Black Queen") == 0))
                        DangerFromRight = false;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - 1)].CompareTo("White King") == 0))
                        DangerFromRight = false;
                }
            }



            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� �� �������� ��� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn - klopa) >= 1) && (DangerFromLeft == true))
                {
                    if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("Black Queen") == 0))
                        DangerFromLeft = false;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - 1)].CompareTo("White King") == 0))
                        DangerFromLeft = false;
                }
            }



            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ���� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////


            DangerFromUp = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingRank + klopa) <= 8) && (DangerFromUp == true))
                {
                    if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromUp = false;
                    else if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank + klopa - 1)].CompareTo("White King") == 0))
                        DangerFromUp = false;
                }
            }



            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ���� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDown = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingRank - klopa) >= 1) && (DangerFromDown == true))
                {
                    if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromDown = false;
                    else if ((BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn - 1), (BlackKingRank - klopa - 1)].CompareTo("White King") == 0))
                        DangerFromDown = false;
                }
            }



            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-����� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromUpRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn + klopa) <= 8) && ((BlackKingRank + klopa) <= 8) && (DangerFromUpRight == true))
                {
                    if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromUpRight = false;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White King") == 0))
                        DangerFromUpRight = false;
                }
            }



            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-�������� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDownLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn - klopa) >= 1) && ((BlackKingRank - klopa) >= 1) && (DangerFromDownLeft == true))
                {
                    if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromDownLeft = false;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White King") == 0))
                        DangerFromDownLeft = false;
                }
            }


            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-����� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDownRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn + klopa) <= 8) && ((BlackKingRank - klopa) >= 1) && (DangerFromDownRight == true))
                {
                    if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromDownRight = false;
                    else if ((BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn + klopa - 1), (BlackKingRank - klopa - 1)].CompareTo("White King") == 0))
                        DangerFromDownRight = false;
                }
            }



            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-�������� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromUpLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((BlackKingColumn - klopa) >= 1) && ((BlackKingRank + klopa) <= 8) && (DangerFromUpLeft == true))
                {
                    if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        KingCheck = true;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        DangerFromUpLeft = false;
                    else if ((BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (BCSkakiera[(BlackKingColumn - klopa - 1), (BlackKingRank + klopa - 1)].CompareTo("White King") == 0))
                        DangerFromUpLeft = false;
                }
            }


            //////////////////////////////////////////////////////////////////////////
            // ������� ��� �� �� � ������ �������� ���������� ��� �����.
            //////////////////////////////////////////////////////////////////////////

            if (((BlackKingColumn + 1) <= 8) && ((BlackKingRank - 1) >= 1))
            {
                if (BCSkakiera[(BlackKingColumn + 1 - 1), (BlackKingRank - 1 - 1)].CompareTo("White Pawn") == 0)
                {
                    KingCheck = true;
                }
            }


            if (((BlackKingColumn - 1) >= 1) && ((BlackKingRank - 1) >= 1))
            {
                if (BCSkakiera[(BlackKingColumn - 1 - 1), (BlackKingRank - 1 - 1)].CompareTo("White Pawn") == 0)
                {
                    KingCheck = true;
                }
            }


            ///////////////////////////////////////////////////////////////////////
            // ������� ��� �� �� � ������ �������� ���������� ��� ����.
            ///////////////////////////////////////////////////////////////////////

            if (((BlackKingColumn + 1) <= 8) && ((BlackKingRank + 2) <= 8))
                if (BCSkakiera[(BlackKingColumn + 1 - 1), (BlackKingRank + 2 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn + 2) <= 8) && ((BlackKingRank - 1) >= 1))
                if (BCSkakiera[(BlackKingColumn + 2 - 1), (BlackKingRank - 1 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn + 1) <= 8) && ((BlackKingRank - 2) >= 1))
                if (BCSkakiera[(BlackKingColumn + 1 - 1), (BlackKingRank - 2 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn - 1) >= 1) && ((BlackKingRank - 2) >= 1))
                if (BCSkakiera[(BlackKingColumn - 1 - 1), (BlackKingRank - 2 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn - 2) >= 1) && ((BlackKingRank - 1) >= 1))
                if (BCSkakiera[(BlackKingColumn - 2 - 1), (BlackKingRank - 1 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn - 2) >= 1) && ((BlackKingRank + 1) <= 8))
                if (BCSkakiera[(BlackKingColumn - 2 - 1), (BlackKingRank + 1 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn - 1) >= 1) && ((BlackKingRank + 2) <= 8))
                if (BCSkakiera[(BlackKingColumn - 1 - 1), (BlackKingRank + 2 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            if (((BlackKingColumn + 2) <= 8) && ((BlackKingRank + 1) <= 8))
                if (BCSkakiera[(BlackKingColumn + 2 - 1), (BlackKingRank + 1 - 1)].CompareTo("White Knight") == 0)
                    KingCheck = true;

            return KingCheck;
        }



        public static bool CheckForBlackMate(string[,] BMSkakiera)
        {
            // TODO: Add your control notification handler code here

            bool Mate;

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ��������� ��� ���������� ���� ������ ��� �� �� ������� ��� (��. ����������� CheckForWhiteMate() ���
            // CheckForBlackMate()).
            // �������������, �� ��������� ������� �� ������ ������� ��� ���, �� �������, ������� �� ���� ��
            // ��� ������ �� ���������� �� �� ���������� ��� ��� ������ ������� �� ������ ��������� ���������.
            // � ��������� ���������� �� �� ��������� �� ������� ���������� �� ������� ��� ��� ��������.
            /////////////////////////////////////////////////////////////////////////////////////////////////////////

            bool DangerForMate;

            ////////////////////////////////////////////////////////////
            // ������� ��� �� ������� "���" ���� ����� �������
            ////////////////////////////////////////////////////////////

            Mate = false;
            DangerForMate = true;    // ������, �������� ������� ���������� �� ������� ��� ��� ��������.
            // ��, ������, ������ ������ ������ ��� �� � �������� ������ �� �����������
            // �� ��� ������� ��������� ��� �� ����� �� ��������� ���, ���� ����� ��
            // ������� ���������� �� ������� ��� (��������) ��� � ��������� ������� ���
            // ���� false.


            //////////////////////////////////////////////////////////////
            // ������ ��� ������� ������������� ��� �������
            //////////////////////////////////////////////////////////////

            for (i = 0; i <= 7; i++)
            {
                for (j = 0; j <= 7; j++)
                {

                    if (BMSkakiera[(i), (j)].CompareTo("Black King") == 0)
                    {
                        StartingBlackKingColumn = (i + 1);
                        StartingBlackKingRank = (j + 1);
                    }

                }
            }


            //////////////////////////////////////////////////
            // ������� �� � ������ �������� ����� ���
            //////////////////////////////////////////////////


            if (m_WhichColorPlays.CompareTo("Black") == 0)
            {

                ////////////////////////////////////////////////
                // ������� �� ������� ��� ���� �� ������
                ////////////////////////////////////////////////

                BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                if (BlackKingCheck == false)     // �� ���� �� ������ ��� ��������� ���, ���� �� �� ���������� � �������
                    DangerForMate = false;         // ����� ��� ��������� �� ��������� ���������� �� ������� ���.

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingBlackKingRank < 8)
                {
                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
                        // � ������� ������� ���� �� ��� ��������� ��� ������������ ��������� � �������� ��� ������� ���� �������
                        // ��� ����� �������� ��� �� ��� ��������� ��� ��, ������, � �������� ��� ������� ��� ��� �� �������� ��
                        // ���� ��� ��� ������ ��� ��, ��������, ��������� �� ������� ���������� �� ������� ��� (����� �� ���
                        // ������� ������ ����������, ���� � ������� ����� ��������).

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 + 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 + 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-�����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingBlackKingColumn < 8) && (StartingBlackKingRank < 8))
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 + 1) <= 7) && ((StartingBlackKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 + 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 + 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� �����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingBlackKingColumn < 8)
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-�����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingBlackKingColumn < 8) && (StartingBlackKingRank > 1))
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 - 1) >= 0) && ((StartingBlackKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 - 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 + 1), (StartingBlackKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingBlackKingRank > 1)
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 - 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingBlackKingColumn > 1) && (StartingBlackKingRank > 1))
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 - 1) >= 0) && ((StartingBlackKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 - 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingBlackKingColumn > 1)
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingBlackKingColumn > 1) && (StartingBlackKingRank < 8))
                {

                    MovingPiece = BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)];
                    ProsorinoKommati = BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("Black Queen") == 1) && (ProsorinoKommati.CompareTo("Black Rook") == 1) && (ProsorinoKommati.CompareTo("Black Knight") == 1) && (ProsorinoKommati.CompareTo("Black Bishop") == 1) && (ProsorinoKommati.CompareTo("Black Pawn") == 1) && (DangerForMate == true) && ((StartingBlackKingRank - 1 + 1) <= 7) && ((StartingBlackKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = "";
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 + 1)] = MovingPiece;
                        BlackKingCheck = CheckForBlackCheck(BMSkakiera);

                        if (BlackKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        BMSkakiera[(StartingBlackKingColumn - 1), (StartingBlackKingRank - 1)] = MovingPiece;
                        BMSkakiera[(StartingBlackKingColumn - 1 - 1), (StartingBlackKingRank - 1 + 1)] = ProsorinoKommati;

                    }

                }

                if (DangerForMate == true)
                    Mate = true;

            }

            return Mate;
        }






        public static bool CheckForWhiteCheck(string[,] WCSkakiera)
        {


            // TODO: Add your control notification handler code here

            bool KingCheck;

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������ ��� ������������� ��� �������.
            // �� �� ������ ��������� ������ ��� ������� ���� ��������, ���� ���� ������������ � ���� ��� �� ����
            // ���������� ���� ����������� ���������� ��� �������� �� ����� ��� �� ������ ���� ����� ������� ������
            // ��������.
            // �������: ����� (i+1) ���� ��� i ��� (j+1) ���� ��� j ����� �� ����� �������� ��� ������ WCWCSkakiera[(8),(8)]
            // ����� �� WCSkakiera[(0),(0)] ��� ��� �� WCSkakiera[(1),(1)]!
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

            for (i = 0; i <= 7; i++)
            {
                for (j = 0; j <= 7; j++)
                {

                    if (WCSkakiera[(i), (j)].CompareTo("White King") == 0)
                    {
                        WhiteKingColumn = (i + 1);
                        WhiteKingRank = (j + 1);
                    }

                }
            }

            ///////////////////////////////////////////////////////////////
            // ������� ��� �� � ������ �������� ��������� "���"
            ///////////////////////////////////////////////////////////////

            KingCheck = false;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ��������� ������ �� ������� �������� ��� �� ����� ������� ��� �� ����� ���. ��� �� ��� ������ ��� ��� ��
            // ���� ��� WCSkakiera[(8),(8)] ������ ��������� ��� ������ (WhiteKingColumn + 1) <= 8 ��� "if". ������ � "��������"
            // ��� �� "�����" ����� ��������, ��� DangerFromRight = true. ������ �� ������ ��� ��� ����� ��� ������ ����-
            // ��� ������� ������ ����� �������, ���� ��� ����� ������� � �� ���� �������� �� ��������� ��� ��� �� �����
            // ��� (���� �� "�������������" ��� �� ������� ����� ��������), ����� � DangerFromRight = false ��� � �������
            // ��� ������� ��� �� ����� ��������� (��� ���� ��� ��� ��������� ��� ���������� (DangerFromRight == true) ���
            // "if" ��� ������ ����� ��� ������).
            // �� ���� ��� ������� ������ ����� ������� ����� ��� ������� ��� �� ��� �����������, ���� ��������� ��
            // ������� ���������� �� ���������� � �������� ��� �� ����� ���, ����� � ������� �����������.
            // ��������: � ������� ������� ��� ������ ��� ��� ����� � ��������� ��������� ��������.
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn + klopa) <= 8) && (DangerFromRight == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("White Queen") == 0))
                        DangerFromRight = false;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - 1)].CompareTo("Black King") == 0))
                        DangerFromRight = false;
                }
            }


            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� �� �������� ��� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn - klopa) >= 1) && (DangerFromLeft == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("White Queen") == 0))
                        DangerFromLeft = false;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - 1)].CompareTo("Black King") == 0))
                        DangerFromLeft = false;
                }
            }


            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ���� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////


            DangerFromUp = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingRank + klopa) <= 8) && (DangerFromUp == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromUp = false;
                    else if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromUp = false;
                }
            }


            ///////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ���� (��� ����� � ���������).
            ///////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDown = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingRank - klopa) >= 1) && (DangerFromDown == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromDown = false;
                    else if ((WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromDown = false;
                }
            }


            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-����� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromUpRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn + klopa) <= 8) && ((WhiteKingRank + klopa) <= 8) && (DangerFromUpRight == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromUpRight = false;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromUpRight = false;
                }
            }


            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-�������� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDownLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn - klopa) >= 1) && ((WhiteKingRank - klopa) >= 1) && (DangerFromDownLeft == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromDownLeft = false;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromDownLeft = false;
                }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-����� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromDownRight = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn + klopa) <= 8) && ((WhiteKingRank - klopa) >= 1) && (DangerFromDownRight == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromDownRight = false;
                    else if ((WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn + klopa - 1), (WhiteKingRank - klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromDownRight = false;
                }
            }


            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ������� �� ������� �������� ��� �� ����� ������� ��� ����-�������� ��� (��� ��������� � ����������).
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            DangerFromUpLeft = true;

            for (int klopa = 1; klopa <= 7; klopa++)
            {
                if (((WhiteKingColumn - klopa) >= 1) && ((WhiteKingRank + klopa) <= 8) && (DangerFromUpLeft == true))
                {
                    if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Queen") == 0))
                        KingCheck = true;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Bishop") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("White Queen") == 0))
                        DangerFromUpLeft = false;
                    else if ((WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Pawn") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Rook") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black Knight") == 0) || (WCSkakiera[(WhiteKingColumn - klopa - 1), (WhiteKingRank + klopa - 1)].CompareTo("Black King") == 0))
                        DangerFromUpLeft = false;
                }
            }



            //////////////////////////////////////////////////////////////////////////
            // ������� ��� �� �� � ������ �������� ���������� ��� �����.
            //////////////////////////////////////////////////////////////////////////

            if (((WhiteKingColumn + 1) <= 8) && ((WhiteKingRank + 1) <= 8))
            {
                if (WCSkakiera[(WhiteKingColumn + 1 - 1), (WhiteKingRank + 1 - 1)].CompareTo("Black Pawn") == 0)
                {
                    KingCheck = true;
                }
            }


            if (((WhiteKingColumn - 1) >= 1) && ((WhiteKingRank + 1) <= 8))
            {
                if (WCSkakiera[(WhiteKingColumn - 1 - 1), (WhiteKingRank + 1 - 1)].CompareTo("Black Pawn") == 0)
                {
                    KingCheck = true;
                }
            }


            ///////////////////////////////////////////////////////////////////////
            // ������� ��� �� �� � ������ �������� ���������� ��� ����.
            ///////////////////////////////////////////////////////////////////////

            if (((WhiteKingColumn + 1) <= 8) && ((WhiteKingRank + 2) <= 8))
                if (WCSkakiera[(WhiteKingColumn + 1 - 1), (WhiteKingRank + 2 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn + 2) <= 8) && ((WhiteKingRank - 1) >= 1))
                if (WCSkakiera[(WhiteKingColumn + 2 - 1), (WhiteKingRank - 1 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn + 1) <= 8) && ((WhiteKingRank - 2) >= 1))
                if (WCSkakiera[(WhiteKingColumn + 1 - 1), (WhiteKingRank - 2 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn - 1) >= 1) && ((WhiteKingRank - 2) >= 1))
                if (WCSkakiera[(WhiteKingColumn - 1 - 1), (WhiteKingRank - 2 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn - 2) >= 1) && ((WhiteKingRank - 1) >= 1))
                if (WCSkakiera[(WhiteKingColumn - 2 - 1), (WhiteKingRank - 1 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn - 2) >= 1) && ((WhiteKingRank + 1) <= 8))
                if (WCSkakiera[(WhiteKingColumn - 2 - 1), (WhiteKingRank + 1 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn - 1) >= 1) && ((WhiteKingRank + 2) <= 8))
                if (WCSkakiera[(WhiteKingColumn - 1 - 1), (WhiteKingRank + 2 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            if (((WhiteKingColumn + 2) <= 8) && ((WhiteKingRank + 1) <= 8))
                if (WCSkakiera[(WhiteKingColumn + 2 - 1), (WhiteKingRank + 1 - 1)].CompareTo("Black Knight") == 0)
                    KingCheck = true;

            return KingCheck;
        }




        public static bool CheckForWhiteMate(string[,] WMSkakiera)
        {
            // TODO: Add your control notification handler code here

            bool Mate;

            /////////////////////////////////////////////////////////////////////////////////////////////////////////
            // ��������� ��� ���������� ���� ������ ��� �� �� ������� ��� (��. ����������� CheckForWhiteMate() ���
            // CheckForBlackMate()).
            // �������������, �� ��������� ������� �� ������ ������� ��� ���, �� �������, ������� �� ���� ��
            // ��� ������ �� ���������� �� �� ���������� ��� ��� ������ ������� �� ������ ��������� ���������.
            // � ��������� ���������� �� �� ��������� �� ������� ���������� �� ������� ��� ��� ��������.
            /////////////////////////////////////////////////////////////////////////////////////////////////////////

            bool DangerForMate;

            ////////////////////////////////////////////////////////////
            // ������� ��� �� ������� "���" ���� ����� �������
            ////////////////////////////////////////////////////////////

            Mate = false;
            DangerForMate = true;    // ������, �������� ������� ���������� �� ������� ��� ��� ��������.
            // ��, ������, ������ ������ ������ ��� �� � �������� ������ �� �����������
            // �� ��� ������� ��������� ��� �� ����� �� ��������� ���, ���� ����� ��
            // ������� ���������� �� ������� ��� (��������) ��� � ��������� ������� ���
            // ���� false.


            //////////////////////////////////////////////////////////////
            // ������ ��� ������� ������������� ��� �������
            //////////////////////////////////////////////////////////////

            for (i = 0; i <= 7; i++)
            {
                for (j = 0; j <= 7; j++)
                {

                    if (WMSkakiera[(i), (j)].CompareTo("White King") == 0)
                    {
                        StartingWhiteKingColumn = (i + 1);
                        StartingWhiteKingRank = (j + 1);
                    }

                }
            }


            //////////////////////////////////////////////////
            // ������� �� � ������ �������� ����� ���
            //////////////////////////////////////////////////


            if (m_WhichColorPlays.CompareTo("White") == 0)
            {

                ////////////////////////////////////////////////
                // ������� �� ������� ��� ���� �� ������
                ////////////////////////////////////////////////

                WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                if (WhiteKingCheck == false)     // �� ���� �� ������ ��� ��������� ���, ���� �� �� ���������� � �������
                    DangerForMate = false;         // ����� ��� ��������� �� ��������� ���������� �� ������� ���.

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingWhiteKingRank < 8)
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
                        // � ������� ������� ���� �� ��� ��������� ��� ������������ ��������� � �������� ��� ������� ���� �������
                        // ��� ����� �������� ��� �� ��� ��������� ��� ��, ������, � �������� ��� ������� ��� ��� �� �������� ��
                        // ���� ��� ��� ������ ��� ��, ��������, ��������� �� ������� ���������� �� ������� ��� (����� �� ���
                        // ������� ������ ����������, ���� � ������� ����� ��������).

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 + 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 + 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-�����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingWhiteKingColumn < 8) && (StartingWhiteKingRank < 8))
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 + 1) <= 7) && ((StartingWhiteKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 + 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 + 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� �����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingWhiteKingColumn < 8)
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-�����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingWhiteKingColumn < 8) && (StartingWhiteKingRank > 1))
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 - 1) >= 0) && ((StartingWhiteKingColumn - 1 + 1) <= 7))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 - 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1 + 1), (StartingWhiteKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingWhiteKingRank > 1)
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 - 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingWhiteKingColumn > 1) && (StartingWhiteKingRank > 1))
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1 - 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 - 1) >= 0) && ((StartingWhiteKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1 - 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1 - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (StartingWhiteKingColumn > 1)
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);

                        if (WhiteKingCheck == false)
                            DangerForMate = false;

                        // ��������� ��� ��������� ���� ��������� ���� ����� ��������� ���� ����������� � �������� ��� ����
                        // ������� ��� �������.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = MovingPiece;
                        WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1)] = ProsorinoKommati;

                    }

                }


                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // ������� ��� �� �� ��������� �� ������� ��� �� � ������ �������� ����������� �� �������� ��������������
                // ���� �� ����-��������
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if ((StartingWhiteKingColumn > 1) && (StartingWhiteKingRank < 8))
                {

                    MovingPiece = WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)];
                    ProsorinoKommati = WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1 + 1)];

                    if ((ProsorinoKommati.CompareTo("White Queen") == 1) && (ProsorinoKommati.CompareTo("White Rook") == 1) && (ProsorinoKommati.CompareTo("White Knight") == 1) && (ProsorinoKommati.CompareTo("White Bishop") == 1) && (ProsorinoKommati.CompareTo("White Pawn") == 1) && (DangerForMate == true) && ((StartingWhiteKingRank - 1 + 1) <= 7) && ((StartingWhiteKingColumn - 1 - 1) >= 0))
                    {

                        // (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

                        WMSkakiera[(StartingWhiteKingColumn - 1), (StartingWhiteKingRank - 1)] = "";
                        WMSkakiera[(StartingWhiteKingColumn - 1 - 1), (StartingWhiteKingRank - 1 + 1)] = MovingPiece;
                        WhiteKingCheck = CheckForWhiteCheck(WMSkakiera);