Click here to Skip to main content
11,584,040 members (57,574 online)
Click here to Skip to main content
Add your own
alternative version

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

, 23 Aug 2014 CPOL 189.7K 13.9K 166
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
// HuoChessConsole.cpp : main project file.

#include "stdafx.h"

using namespace System;
using namespace System::IO;

ref class HuoChess_main {
	public:
	////////////////////////////////////////////////////////////////////////////////////////////////////////
	// DECLARE VARIABLES
	////////////////////////////////////////////////////////////////////////////////////////////////////////

	// the chessboard (=skakiera in Greek)
	static array<String^, 2>^ Skakiera = gcnew array<String^, 2>(8,8);  // ������ ������ ��� �������������� �� ��������

	// 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
	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.
	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
	bool Defenders_value_penalty;

	String^ m_PlayerColor;   
	String^ m_ComputerLevel; 
	String^ m_WhoPlays;      
	String^ m_WhichColorPlays; 
	String^ MovingPiece;      

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

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

	// NEW
	int kopa;
	bool KingCheck;

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

	// variable for en passant moves
	bool enpassant_occured;

	// move number
	int Move;

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

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

	// variables to help find out if it is legal for the computer to perform castling
	static bool White_King_Moved = false;
	static bool Black_King_Moved = false;
	static bool White_Rook_a1_Moved = false;
	static bool White_Rook_h1_Moved = false;
	static bool Black_Rook_a8_Moved = false;
	static bool Black_Rook_h8_Moved = false;
	static bool Can_Castle_Big_White;
	static bool Can_Castle_Big_Black;
	static bool Can_Castle_Small_White;
	static bool Can_Castle_Small_Black;
	
	// variables to show where the kings are in the chessboard
	int WhiteKingColumn;      
    int WhiteKingRank;        
	int BlackKingColumn;      
    int BlackKingRank;        

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

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

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

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

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

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

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

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

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

	int ApophasiXristi;

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

	// for writing the computer move
	String^ HY_Starting_Column_Text;
	String^ HY_Finishing_Column_Text;

	// chessboard to store the chessboard squares where it is dangerous
	// for the HY to move a piece
	// SEE function ComputerMove!
	//static array<String^, 2>^ Skakiera_Dangerous_Squares = gcnew array<String^, 2>(8,8);  // ������ ������ ��� �������������� �� ��������

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

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

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

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

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

	int choise_of_user;

	///////////////////////////////////////////////////////////////////////////////////////////////////
	// END OF VARIABLES DECLARATION
	///////////////////////////////////////////////////////////////////////////////////////////////////

void Game() {
	/////////////////////
	// Setup game
	/////////////////////
	Console::WriteLine("Choose color: 1. White, 2. Black");
	Console::Write("CHOOSE (1-2): ");
	choise_of_user = Int32::Parse(Console::ReadLine());

	switch(choise_of_user)
	{
	case 1:
		m_PlayerColor = "White";
		m_WhoPlays = "Human";
		break;

	case 2:
		m_PlayerColor = "Black";
		m_WhoPlays = "HY";
		break;
	};

	Console::WriteLine("");

	/////////////////////////////////////////////////////////////////////////
	// �������: �� ���� ��� ���������� �� ������� �� ����� 1 �������
	// (���� Thinking_Depth = 0), ���� ��� ��������� �����! ���� ���������
	// ����� � HumanMove ������ �� ������ ����������� ��� ���� ��� ��
	// ����������� ����� ����������� ���� ������ ������ ������ ��� ��.
	/////////////////////////////////////////////////////////////////////////
	//Console::WriteLine("Choose computer level: 1. Maitre (thinking depth: 3 half-moves)");
	//Console::WriteLine("                       2. Grand Maitre (thinking depth: 5 half-moves)");
	//Console::WriteLine("                       3. World Champion (thinking depth: 7 half-moves)");
	//Console::WriteLine("                       4. Spiros Kakos! (thinking depth: 9 half-moves)");

	//Console::WriteLine("");
	//Console::Write("Enter your choice (1-4): ");
	//choise_of_user = Int32::Parse(Console::ReadLine());

	//switch(choise_of_user)
	//{
	//case 1:
		m_ComputerLevel = "M";
		Thinking_Depth = 2;
	//	break;

	//case 2:
	//	m_ComputerLevel = "GM";
	//	Thinking_Depth = 4;
	//	break;

	//case 3:
	//	m_ComputerLevel = "World Champion";
	//	Thinking_Depth = 6;
	//	break;

	//case 4:
	//	m_ComputerLevel = "Spiros Kakos";
	//	Thinking_Depth = 8;
	//	break;

	//default:
	//	m_ComputerLevel = "";
	//	break;
	//};

	Console::WriteLine( "Huo Chess v0.51D by Spiros I.Kakos (huo) [2008]" );

	// 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
	this->Starting_position();

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

	bool exit_game = false;

	do
	{

	if ( m_WhoPlays->CompareTo("HY") == 0 )
	{
		// call HY Thought function
		Move = 0;

		if( Move == 0 )
		{
			Console::WriteLine("");
			Console::WriteLine("Thinking...");
		}

		Move_Analyzed = 0;
		Stop_Analyzing = false;
		First_Call = true;
		Best_Move_Found = false;
		Who_Is_Analyzed = "HY";
		ComputerMove(Skakiera);
	}
	else if ( m_WhoPlays->CompareTo("Human") == 0 )
	{
		////////////////////////////
		// Human enters his move
		////////////////////////////
		Console::WriteLine("");
		Console::Write("Starting column (A to H)...");
		m_StartingColumn = Console::ReadLine()->ToUpper();

		Console::Write("Starting rank (1 to 8).....");
		m_StartingRank = Int32::Parse(Console::ReadLine());

		Console::Write("Finishing column (A to H)...");
		m_FinishingColumn = Console::ReadLine()->ToUpper();

		Console::Write("Finishing rank (1 to 8).....");
		m_FinishingRank = Int32::Parse(Console::ReadLine());

		// show the move entered

		String^ Move = String::Concat("Your move: ", m_StartingColumn, m_StartingRank.ToString(), " --> " );
		Move = String::Concat( Move, m_FinishingColumn, m_FinishingRank.ToString() );
		Console::WriteLine( Move );
		Console::WriteLine("");
		Console::WriteLine("Thinking...");

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

	}while(exit_game == false);

	}



bool CheckForBlackCheck(array<String^, 2>^ 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;
	}


		
bool CheckForBlackMate(array<String^, 2>^ 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;
	}





	
bool CheckForWhiteCheck(array<String^, 2>^ 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;
	}



	
bool CheckForWhiteMate(array<String^, 2>^ 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);

		if (WhiteKingCheck == false)
			DangerForMate = false;

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

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

	}

	}

	if (DangerForMate == true)
		Mate = true;

	}

	return Mate;
	}


		
void CheckMove(array<String^, 2>^ CMSkakiera)               
	{    
	// Assign values to m_WhoPlays and m_WrongColumn variables,
	// which are necessary for the proper function of ElegxosNomimotitas and ElegxosOrthotitas
	m_WhoPlays = "Human";
	m_WrongColumn = false;
	MovingPiece = CMSkakiera[(m_StartingColumnNumber - 1),(m_StartingRank - 1)];

	// Check correctness of move
	m_OrthotitaKinisis = ElegxosOrthotitas(CMSkakiera);
	// if move is correct, then check the legality also
	if( m_OrthotitaKinisis == true )
		m_NomimotitaKinisis = ElegxosNomimotitas(CMSkakiera);

	// restore the normal value of the m_WhoPlays
	m_WhoPlays = "HY";

	///////////////////////////////////////////////////////////////////////////////////////////////////////////
	// CHECK FOR MATE
	///////////////////////////////////////////////////////////////////////////////////////////////////////////

	if (((m_OrthotitaKinisis == true)&&(m_NomimotitaKinisis == true))&&(Move_Analyzed == 0))
	{

	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// temporarily move the piece to see if the king will continue to be under check
	/////////////////////////////////////////////////////////////////////////////////////////////////////////

	CMSkakiera[(m_StartingColumnNumber - 1),(m_StartingRank - 1)] = "";
	ProsorinoKommati = CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)];   // ��������� ���������� ���
																					 // ��������� ��� ��������� ���
	                                                                                 // ��������� ����������
	                                                                                 // (��. ���� ��� �� �����������
	                                                                                 // ���, ���� ��� ������� ����-
	                                                                                 // ��� ��� �� �� ��������� ��
	                                                                                 // ��������� ���).

	CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = MovingPiece;


	//////////////////////////////////////////////////////////////////////////
	// is the king still under check?
	//////////////////////////////////////////////////////////////////////////
	
	WhiteKingCheck = CheckForWhiteCheck(CMSkakiera);

	if ( (m_WhichColorPlays->CompareTo("White") == 0) && (WhiteKingCheck == true) )
	{
		m_NomimotitaKinisis = false;
	}


	///////////////////////////////////////////////////////////////////////////
	// is the black king under check?
	///////////////////////////////////////////////////////////////////////////

	BlackKingCheck = CheckForBlackCheck(CMSkakiera);

	if ( (m_WhichColorPlays->CompareTo("Black") == 0) && (BlackKingCheck == true) )
	{
		m_NomimotitaKinisis = false;
	}


	// restore pieces to their initial positions
	CMSkakiera[(m_StartingColumnNumber - 1),(m_StartingRank - 1)] = MovingPiece;
	CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = ProsorinoKommati;

	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// end of checking in the king is still under check!
	////////////////////////////////////////////////////////////////////////////////////////////////////////////

	// restore the normal value of m_WhoPlays
	m_WhoPlays = "HY";


	// check if HY moves the king next to the king of the opponent
	// (this case is not controlled in the lines above)
	if( MovingPiece->CompareTo("White King") == 0 )
	{
		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1 + 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1) >= 0) && ((m_FinishingColumnNumber - 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1 + 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1 + 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1) >= 0) && ((m_FinishingRank - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1 - 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1) >= 0) && ((m_FinishingColumnNumber - 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1 - 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1 - 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1) >= 0) && ((m_FinishingRank - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1)]->CompareTo("Black King") == 0)
				m_NomimotitaKinisis = false;
		}
	}


	if( MovingPiece->CompareTo("Black King") == 0 )
	{
		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1 + 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1) >= 0) && ((m_FinishingColumnNumber - 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1 + 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1 + 1) >= 0) && ((m_FinishingRank - 1 + 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1 + 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1) >= 0) && ((m_FinishingRank - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 - 1) >= 0) && ((m_FinishingColumnNumber - 1 - 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 - 1),(m_FinishingRank - 1 - 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1) >= 0) && ((m_FinishingColumnNumber - 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1 - 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1 - 1) >= 0) && ((m_FinishingRank - 1 - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1 - 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}

		if( ((m_FinishingColumnNumber - 1 + 1) >= 0) && ((m_FinishingColumnNumber - 1 + 1) <= 7) && ((m_FinishingRank - 1) >= 0) && ((m_FinishingRank - 1) <= 7) )
		{
			if(CMSkakiera[(m_FinishingColumnNumber - 1 + 1),(m_FinishingRank - 1)]->CompareTo("White King") == 0)
				m_NomimotitaKinisis = false;
		}
	}

	
	// if the move under analysis is correct and legal, then do it and measure its score

	if ((m_OrthotitaKinisis == true)&&(m_NomimotitaKinisis == true))
	{
		// temporarily perform the move
		ProsorinoKommati = CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)];
		CMSkakiera[(m_StartingColumnNumber - 1),(m_StartingRank - 1)] = "";
		CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = MovingPiece;


		// check is there is a pawn promotion
		if (m_FinishingRank == 8)
		{
			CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = "White Queen";
			Promotion_Occured = true;
		}
		else if (m_FinishingRank == 1)
		{
			CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = "Black Queen";
			Promotion_Occured = true;
		}


		// store the move to ***_HY variables (because after continuous calls of ComputerMove the initial move under analysis will be lost...)
		if ( (Move_Analyzed == 0) && ( ((m_PlayerColor->CompareTo("White") == 0) && ((MovingPiece->CompareTo("Black Pawn") == 0)||(MovingPiece->CompareTo("Black Rook") == 0)||(MovingPiece->CompareTo("Black Knight") == 0)||(MovingPiece->CompareTo("Black Bishop") == 0)||(MovingPiece->CompareTo("Black Queen") == 0)||(MovingPiece->CompareTo("Black King") == 0)))     ||     ((m_PlayerColor->CompareTo("Black") == 0) && ((MovingPiece->CompareTo("White Pawn") == 0)||(MovingPiece->CompareTo("White Rook") == 0)||(MovingPiece->CompareTo("White Knight") == 0)||(MovingPiece->CompareTo("White Bishop") == 0)||(MovingPiece->CompareTo("White Queen") == 0)||(MovingPiece->CompareTo("White King") == 0))) ) )
		{
			// check is HY eats the opponents queen
			// (so it is preferable to do so...)
			// Changed in version 0.5
			//if(( ProsorinoKommati->CompareTo("White Queen") == 0) || ( ProsorinoKommati->CompareTo("Black Queen") == 0))
			//	this->eat_queen = true;
			//else
			//	this->eat_queen = false;

			MovingPiece_HY = MovingPiece;
			m_StartingColumnNumber_HY = m_StartingColumnNumber;
			m_FinishingColumnNumber_HY = m_FinishingColumnNumber;
			m_StartingRank_HY = m_StartingRank;
			m_FinishingRank_HY = m_FinishingRank;
		}

		// if the HY moves its king in the initial moves, then there is a penalty
		if( (MovingPiece_HY->CompareTo("White King") == 0) || (MovingPiece_HY->CompareTo("Black King") == 0) )
			moving_the_king = true;
		else
			moving_the_king = false;

		if ((First_Call == true)&&(Move_Analyzed == this->Thinking_Depth))
		{
			Best_Move_StartingColumnNumber = m_StartingColumnNumber_HY;
			Best_Move_FinishingColumnNumber = m_FinishingColumnNumber_HY;
			Best_Move_StartingRank = m_StartingRank_HY;
			Best_Move_FinishingRank = m_FinishingRank_HY;

			// Measure the move score
			CountScore(CMSkakiera);
			Best_Move_Score = Current_Move_Score;
			
			First_Call = false;
			Best_Move_Found = true;
		}

		if (Move_Analyzed == Thinking_Depth)
		{
		// Measure the move score
		CountScore(CMSkakiera);

		// HUO DEBUG
		// If the computer loses its queen...then penalty!
		//if(this->LoseQueen_penalty == true)
		//{
			//Console::WriteLine("Danger penalty noted!");
		//	if(m_PlayerColor->CompareTo("White") == 0)
		//		Current_Move_Score = Current_Move_Score + 50;
		//	else if(m_PlayerColor->CompareTo("Black") == 0)
		//		Current_Move_Score = Current_Move_Score - 50;
		//}

		// record the score as the best move score, if it is the best
		// move score!
		// HUO DEBUG
		//if(this->LoseQueen_penalty == false)
		//{
		//Console::WriteLine("Checked move...");
		if ( ((m_PlayerColor->CompareTo("Black") == 0)&&(Current_Move_Score > Best_Move_Score)) || ((m_PlayerColor->CompareTo("White") == 0)&&(Current_Move_Score < Best_Move_Score)) )
		{
			// HUO DEBUG
			//StreamWriter^ swer = gcnew StreamWriter("BestMoves.txt",true);
			//swer->WriteLine(String::Concat((m_StartingColumnNumber_HY).ToString(),(m_StartingRank_HY).ToString(),(m_FinishingColumnNumber_HY).ToString(),(m_FinishingRank_HY).ToString(),"  : Best Move Found!"));
			//swer->Close();

			Best_Move_StartingColumnNumber = m_StartingColumnNumber_HY;
			Best_Move_FinishingColumnNumber = m_FinishingColumnNumber_HY;
			Best_Move_StartingRank = m_StartingRank_HY;
			Best_Move_FinishingRank = m_FinishingRank_HY;
			Best_Move_Score = Current_Move_Score;
		}
		else if ( ( Current_Move_Score == Best_Move_Score ) && ( ((m_PlayerColor->CompareTo("White") == 0) && ((MovingPiece->CompareTo("Black Pawn") == 0)||(MovingPiece->CompareTo("Black Rook") == 0)||(MovingPiece->CompareTo("Black Knight") == 0)||(MovingPiece->CompareTo("Black Bishop") == 0)||(MovingPiece->CompareTo("Black Queen") == 0)||(MovingPiece->CompareTo("Black King") == 0)))     ||     ((m_PlayerColor->CompareTo("Black") == 0) && ((MovingPiece->CompareTo("White Pawn") == 0)||(MovingPiece->CompareTo("White Rook") == 0)||(MovingPiece->CompareTo("White Knight") == 0)||(MovingPiece->CompareTo("White Bishop") == 0)||(MovingPiece->CompareTo("White Queen") == 0)||(MovingPiece->CompareTo("White King") == 0))) ) )
		{
			// if score of move analyzed is equal to so-far best move score, then
			// let chance ('����' in Greek) decide to which move will be kept as best move
			// (target: maximize variety of computer game)
			// REMOVE THIS PART TO MAXIMIZE THE STABILITY OF COMPUTER GAME PLAY
			// �� �� ���� ��� ������� ��� ��������� ����� ��� �� �� ���� ��� ��� ���� ��������� �������, ����
			// �������� �� ���������� � ���� ��� �� �� � ������ ���� �� �������������� ��� ��� ���� ��������.
			// ������: � �������� ��� ��������� ��� �������� ��� ����������.

			Random^ random_number = gcnew Random();
			int Arithmos = random_number->Next(1, 20);

			if (Arithmos > 13)
			{
			Best_Move_StartingColumnNumber = m_StartingColumnNumber_HY;
			Best_Move_FinishingColumnNumber = m_FinishingColumnNumber_HY;
			Best_Move_StartingRank = m_StartingRank_HY;
			Best_Move_FinishingRank = m_FinishingRank_HY;
			Best_Move_Score = Current_Move_Score;
			}
		}
		//}

		////////////////////////////////////////////////////////////////////////
		// restore the pieces to their initial positions
		////////////////////////////////////////////////////////////////////////
		for (i = 0; i <= 7; i++)
		{
			for (j = 0; j <= 7; j++)
			{
				Skakiera[(i),(j)] = Skakiera_Move_0[(i),(j)];
			}
		}

		// restore promoted pawn (if exists)
		if ((m_FinishingRank == 8) && (Promotion_Occured == true))
		{
			CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = "White Pawn";
			Promotion_Occured = false;
		}
		else if ((m_FinishingColumnNumber == 1) && (Promotion_Occured == true))
		{
			CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = "Black Pawn";
			Promotion_Occured = false;
		}

		// restore pieces
		CMSkakiera[(m_StartingColumnNumber - 1),(m_StartingRank - 1)] = MovingPiece;
		CMSkakiera[(m_FinishingColumnNumber - 1),(m_FinishingRank - 1)] = ProsorinoKommati;
		}

	///////////////////////////////////////////////////////////////////////////////////////
	// NOW CHECK FOR POSSIBLE ANSWERS BY THE OPPONENT
	///////////////////////////////////////////////////////////////////////////////////////

	if (Move_Analyzed < Thinking_Depth)
	{
		//////////////////////////////////////////////////////////////
		// is human's king in check?
		//////////////////////////////////////////////////////////////
		Human_is_in_check = false;
		
		WhiteKingCheck = CheckForWhiteCheck(CMSkakiera);
		if ( (this->m_PlayerColor->CompareTo("White") == 0) && (WhiteKingCheck == true) )
			Human_is_in_check = true;

		BlackKingCheck = CheckForBlackCheck(CMSkakiera);
		if ( (this->m_PlayerColor->CompareTo("Black") == 0) && (BlackKingCheck == true) )
			Human_is_in_check = true;

		Move_Analyzed = Move_Analyzed + 1;

		for (i = 0; i <= 7; i++)
		{
			for (j = 0; j <= 7; j++)
			{
				Skakiera_Move_After[(i),(j)] = CMSkakiera[(i),(j)];
			}
		}

		Who_Is_Analyzed = "Human";
		First_Call_Human_Thought = true;
		
		// check human move (to find the best possible answer of the human
		// to the move currently analyzed by the HY Thought process)
		HumanMove(Skakiera_Move_After);
	}

	} 
	}


		
void ComputerMove(array<String^, 2>^ Skakiera_Thinking_init)              
{     
	// set mate=false, to avoid false alarms for mate.
	// if the program finds out in a next step that mate exists,
	// then it will tell it to you, don't worry! :)
	Mate = false;

	int iii;
	int jjj;

	if (First_Call == true)
	{
			// store the initial position in the chessboard
			for (iii = 0; iii <= 7; iii++)
			{
				for (jjj = 0; jjj <= 7; jjj++)
				{
					Skakiera_Thinking[iii,jjj] = Skakiera_Thinking_init[(iii),(jjj)];
					Skakiera_Move_0[(iii),(jjj)] = Skakiera_Thinking_init[(iii),(jjj)];
				}
			}
	}


	// check is computer has thought as far as the ThinkingDepth dictates
	if (Move_Analyzed > Thinking_Depth)
		Stop_Analyzing = true;

	////////////////////////////////////////////////////////////////////////
	// CHECK IF POSITION IS IN THE OPENING BOOK
	////////////////////////////////////////////////////////////////////////

	int op_iii;
	int op_jjj;

	int opening = 1;

	bool exit_opening_loop = false;
	// ��������� ��� ������������ �� �� ������� ��������� ��� �������� ����� �� ������ ��� ��� ������ ��� �������� ������������� ��� ������ ���������� ��� ��
	bool match_found;

	String^ line_in_opening_book;

	do
	{
		if( File::Exists(String::Concat("Huo Chess Opening Book\\",opening.ToString(),".txt")) )
		{
			// ������� ��� ������� .txt ��� �������� � ���� ��������� ��� ��
			StreamReader^ sr = gcnew StreamReader(String::Concat("Huo Chess Opening Book\\",opening.ToString(),".txt"));
			match_found = true;

			for (op_iii = 0; op_iii <= 7; op_iii++)
			{
				for (op_jjj = 0; op_jjj <= 7; op_jjj++)
				{
					line_in_opening_book = sr->ReadLine();
					if(Skakiera_Thinking[op_iii,op_jjj]->CompareTo(line_in_opening_book) != 0)
						match_found = false;
				}
			}

			// �� ������� ��� ���� ��� ����� ������������ ��� ������ ����������,
			// ���� ������� ��� ��� �������� ������ ��� ������ text �� ������ ���������
			// ��� ������ ��� ������ �� ����� � �� ���� ������� ����.

			if( match_found == true )
			{
				// ���� ������� ����, ���� ��� ���������� ��������� �������.
				exit_opening_loop = true;

				// ���� ������� ����, ���� � �� ��� ���������� �� ������� ��� ��� ������ ���, ��� ���� ���� ������!
				Stop_Analyzing = true;

				// �������� ��� ����� ������� ��� ������� ��� ������.
				line_in_opening_book = sr->ReadLine();

				line_in_opening_book = sr->ReadLine();
				Best_Move_StartingColumnNumber = Int32::Parse(line_in_opening_book);
				line_in_opening_book = sr->ReadLine();
				Best_Move_StartingRank = Int32::Parse(line_in_opening_book);

				line_in_opening_book = sr->ReadLine();
				Best_Move_FinishingColumnNumber = Int32::Parse(line_in_opening_book);
				line_in_opening_book = sr->ReadLine();
				Best_Move_FinishingRank = Int32::Parse(line_in_opening_book);
			}
		}
		else
		{
			exit_opening_loop = true;
		}

		opening = opening + 1;
	}while(exit_opening_loop == false);

	//////////////////////////////////////
	// END OF OPENING BOOK CHECK
	//////////////////////////////////////

	if (Stop_Analyzing == false)
	{
	array<String^, 2>^ Skakiera_Dangerous_Squares = gcnew array<String^, 2>(8,8);
	array<int, 2>^ Number_of_defenders = gcnew array<int,2>(8,8);
	array<int, 2>^ Number_of_attackers = gcnew array<int,2>(8,8);
	array<int, 2>^ Value_of_defenders = gcnew array<int,2>(8,8);
	array<int, 2>^ Value_of_attackers = gcnew array<int,2>(8,8);
	array<int, 2>^ Exception_defender_column = gcnew array<int,2>(8,8);
	array<int, 2>^ Exception_defender_rank = gcnew array<int,2>(8,8); 

	// Scan the chessboard -> if a piece of HY is found -> check all
	// possible destinations in the chessboard -> check correctness of
	// the move analyzed -> check legality of the move analyzed -> if
	// correct and legal, then do the move.
	// NOTE: In all column and rank numbers I add +1, because I must transform
	// them from the 0...7 'measure system' of the chessboard (='Skakiera' in Greek) table
	// to the 1...8 'measure system' of the chessboard.

	// find the dangerous squares in the chessboard, where if the HY
	// moves its piece, will immediately loose it.
	for(i=0;i<=7;i++)
	{
		for(j=0;j<=7;j++)
		{
			Skakiera_Dangerous_Squares[i,j] = "";
		}
	}

	// Changed in version 0.5
	// Initialize variables for finfind the dangerous squares
	for(int di=0;di<=7;di++)
	{
		for(int dj=0;dj<=7;dj++)
		{
			Number_of_attackers[di,dj] = 0;
			Number_of_defenders[di,dj] = 0;
			Value_of_attackers[di,dj] = 0;
			Value_of_defenders[di,dj] = 0;
			Exception_defender_column[di,dj] = -9;
			Exception_defender_rank[di,dj] = -9;
		}
	}

	for (int iii2 = 0; iii2 <= 7; iii2++)
	{
		for (int jjj2 = 0; jjj2 <= 7; jjj2++)
		{
	if ( (( ( ((Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White King") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White Queen") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White Rook") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White Knight") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White Bishop") == 0)  || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("White Pawn") == 0)) && (m_PlayerColor->CompareTo("White") == 0) ) || ( ((Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black King") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black Queen") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black Rook") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black Knight") == 0) || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black Bishop") == 0)  || (Skakiera_Thinking[(iii2),(jjj2)]->CompareTo("Black Pawn") == 0)) && (m_PlayerColor->CompareTo("Black") == 0) ) ) )  )
	{
	
	// find squares where the human opponent can hit
		for( int w2=0; w2<=7; w2++)
		{
			for( int r2=0; r2<=7; r2++)
			{
				MovingPiece = Skakiera_Thinking[(iii2),(jjj2)];
				m_StartingColumnNumber = iii2+1;
				m_FinishingColumnNumber = w2+1;
				m_StartingRank = jjj2+1;
				m_FinishingRank = r2+1;

				// check the move
				m_WhoPlays = "Human";
				m_WrongColumn = false;
				m_OrthotitaKinisis = ElegxosOrthotitas(Skakiera_Thinking);
				if( m_OrthotitaKinisis == true )
					m_NomimotitaKinisis = ElegxosNomimotitas(Skakiera_Thinking);
				// restore normal value of m_whoplays
				m_WhoPlays = "HY";
				if(( m_OrthotitaKinisis == true )&&(m_NomimotitaKinisis == true))
				{
					// Another attacker on that square found!
					Number_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Number_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 1;
					Skakiera_Dangerous_Squares[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = "Danger";
					
					//if(Skakiera_Dangerous_Squares[(m_FinishingColumnNumber-1),(m_FinishingRank-1)]->ToString()->Equals("Danger") == true)
					//	Console::WriteLine("Added new dangerous square!");

					// Calculate the value (total value) of the attackers
					if ((MovingPiece->CompareTo("White Rook") == 0)||(MovingPiece->CompareTo("Black Rook") == 0))
						Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 5;
					else if ((MovingPiece->CompareTo("White Bishop") == 0)||(MovingPiece->CompareTo("Black Bishop") == 0))
						Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 3;
					else if ((MovingPiece->CompareTo("White Knight") == 0)||(MovingPiece->CompareTo("Black Knight") == 0))
						Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 3;
					else if ((MovingPiece->CompareTo("White Queen") == 0)||(MovingPiece->CompareTo("Black Queen") == 0))
						Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 9;
					else if ((MovingPiece->CompareTo("White Pawn") == 0)||(MovingPiece->CompareTo("Black Pawn") == 0))
						Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 1;
				}
			}
		}
	}
		}
	}

	///////////////////////////////////////////////////////////////////////////////////////
	// ���������� ��� ����������� ����������
	// USE FOR DEBUGGING PURPOSES ONLY!
	//StreamWriter^ srw = gcnew StreamWriter(String::Concat("log1.txt"));
	//srw->WriteLine(String::Concat("Move: ",this->Move.ToString()));
	//srw->WriteLine("*************************************");
	//for (iii = 0; iii <= 7; iii++)
	//{
	//	for (jjj = 0; jjj <= 7; jjj++)
	//	{
	//		if(Skakiera_Dangerous_Squares[(iii),(jjj)]->ToString()->Equals("Danger") == true)
	//			srw->WriteLine(String::Concat(iii.ToString(),jjj.ToString()," DANGER!"));
	//		else if(Skakiera_Dangerous_Squares[(iii),(jjj)]->ToString()->Equals("") == true)
	//			srw->WriteLine(String::Concat(iii.ToString(),jjj.ToString()," No danger...������!"));
	//		else
	//			srw->WriteLine(String::Concat(iii.ToString(),jjj.ToString()));
	//	}
	//}
	//srw->WriteLine("**********************************");
	//srw->Close();
	/////////////////////////////////////////////////////////////////////////////////////////


	// Find squares that are also 'protected' by a piece of the HY.
	// If protected, then the square is not really dangerous

	// Changed in version 0.5
	// Initialize all variables used to find exceptions in the non-dangerous squares.
	// Exceptions definition: If human can hit a square and the computer defends it with its pieces, then the
	// square is not dangerous. However, if the computer has only one (1) piece to defend that square, then
	// it cannot move that specific piece to that square (because then the square would have no defenders and
	// would become again a dangerous square!).

	for (int iii3 = 0; iii3 <= 7; iii3++)
	{
		for (int jjj3 = 0; jjj3 <= 7; jjj3++)
		{
	if ( ((Who_Is_Analyzed->CompareTo("HY") == 0) && ( ( ((Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White King") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White Queen") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White Rook") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White Knight") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White Bishop") == 0)  || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("White Pawn") == 0)) && (m_PlayerColor->CompareTo("Black") == 0) ) || ( ((Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black King") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black Queen") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black Rook") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black Knight") == 0) || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black Bishop") == 0)  || (Skakiera_Thinking[(iii3),(jjj3)]->CompareTo("Black Pawn") == 0)) && (m_PlayerColor->CompareTo("White") == 0) ) ) ) )
	{
		for( int w1=0; w1<=7; w1++)
		{
			for( int r1=0; r1<=7; r1++)
			{
				MovingPiece = Skakiera_Thinking[(iii3),(jjj3)];
				m_StartingColumnNumber = iii3+1;
				m_FinishingColumnNumber = w1+1;
				m_StartingRank = jjj3+1;
				m_FinishingRank = r1+1;

				// ������� ��� �������
				// ������� ����� ���� ���������� m_WhoPlays ��� m_WrongColumn, �� ������ ����� ����������� ��� �� ������������ ����� �� ����������� ElegxosNomimotitas ��� ElegxosOrthotitas
				m_WhoPlays = "Human";
				m_WrongColumn = false;
				m_OrthotitaKinisis = ElegxosOrthotitas(Skakiera_Thinking);
				if( m_OrthotitaKinisis == true )
					m_NomimotitaKinisis = ElegxosNomimotitas(Skakiera_Thinking);
				// ��������� ��� ��������� ����� ��� m_WhoPlays
				m_WhoPlays = "HY";
				if(( m_OrthotitaKinisis == true )&&(m_NomimotitaKinisis == true))
				{
					// Changed in version 0.5
					// A new defender for that square is found!
					Number_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Number_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 1;
					
					// Calculate the value (total value) of the defenders
					if ((MovingPiece->CompareTo("White Rook") == 0)||(MovingPiece->CompareTo("Black Rook") == 0))
						Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 5;
					else if ((MovingPiece->CompareTo("White Bishop") == 0)||(MovingPiece->CompareTo("Black Bishop") == 0))
						Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 3;
					else if ((MovingPiece->CompareTo("White Knight") == 0)||(MovingPiece->CompareTo("Black Knight") == 0))
						Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 3;
					else if ((MovingPiece->CompareTo("White Queen") == 0)||(MovingPiece->CompareTo("Black Queen") == 0))
						Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 9;
					else if ((MovingPiece->CompareTo("White Pawn") == 0)||(MovingPiece->CompareTo("Black Pawn") == 0))
						Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] + 1;

					// Record the coordinates of the defender.
					// If the defender found is the only one, then that defender cannot move to that square,
					// since then the square would be again dangerous (since its only defender would have moved into it!)
					// If more than one defenders is found, then no exceptions exist.
					if( Number_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] == 1 )
					{
					Exception_defender_column[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = (m_StartingColumnNumber - 1);
					Exception_defender_rank[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = (m_StartingRank - 1);	
					}
					// PLAYING: Change 1 to 2 ???
					if( Number_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] > 1 )
					{
					Exception_defender_column[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = -99;
					Exception_defender_rank[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = -99;	
					}
					
					if(Skakiera_Dangerous_Squares[(m_FinishingColumnNumber-1),(m_FinishingRank-1)]->CompareTo("Danger")==0)
					{
						Skakiera_Dangerous_Squares[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] = "";				
					}
				}
			}
		}
	}
		}
	}
	///////////////////////////////////////////////////////////////
	//***********************************************************//
	///////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////////////////////
	// ���������� ��� ����������� ����������
	// USE FOR DEBUGGING PURPOSES ONLY!
	//StreamWriter^ srw2 = gcnew StreamWriter(String::Concat("log2.txt"));
	//srw2->WriteLine("AFTER CHECKING THE COMPUTER DEFENDERS");
	//srw2->WriteLine(String::Concat("Move: ",this->Move.ToString()));
	//srw2->WriteLine("*************************************");
	//for (iii = 0; iii <= 7; iii++)
	//{
	//	for (jjj = 0; jjj <= 7; jjj++)
	//	{
	//		if(Skakiera_Dangerous_Squares[(iii),(jjj)]->ToString()->Equals("Danger") == true)
	//			srw2->WriteLine(String::Concat(iii.ToString(),jjj.ToString()," DANGER!"));
	//		else
	//			srw2->WriteLine(String::Concat(iii.ToString(),jjj.ToString()));
	//	}
	//}
	//srw2->WriteLine("**********************************");
	//srw2->Close();
	////////////////////////////////////////////////////////////////////////////////////////

	for (iii = 0; iii <= 7; iii++)
	{
		for (jjj = 0; jjj <= 7; jjj++)
		{

	if ( ((Who_Is_Analyzed->CompareTo("HY") == 0) && ( ( ((Skakiera_Thinking[(iii),(jjj)]->CompareTo("White King") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Queen") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Rook") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Knight") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Bishop") == 0)  || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Pawn") == 0)) && (m_PlayerColor->CompareTo("Black") == 0) ) || ( ((Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black King") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Queen") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Rook") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Knight") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Bishop") == 0)  || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Pawn") == 0)) && (m_PlayerColor->CompareTo("White") == 0) ) ) ) || ( (Who_Is_Analyzed->CompareTo("Human") == 0) && ( ( ((Skakiera_Thinking[(iii),(jjj)]->CompareTo("White King") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Queen") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Rook") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Knight") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Bishop") == 0)  || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("White Pawn") == 0)) && (m_PlayerColor->CompareTo("White") == 0) ) || ( ((Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black King") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Queen") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Rook") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Knight") == 0) || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Bishop") == 0)  || (Skakiera_Thinking[(iii),(jjj)]->CompareTo("Black Pawn") == 0)) && (m_PlayerColor->CompareTo("Black") == 0) ) ) ))
	{
	
		for( int w=0; w<=7; w++)
		{
			for( int r=0; r<=7; r++)
			{
				// Changed in version 0.5
				this->Danger_penalty = false;
				this->Attackers_penalty = false;
				this->Defenders_value_penalty = false;

				MovingPiece = Skakiera_Thinking[(iii),(jjj)];
				m_StartingColumnNumber = iii+1;
				m_FinishingColumnNumber = w+1;
				m_StartingRank = jjj+1;
				m_FinishingRank = r+1;

				// check move, ONLY if the destination square is not
				// one of the dangerous squares found above.
				if((Skakiera_Dangerous_Squares[(m_FinishingColumnNumber-1),(m_FinishingRank-1)]->CompareTo("Danger")==0))
				{
				}
				else 
				{
						//if((Exception_defender_column[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] == (m_StartingColumnNumber-1)) && (Exception_defender_rank[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] == (m_StartingRank-1)))
						//{
						//	this->Danger_penalty = true;
						//}
						//else
						//{
							// Penalty for moving your piece to a square that the human opponent can hit with more power than the computer.
							if(Number_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] > Number_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)])
							{	this->Attackers_penalty = true;}

							// 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
							if(Value_of_attackers[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] > Value_of_defenders[(m_FinishingColumnNumber-1),(m_FinishingRank-1)])
							{	Defenders_value_penalty = true;}
							
							// 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!)
							if((Exception_defender_column[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] == (m_StartingColumnNumber-1)) && (Exception_defender_rank[(m_FinishingColumnNumber-1),(m_FinishingRank-1)] == (m_StartingRank-1)))
								this->Danger_penalty = true;

							// HUO DEBUG
							//this->LoseQueen_penalty = false;

							CheckMove(Skakiera_Thinking);
						//}
				}
					
			}
		}

	}


		}
	}


	}


	/////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// find if there is mate
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////

	if ((Move_Analyzed == 0) && ((WhiteKingCheck == true)||(BlackKingCheck == true)))
	{
	
		// �� � ����������� ��� ��������� �� ���� ����� ������ ������ �� ����� �������� ��� ��� ����� ���

		if (Best_Move_Found == false)
		{
			Mate = true;

			if (m_PlayerColor->CompareTo("White") == 0)
				Console::WriteLine("Black is MATE!");
			else if (m_PlayerColor->CompareTo("Black") == 0)
				Console::WriteLine("White is MATE!");
		}

	}


	// DO THE BEST MOVE FOUND

	if (Move_Analyzed == 0)
	{
	// ��������� ��� ����� ��� Stop_Analyzing (��. ��� ����)
	this->Stop_Analyzing = false;

	/////////////////////////////////////////////////////////////////////////////////////////////////
	// REDRAW THE CHESSBOARD
	/////////////////////////////////////////////////////////////////////////////////////////////////

		// erase the initial square
		
		for (iii = 0; iii <= 7; iii++)
		{
			for (jjj = 0; jjj <= 7; jjj++)
			{
				Skakiera[(iii),(jjj)] = Skakiera_Move_0[(iii),(jjj)];
			}
		}

		MovingPiece = Skakiera[(Best_Move_StartingColumnNumber - 1),(Best_Move_StartingRank - 1)];
		Skakiera[(Best_Move_StartingColumnNumber - 1),(Best_Move_StartingRank - 1)] = "";

		if (Best_Move_StartingColumnNumber == 1)
			this->HY_Starting_Column_Text = "a";
		else if (Best_Move_StartingColumnNumber == 2)
			this->HY_Starting_Column_Text = "b";
		else if (Best_Move_StartingColumnNumber == 3)
			this->HY_Starting_Column_Text = "c";
		else if (Best_Move_StartingColumnNumber == 4)
			this->HY_Starting_Column_Text = "d";
		else if (Best_Move_StartingColumnNumber == 5)
			this->HY_Starting_Column_Text = "e";
		else if (Best_Move_StartingColumnNumber == 6)
			this->HY_Starting_Column_Text = "f";
		else if (Best_Move_StartingColumnNumber == 7)
			this->HY_Starting_Column_Text = "g";
		else if (Best_Move_StartingColumnNumber == 8)
			this->HY_Starting_Column_Text = "h";

		// position piece to the square of destination

		Skakiera[(Best_Move_FinishingColumnNumber - 1),(Best_Move_FinishingRank - 1)] = MovingPiece;

		if (Best_Move_FinishingColumnNumber == 1)
			this->HY_Finishing_Column_Text = "a";
		else if (Best_Move_FinishingColumnNumber == 2)
			this->HY_Finishing_Column_Text = "b";
		else if (Best_Move_FinishingColumnNumber == 3)
			this->HY_Finishing_Column_Text = "c";
		else if (Best_Move_FinishingColumnNumber == 4)
			this->HY_Finishing_Column_Text = "d";
		else if (Best_Move_FinishingColumnNumber == 5)
			this->HY_Finishing_Column_Text = "e";
		else if (Best_Move_FinishingColumnNumber == 6)
			this->HY_Finishing_Column_Text = "f";
		else if (Best_Move_FinishingColumnNumber == 7)
			this->HY_Finishing_Column_Text = "g";
		else if (Best_Move_FinishingColumnNumber == 8)
			this->HY_Finishing_Column_Text = "h";

		// if king is moved, no castling can occur
		if (MovingPiece->CompareTo("White King") == 0)
			White_King_Moved = true;
		else if (MovingPiece->CompareTo("Black King") == 0)
			Black_King_Moved = false;
		else if (MovingPiece->CompareTo("White Rook") == 0)
		{
            if ((Best_Move_StartingColumnNumber == 1) && (Best_Move_StartingRank == 1))
				White_Rook_a1_Moved = false;
			else if ((Best_Move_StartingColumnNumber == 8) && (Best_Move_StartingRank == 1))
				White_Rook_h1_Moved = false;
		}
		else if (MovingPiece->CompareTo("Black Rook") == 0)
		{
			if ((Best_Move_StartingColumnNumber == 1) && (Best_Move_StartingRank == 8))
				Black_Rook_a8_Moved = false;
			else if ((Best_Move_StartingColumnNumber == 8) && (Best_Move_StartingRank == 8))
				Black_Rook_h8_Moved = false;
		}
			
		// is there a pawn to promote?
		if ( ( (MovingPiece->CompareTo("White Pawn") == 0) || (MovingPiece->CompareTo("Black Pawn") == 0) ) && (m_WhoPlays->CompareTo("HY") == 0) )
		{

			if (Best_Move_FinishingRank == 8)
			{
				Skakiera[(Best_Move_FinishingColumnNumber - 1),(Best_Move_FinishingRank - 1)] = "White Queen";
				Console::WriteLine( "���� ���������!" );
			}
			else if (Best_Move_FinishingRank == 1)
			{
				Skakiera[(Best_Move_FinishingColumnNumber - 1),(Best_Move_FinishingRank - 1)] = "Black Queen";
				Console::WriteLine( "���� ���������!" );
			}

		}


	//////////////////////////////////////////////////////////////////////
	// show HY move
	//////////////////////////////////////////////////////////////////////
	String^ NextLine= String::Concat( HY_Starting_Column_Text, Best_Move_StartingRank.ToString(), " -> ", HY_Finishing_Column_Text, Best_Move_FinishingRank.ToString() );
	Console::WriteLine(String::Concat("My move is: ", NextLine));

	// �� � ����������� ������ �� �� �����, ���� ��������� ���� �� ������� ��� �������.
	if(this->m_PlayerColor->CompareTo("Black") == 0)
		Move = Move + 1;

	// now it is the other color's turn to play
	if (m_PlayerColor->CompareTo("Black") == 0)
		m_WhichColorPlays = "Black";
	else if (m_PlayerColor->CompareTo("White") == 0)
		m_WhichColorPlays = "White";

	// now it is the human's turn to play
	m_WhoPlays = "Human";

	}
	else
	{
		Move_Analyzed = Move_Analyzed - 2;
		Who_Is_Analyzed = "HY";
		for (i = 0; i <= 7; i++)
		{
			for (j = 0; j <= 7; j++)
			{
				Skakiera_Thinking[i,j] = Skakiera_Move_0[i,j];
			}
		}
	}
}

void CountScore(array<String^, 2>^ CSSkakiera)             
	{      
	// Changed in version 0.5
	// white pieces: positive score
	// black pieces: negative score

	Current_Move_Score = 0;

	// Changed in version 0.5
	// PENALTIES SECTION
	// (see ComputerMove for explanation of the Dangerous Squares)
	
	if(this->Danger_penalty == true)
	{
		if(this->m_PlayerColor->CompareTo("White") == 0)
			Current_Move_Score = Current_Move_Score + 0.5;
		else if(this->m_PlayerColor->CompareTo("Black") == 0)
			Current_Move_Score = Current_Move_Score - 0.5;
	}

	if(this->Attackers_penalty == true)
	{
		if(this->m_PlayerColor->CompareTo("White") == 0)
			Current_Move_Score = Current_Move_Score + 0.4;
		else if(this->m_PlayerColor->CompareTo("Black") == 0)
			Current_Move_Score = Current_Move_Score - 0.4;
	}

	if(Defenders_value_penalty == true)
	{
		if(this->m_PlayerColor->CompareTo("White") == 0)
			Current_Move_Score = Current_Move_Score + 0.4;
		else if(this->m_PlayerColor->CompareTo("Black") == 0)
			Current_Move_Score = Current_Move_Score - 0.4;
	}

	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			if (CSSkakiera[(i),(j)]->CompareTo("White Pawn") == 0)
			{
				Current_Move_Score = Current_Move_Score + 1;

				// if the pawn goes to be a queen
				// (to avoid having the HY continuously going forward
				// with the pawn so as to promote them!)
				if( this->m_PlayerColor->CompareTo("White") == 0 )
				{
					if( j == 5 )
						Current_Move_Score = Current_Move_Score + 0.5;
					else if( j == 6 )
						Current_Move_Score = Current_Move_Score + 1.5;
					else if( j == 7 )
						Current_Move_Score = Current_Move_Score + 3;
				}
			}
			else if (CSSkakiera[(i),(j)]->CompareTo("White Rook") == 0)
				Current_Move_Score = Current_Move_Score + 5;
			else if (CSSkakiera[(i),(j)]->CompareTo("White Knight") == 0)
				Current_Move_Score = Current_Move_Score + 3;
			else if (CSSkakiera[(i),(j)]->CompareTo("White Bishop") == 0)
				Current_Move_Score = Current_Move_Score + 3;
			else if (CSSkakiera[(i),(j)]->CompareTo("White Queen") == 0)
			{
//				if( this->m_PlayerColor->CompareTo("White") == 0 )
					Current_Move_Score = Current_Move_Score + 9;
//				else if( this->m_PlayerColor->CompareTo("Black") == 0 )
//					Current_Move_Score = Current_Move_Score + 10;
			}
			else if (CSSkakiera[(i),(j)]->CompareTo("White King") == 0)
			{
				// king with small score, because if he had a great score,
				// then the HY would conduct all his moves with the goal
				// to eat or threaten the opponent's king!
				Current_Move_Score = Current_Move_Score + 5;
			}
			else if (CSSkakiera[(i),(j)]->CompareTo("Black Pawn") == 0)
			{
				Current_Move_Score = Current_Move_Score - 1;
				if( this->m_PlayerColor->CompareTo("Black") == 0 )
				{
					if( j == 2 )
						Current_Move_Score = Current_Move_Score - 0.5;
					else if( j == 1 )
						Current_Move_Score = Current_Move_Score - 1.5;
					else if( j == 0 )
						Current_Move_Score = Current_Move_Score - 3;
				}

				
				// the f7 pawn is valuable!
				//if( this->m_PlayerColor->CompareTo("White") == 0 )
				//{
				//if( CSSkakiera[(5),(6)]->CompareTo("Black Pawn") == 0 )
				//{
				//	if( this->Move < 10 )
				//		Current_Move_Score = Current_Move_Score - 4;
				//}
				//}
			}
			else if (CSSkakiera[(i),(j)]->CompareTo("Black Rook") == 0)
				Current_Move_Score = Current_Move_Score - 5;
			else if (CSSkakiera[(i),(j)]->CompareTo("Black Knight") == 0)
				Current_Move_Score = Current_Move_Score - 3;
			else if (CSSkakiera[(i),(j)]->CompareTo("Black Bishop") == 0)
				Current_Move_Score = Current_Move_Score - 3;
			else if (CSSkakiera[(i),(j)]->CompareTo("Black Queen") == 0)
			{
//				if( this->m_PlayerColor->CompareTo("White") == 0 )
//					Current_Move_Score = Current_Move_Score - 10;
//				else if( this->m_PlayerColor->CompareTo("Black") == 0 )
					Current_Move_Score = Current_Move_Score - 9;
			}
			else if (CSSkakiera[(i),(j)]->CompareTo("Black King") == 0)
			{
				Current_Move_Score = Current_Move_Score - 5;
			}

		}
	}

	// if we are in the beginning of the game, it is not good to move
	// your queen, king, rooks etc...

	if (Move < 11)
	{

	// control the center with your pawns

	if (CSSkakiera[3,2]->CompareTo("White Pawn") == 0)
		Current_Move_Score = Current_Move_Score + 0.4;
		
	if (CSSkakiera[3,3]->CompareTo("White Pawn") == 0)
		Current_Move_Score = Current_Move_Score + 0.4;