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

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

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

/////////////////////////////////////////////
// Huo Chess                               //
// version: 0.6                            //
// Year: 2008                              //
// Place: Earth                            //
// Programmed by Spiros I. Kakos (huo)     //
// License: TOTALLY FREEWARE!              //
//          Do anything you want with it!  //
//          Spread the knowledge!          //
//          Fix its bugs!                  //
//          Sell it (if you can...)!       //
//          Call me for help!              //
// Site: www.kakos.com.gr                  //
//       www.kakos.eu                      //
/////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////
// MAIN ALGORITHM
// 1. hym: Scans the chessboard and makes all possible moves.
// 2. chm: It checks the legality and correctness of these possible moves.
// 3. (if thinking depth not reached) => call hm
// 4. hm: chs and finds the best answer of the human opponent.
// 5. hym2: Scans the chessboard and makes all possible moves at the next thinking level.
// 6. chm: It checks the legality and correctness of these possible moves.
// 7. (if thinking depth not reached) => call hm
// 8. hm: chs and finds the best answer of the human opponent.
// 9. hym4: Scans the chessboard and makes all possible moves at the next thinking level.
// 10. chm: It checks the legality and correctness of these possible moves.
// 11. (if thinking depth reached) => record the score of the final position.
// 12. (if score of position the best so far) => record the move as best move!
// 13. The algorithm continues until all possible moves are scanned.
// SET huodebug to TRUE to see live the progress of the computer thought!
// FIND us at Codeproject (www.codeproject.com) or MSDN Code Gallery!
////////////////////////////////////////////////////////////////////////////////////////////

//#include "stdafx.h"

using namespace System;

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

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

	// Variable to note if the computer moves its piece to a square threatened by a pawn
	bool a9;
	bool a10;
	bool a11;
	bool a12;
	bool a13;

	// Variable which determines of the program will show the inner
	// thinking process of the AI. Good for educational purposes!!!
	// UNCOMMENT TO SHOW INNER THINKING MECHANISM!
	//bool huodebug;

	// Arrays to use in hym 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 h1;
	//bool LoseQueenpenalty;
	// Penalty for moving your piece to a square that the human opponent can hit with more power than the computer.
	bool a7;
	// 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 a6;

	String^ a4;   
	//String^ a3; 
	String^ a2;      
	String^ a1; 
	String^ a5;      

	// variable to store temporarily the piece that is moving
	String^ PK; 
	String^ h2; 

	// variables to check the legality of the move
	static bool a8 = false;
	int h;
	int p;
	int h3;
	int h4;
	int h5;

	// NEW
	//int h6;
	bool h7;

	// coordinates of the starting square of the move
	String^ h8;
	int h9;
	String^ q1;
	int q2;

	// variable for en passant moves
	bool q3;

	// move number
	int m;

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

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

	// variables to help find out if it is legal for the computer to perform castling
	static bool q6 = false;
	static bool q7 = false;
	static bool q8 = false;
	static bool q9 = false;
	static bool w1 = false;
	static bool w2 = false;
	static bool w3;
	static bool w4;
	static bool w5;
	static bool w6;
	
	// variables to show where the kings are in the chessboard
	int w7;      
    int w8;        
	int w9;      
    int e1;        

	// variables to show if king is in check
	bool e2;
	bool e3;

	// variables to show if there is a possibility for k9
	//bool e4;
	//bool e5;
	bool k9;

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

	// variables to help find if a king is under check.
	// (see chForWHch and chForBLch functions)
	bool e7;
	bool e8;
	bool e9;
	bool e10;
	bool e11;
	bool e12;
	bool e13;
	bool e14;

	// initial coordinates of the two kings
	// (see chForWHch and chForBLch functions)
	int e15;
	int e16;
	int e17;
	int e18;

	// column number inserted by the user
	int e19;
	int e20;

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

	// variable for the correctness of the move
	bool e21;           
	// variable for the legality of the move
	bool x26;         
	// has the user entered a wrong column?
	bool x25;                

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

	//int ApophasiXristi;

	//////////////////////////////////////
	// hy Thought
	//////////////////////////////////////
	// Chessboards used for the computer throught
	static array<String^, 2>^ z1 = gcnew array<String^, 2>(8,8);  // ������ ������ ��� �������������� �� ��������
	static array<String^, 2>^ z2 = gcnew array<String^, 2>(8,8);  // ������ ������ ��� �������������� �� ��������
	static array<String^, 2>^ z3 = gcnew array<String^, 2>(8,8);  // ������ ������ ��� ��������������� ��� ����� ��� ����������.
	// rest of variables used for computer thought
	double z4;
	double z5;
	int z6;
	int z7;
	int z8;
	int x3;
	int mA;
	bool sa;
	int z9;
	int z10;
	int z11;
	int z12;
	int x24;
	bool z13;
	String^ wa;
	String^ z14;

	// for writing the computer move
	String^ x1;
	String^ x2;

	// chessboard to store the chessboard squares where it is dangerous
	// for the HY to move a piece
	// SEE function hym!
	//static array<String^, 2>^ skdousSquares = 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>^ x4 = gcnew array<String^, 2>(8,8);
	static array<String^, 2>^ x5 = gcnew array<String^, 2>(8,8);
	bool v3;
	int v2;
	int v1;
	//String^ a5h;
	//int x13;
	//int x14;
	//int x15;
	//int x16;
	double x17;
	double x18;
	int x19;
	int x20;
	int x21;
	int x22;
	bool x23;

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

	// where the player can perform en passant
	int x9;
	int x8;

	// is there a possible k9?
	bool x7;
	bool x6;

	// does the HY moves its K with the move it is analyzing?
	bool x11;

	int x12;

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

void Game() {
	/////////////////////
	// Setup game
	/////////////////////
	Console::Write("Color (w/b):");
	String^ thechoiseofuser = Console::ReadLine();

	if((thechoiseofuser->CompareTo("w") == 0)||(thechoiseofuser->CompareTo("W") == 0))
	{
		a4 = "WH";
		a2 = "h";
	}
	else if((thechoiseofuser->CompareTo("b") == 0)||(thechoiseofuser->CompareTo("B") == 0))
	{
		a4 = "BL";
		a2 = "HY";
	}

	/////////////////////////////////////////////////////////////////////////
	// UNCOMMENT THE FOLLOWING TO HAVE MORE THINKING DEPTHS
	// BUT REMEMBER TO ALSO UNCOMMENT hym4,6,8 functions and
	// the respective part in hm function that calls them!
	/////////////////////////////////////////////////////////////////////////
	// �������: �� ���� ��� ���������� �� ������� �� ����� 1 �������
	// (���� z9 = 0), ���� ��� ��������� �����! ���� ���������
	// ����� � hm ������ �� ������ ����������� ��� ���� ��� ��
	// ����������� ����� ����������� ���� ������ ������ ������ ��� ��.
	/////////////////////////////////////////////////////////////////////////
	//Console::Write("Enter level (1-4) : ");
	//x12 = Int32::Parse(Console::ReadLine());

	//switch(x12)
	//{
	//case 1:
		//a3 = "M";
		z9 = 2;
	//	break;

	//case 2:
		//a3 = "GM";
	//	z9 = 4;
	//	break;

	//case 3:
		//a3 = "World Champion";
	//	z9 = 6;
	//	break;

	//case 4:
		//a3 = "Spiros Kakos";
	//	z9 = 8;
	//	break;

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

	////////////////////////////////////////////////////////////
	// SHOW THE INNER THINKING PROCESS OF THE COMPUTER?
	// GOOD FOR EDUCATIONAL PURPOSES!
	// SET huodebug to TRUE to show inner thinking process!
	////////////////////////////////////////////////////////////
	//Console::Write("Show thinking process (y/n)? ");
	//thechoiseofuser = Console::ReadLine();
	//if((thechoiseofuser->CompareTo("y") == 0)||(thechoiseofuser->CompareTo("Y") == 0))
	//	huodebug = true;
	//else if((thechoiseofuser->CompareTo("n") == 0)||(thechoiseofuser->CompareTo("N") == 0))
	//	huodebug = false;

	Console::WriteLine( "\nHuo Chess v0.6-MICRO by Spiros I.Kakos (huo) [2008]" );

	// initial values
	q6 = false;
	q7 = false;
	q8 = false;
	q9 = false;
	w1 = false;
	w2 = false;
	w3 = true;
	w4 = true;
	w5 = true;
	w6 = true;
	m = 0;
	a1 = "WH";

	// fix startup position
	stposition();

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

	bool exitgame = false;

	do
	{

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

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

		mA = 0;
		sa = false;
		z13 = true;
		e6 = false;
		wa = "HY";
		hym(sk);
	}
	else if ( a2->CompareTo("h") == 0 )
	{
		////////////////////////////
		// h enters his move
		////////////////////////////
		Console::WriteLine("");
		Console::Write("Starting column (A to H)...");
		h8 = Console::ReadLine()->ToUpper();

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

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

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

		// show the move entered

		String^ m = String::Concat("Your move: ", h8, h9.ToString(), " --> " );
		m = String::Concat( m, q1, q2.ToString() );
		Console::WriteLine( m );
		Console::WriteLine("");
		Console::WriteLine("Thinking...");

		// check the move entered by the human for correctness (='o' in Greek)
		// and legality (='n' in Greek)
		Entermove();
	}

	}while(exitgame == false);

	}



bool chForBLch(array<String^, 2>^ BCsk)                    
{      
	// TODO: Add your control notification handler code here

	bool h7;

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

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

			if (BCsk[(i),(j)]->CompareTo("BK") == 0)
			{
				w9 = (i+1);
				e1 = (j+1);
			}

		}
	}

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

	h7 = false;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// ��������� ������ �� ������� �������� ��� �� ����� ������� ��� �� ����� ���. ��� �� ��� ������ ��� ��� ��
	// ���� ��� BCsk[(8),(8)] ������ ��������� ��� ������ (w9 + 1) <= 8 ��� "if". ������ � "��������"
	// ��� �� "�����" ����� ��������, ��� e7 = true. ������ �� ������ ��� ��� ����� ��� ������ ����-
	// ��� ������� ������ ����� �������, ���� ��� ����� ������� � �� ���� �������� �� ��������� ��� ��� �� �����
	// ��� (���� �� "�������������" ��� �� ������� ����� ��������), ����� � e7 = false ��� � �������
	// ��� ������� ��� �� ����� ��������� (��� ���� ��� ��� ��������� ��� ���������� (e7 == true) ���
	// "if" ��� ������ ����� ��� ������).
	// �� ���� ��� ������� ������ ����� ������� ����� ��� ������� ��� �� ��� �����������, ���� ��������� ��
	// ������� ���������� �� ���������� � �������� ��� �� ����� ���, ����� � ������� �����������.
	// ��������: � ������� ������� ��� ������ ��� ��� ����� � ��������� ��������� ��������.
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	e7 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 + klopa) <= 8) && (e7 == true) )
	{
		if ((BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("BQ") == 0))
			e7 = false;
		else if ((BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 + klopa - 1),(e1 - 1)]->CompareTo("WK") == 0))
			e7 = false;
	}
	}



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

	e8 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 - klopa) >= 1) && (e8 == true) )
	{
		if ((BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("BQ") == 0))
			e8 = false;
		else if ((BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 - klopa - 1),(e1 - 1)]->CompareTo("WK") == 0))
			e8 = false;
	}
	}



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


	e9 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((e1 + klopa) <= 8) && (e9 == true) )
	{
		if ((BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("WR") == 0)||(BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("BP") == 0)||(BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("BR") == 0)||(BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("BN") == 0)||(BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("BB") == 0)||(BCsk[(w9 - 1),(e1 + klopa- 1)]->CompareTo("BQ") == 0))
			e9 = false;
		else if ((BCsk[(w9 - 1),(e1 + klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 - 1),(e1 + klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 - 1),(e1 + klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 - 1),(e1 + klopa - 1)]->CompareTo("WK") == 0))
			e9 = false;
	}
	}



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

	e10 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((e1 - klopa) >= 1) && (e10 == true) )
	{
		if ((BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("WR") == 0)||(BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("BP") == 0)||(BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("BR") == 0)||(BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("BN") == 0)||(BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("BB") == 0)||(BCsk[(w9 - 1),(e1 - klopa- 1)]->CompareTo("BQ") == 0))
			e10 = false;
		else if ((BCsk[(w9 - 1),(e1 - klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 - 1),(e1 - klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 - 1),(e1 - klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 - 1),(e1 - klopa - 1)]->CompareTo("WK") == 0))
			e10 = false;
	}
	}



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

	e11 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 + klopa) <= 8) && ((e1 + klopa) <= 8) && (e11 == true) )
	{
		if ((BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("BQ") == 0))
			e11 = false;
		else if ((BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 + klopa - 1),(e1 + klopa - 1)]->CompareTo("WK") == 0))
			e11 = false;
	}
	}



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

	e14 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 - klopa) >= 1) && ((e1 - klopa) >= 1) && (e14 == true) )
	{
		if ((BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("BQ") == 0))
			e14 = false;
		else if ((BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 - klopa - 1),(e1 - klopa - 1)]->CompareTo("WK") == 0))
			e14 = false;
	}
	}


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

	e12 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 + klopa) <= 8) && ((e1 - klopa) >= 1) && (e12 == true) )
	{
		if ((BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("BQ") == 0))
			e12 = false;
		else if ((BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 + klopa - 1),(e1 - klopa - 1)]->CompareTo("WK") == 0))
			e12 = false;
	}
	}



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

	e13 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w9 - klopa) >= 1) && ((e1 + klopa) <= 8) && (e13 == true) )
	{
		if ((BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WB") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WQ") == 0))
			h7 = true;
		else if ((BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("BP") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("BR") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("BN") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("BB") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("BQ") == 0))
			e13 = false;
		else if ((BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WP") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WR") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WN") == 0)||(BCsk[(w9 - klopa - 1),(e1 + klopa - 1)]->CompareTo("WK") == 0))
			e13 = false;
	}
	}


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

	if (((w9 + 1) <= 8) && ((e1 - 1) >= 1))
	{
		if (BCsk[(w9 + 1 - 1),(e1 - 1 - 1)]->CompareTo("WP") == 0)
		{
			h7 = true;
		}
	}


	if (((w9 - 1) >= 1) && ((e1 - 1) >= 1))
	{
		if (BCsk[(w9 - 1 - 1),(e1 - 1 - 1)]->CompareTo("WP") == 0) 
		{
			h7 = true;
		}
	}


	///////////////////////////////////////////////////////////////////////
	// ������� ��� �� �� � ������ �������� ���������� ��� ����.
	///////////////////////////////////////////////////////////////////////
	
	if (((w9 + 1) <= 8) && ((e1 + 2) <= 8))
		if (BCsk[(w9 + 1 - 1),(e1 + 2 - 1)]->CompareTo("WN") == 0)
			h7 = true;
	
	if (((w9 + 2) <= 8) && ((e1 - 1) >= 1))
		if (BCsk[(w9 + 2 - 1),(e1 - 1 - 1)]->CompareTo("WN") == 0)
			h7 = true;
	
	if (((w9 + 1) <= 8) && ((e1 - 2) >= 1))
		if (BCsk[(w9 + 1 - 1),(e1 - 2 - 1)]->CompareTo("WN") == 0)
			h7 = true;

	if (((w9 - 1) >= 1) && ((e1 - 2) >= 1))
		if (BCsk[(w9 - 1 - 1),(e1 - 2 - 1)]->CompareTo("WN") == 0)
			h7 = true;

	if (((w9 - 2) >= 1) && ((e1 - 1) >= 1))
		if (BCsk[(w9 - 2 - 1),(e1 - 1 - 1)]->CompareTo("WN") == 0)
			h7 = true;

	if (((w9 - 2) >= 1) && ((e1 + 1) <= 8))
		if (BCsk[(w9 - 2 - 1),(e1 + 1 - 1)]->CompareTo("WN") == 0)
			h7 = true;
	
	if (((w9 - 1) >= 1) && ((e1 + 2) <= 8))
		if (BCsk[(w9 - 1 - 1),(e1 + 2 - 1)]->CompareTo("WN") == 0)
			h7 = true;

	if (((w9 + 2) <= 8) && ((e1 + 1) <= 8))
		if (BCsk[(w9 + 2 - 1),(e1 + 1 - 1)]->CompareTo("WN") == 0)
			h7 = true;

	return h7;
	}


		
bool chForBLk9(array<String^, 2>^ BMsk)                   
{														      
	// TODO: Add your control notification handler code here

	bool k9;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////
	// ��������� ��� ���������� ���� ������ ��� �� �� ������� ��� (��. ����������� chForWHk9() ���
	// chForBLk9()).
	// �������������, �� ��������� ������� �� ������ ������� ��� ���, �� �������, ������� �� ���� ��
	// ��� ������ �� ���������� �� �� ���������� ��� ��� ������ ������� �� ������ ��������� ���������.
	// � ��������� ���������� �� �� ��������� �� ������� ���������� �� ������� ��� ��� ��������.
	/////////////////////////////////////////////////////////////////////////////////////////////////////////

	bool dFork9;

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

	k9 = false;
	dFork9 = true;    // ������, �������� ������� ���������� �� ������� ��� ��� ��������.
	                         // ��, ������, ������ ������ ������ ��� �� � �������� ������ �� �����������
						     // �� ��� ������� ��������� ��� �� ����� �� ��������� ���, ���� ����� ��
							 // ������� ���������� �� ������� ��� (��������) ��� � ��������� ������� ���
							 // ���� false.


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

	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			
			if (BMsk[(i),(j)]->CompareTo("BK") == 0)
			{
				e17 = (i+1);
				e18 = (j+1);
			}

		}
	}


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


	if (a1->CompareTo("BL") == 0)
	{

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

	e3 = chForBLch(BMsk);

	if ( e3 == false )     // �� ���� �� ������ ��� ��������� ���, ���� �� �� ���������� � �������
		dFork9 = false;         // ����� ��� ��������� �� ��������� ���������� �� ������� ���.

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

	if (e18 < 8)
	{
		a5 = BMsk[(e17 - 1),(e18 - 1)];
		PK = BMsk[(e17 - 1),(e18 - 1 + 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 + 1)<=7) )
	{
	
	// (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
	// � ������� ������� ���� �� ��� ��������� ��� ������������ ��������� � �������� ��� ������� ���� �������
	// ��� ����� �������� ��� �� ��� ��������� ��� ��, ������, � �������� ��� ������� ��� ��� �� �������� ��
	// ���� ��� ��� ������ ��� ��, ��������, ��������� �� ������� ���������� �� ������� ��� (����� �� ���
	// ������� ������ ����������, ���� � ������� ����� ��������).
		
		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1),(e18 - 1 + 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1),(e18 - 1 + 1)] = PK;

	}

	}

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

	if ((e17 < 8)&&(e18 < 8))
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 + 1),(e18 - 1 + 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 + 1)<=7)&&((e17 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 + 1),(e18 - 1 + 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 + 1),(e18 - 1 + 1)] = PK;

	}

	}


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

	if (e17 < 8)
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 + 1),(e18 - 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e17 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 + 1),(e18 - 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 + 1),(e18 - 1)] = PK;

	}

	}


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

	if ((e17 < 8)&&(e18 > 1))
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 + 1),(e18 - 1 - 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 - 1)>=0)&&((e17 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 + 1),(e18 - 1 - 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 + 1),(e18 - 1 - 1)] = PK;

	}

	}


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

	if (e18 > 1)
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1),(e18 - 1 - 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 - 1)>=0) )
	{
	
		// (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
		
		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1),(e18 - 1 - 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1),(e18 - 1 - 1)] = PK;

	}

	}


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

	if ((e17 > 1)&&(e18 > 1))
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 - 1),(e18 - 1 - 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 - 1)>=0)&&((e17 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 - 1),(e18 - 1 - 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 - 1),(e18 - 1 - 1)] = PK;

	}

	}


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

	if (e17 > 1)
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 - 1),(e18 - 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e17 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 - 1),(e18 - 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 - 1),(e18 - 1)] = PK;

	}

	}


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

	if ((e17 > 1)&&(e18 < 8))
	{

	a5 = BMsk[(e17 - 1),(e18 - 1)];
	PK = BMsk[(e17 - 1 - 1),(e18 - 1 + 1)];

	if ( (PK->CompareTo("BQ")==1)&&(PK->CompareTo("BR")==1)&&(PK->CompareTo("BN")==1)&&(PK->CompareTo("BB")==1)&&(PK->CompareTo("BP")==1)&&(dFork9 == true)&&((e18 - 1 + 1)<=7)&&((e17 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		BMsk[(e17 - 1),(e18 - 1)] = "";
		BMsk[(e17 - 1 - 1),(e18 - 1 + 1)] = a5;
		e3 = chForBLch(BMsk);

		if (e3 == false)
			dFork9 = false;

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

		BMsk[(e17 - 1),(e18 - 1)] = a5;
		BMsk[(e17 - 1 - 1),(e18 - 1 + 1)] = PK;

	}

	}

	if (dFork9 == true)
		k9 = true;

	}

	return k9;
	}





	
bool chForWHch(array<String^, 2>^ WCsk)               
{
                                       
													          
	// TODO: Add your control notification handler code here

	bool h7;

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

	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			
			if (WCsk[(i),(j)]->CompareTo("WK") == 0)
			{
				w7 = (i+1);
				w8 = (j+1);
			}

		}
	}

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

	h7 = false;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// ��������� ������ �� ������� �������� ��� �� ����� ������� ��� �� ����� ���. ��� �� ��� ������ ��� ��� ��
	// ���� ��� WCsk[(8),(8)] ������ ��������� ��� ������ (w7 + 1) <= 8 ��� "if". ������ � "��������"
	// ��� �� "�����" ����� ��������, ��� e7 = true. ������ �� ������ ��� ��� ����� ��� ������ ����-
	// ��� ������� ������ ����� �������, ���� ��� ����� ������� � �� ���� �������� �� ��������� ��� ��� �� �����
	// ��� (���� �� "�������������" ��� �� ������� ����� ��������), ����� � e7 = false ��� � �������
	// ��� ������� ��� �� ����� ��������� (��� ���� ��� ��� ��������� ��� ���������� (e7 == true) ���
	// "if" ��� ������ ����� ��� ������).
	// �� ���� ��� ������� ������ ����� ������� ����� ��� ������� ��� �� ��� �����������, ���� ��������� ��
	// ������� ���������� �� ���������� � �������� ��� �� ����� ���, ����� � ������� �����������.
	// ��������: � ������� ������� ��� ������ ��� ��� ����� � ��������� ��������� ��������.
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	e7 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 + klopa) <= 8) && (e7 == true) )
	{
		if ((WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("WQ") == 0))
			e7 = false;
		else if ((WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 + klopa - 1),(w8 - 1)]->CompareTo("BK") == 0))
			e7 = false;
	}
	}


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

	e8 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 - klopa) >= 1) && (e8 == true) )
	{
		if ((WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("WQ") == 0))
			e8 = false;
		else if ((WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 - klopa - 1),(w8 - 1)]->CompareTo("BK") == 0))
			e8 = false;
	}
	}


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


	e9 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w8 + klopa) <= 8) && (e9 == true) )
	{
		if ((WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("BR") == 0)||(WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("WP") == 0)||(WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("WR") == 0)||(WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("WN") == 0)||(WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("WB") == 0)||(WCsk[(w7 - 1),(w8 + klopa- 1)]->CompareTo("WQ") == 0))
			e9 = false;
		else if ((WCsk[(w7 - 1),(w8 + klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 - 1),(w8 + klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 - 1),(w8 + klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 - 1),(w8 + klopa - 1)]->CompareTo("BK") == 0))
			e9 = false;
	}
	}


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

	e10 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w8 - klopa) >= 1) && (e10 == true) )
	{
		if ((WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("BR") == 0)||(WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("WP") == 0)||(WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("WR") == 0)||(WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("WN") == 0)||(WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("WB") == 0)||(WCsk[(w7 - 1),(w8 - klopa- 1)]->CompareTo("WQ") == 0))
			e10 = false;
		else if ((WCsk[(w7 - 1),(w8 - klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 - 1),(w8 - klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 - 1),(w8 - klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 - 1),(w8 - klopa - 1)]->CompareTo("BK") == 0))
			e10 = false;
	}
	}


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

	e11 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 + klopa) <= 8) && ((w8 + klopa) <= 8) && (e11 == true) )
	{
		if ((WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("WQ") == 0))
			e11 = false;
		else if ((WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 + klopa - 1),(w8 + klopa - 1)]->CompareTo("BK") == 0))
			e11 = false;
	}
	}


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

	e14 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 - klopa) >= 1) && ((w8 - klopa) >= 1) && (e14 == true) )
	{
		if ((WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("WQ") == 0))
			e14 = false;
		else if ((WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 - klopa - 1),(w8 - klopa - 1)]->CompareTo("BK") == 0))
			e14 = false;
	}
	}

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

	e12 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 + klopa) <= 8) && ((w8 - klopa) >= 1) && (e12 == true) )
	{
		if ((WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("WQ") == 0))
			e12 = false;
		else if ((WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 + klopa - 1),(w8 - klopa - 1)]->CompareTo("BK") == 0))
			e12 = false;
	}
	}


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

	e13 = true;

	for(int klopa = 1; klopa<=7;klopa++)
	{
	if ( ((w7 - klopa) >= 1) && ((w8 + klopa) <= 8) && (e13 == true) )
	{
		if ((WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BB") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BQ") == 0))
			h7 = true;
		else if ((WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("WP") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("WR") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("WN") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("WB") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("WQ") == 0))
			e13 = false;
		else if ((WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BP") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BR") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BN") == 0)||(WCsk[(w7 - klopa - 1),(w8 + klopa - 1)]->CompareTo("BK") == 0))
			e13 = false;
	}
	}



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

	if (((w7 + 1) <= 8) && ((w8 + 1) <= 8))
	{
		if (WCsk[(w7 + 1 - 1),(w8 + 1 - 1)]->CompareTo("BP") == 0)
		{
			h7 = true;
		}
	}


	if (((w7 - 1) >= 1) && ((w8 + 1) <= 8))
	{
		if (WCsk[(w7 - 1 - 1),(w8 + 1 - 1)]->CompareTo("BP") == 0)
		{
			h7 = true;
		}
	}


	///////////////////////////////////////////////////////////////////////
	// ������� ��� �� �� � ������ �������� ���������� ��� ����.
	///////////////////////////////////////////////////////////////////////
	
	if (((w7 + 1) <= 8) && ((w8 + 2) <= 8))
        if (WCsk[(w7 + 1 - 1),(w8 + 2 - 1)]->CompareTo("BN") == 0)
			h7 = true;
	
	if (((w7 + 2) <= 8) && ((w8 - 1) >= 1))
		if (WCsk[(w7 + 2 - 1),(w8 - 1 - 1)]->CompareTo("BN") == 0)
			h7 = true;
	
	if (((w7 + 1) <= 8) && ((w8 - 2) >= 1))
		if (WCsk[(w7 + 1 - 1),(w8 - 2 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	if (((w7 - 1) >= 1) && ((w8 - 2) >= 1))
		if (WCsk[(w7 - 1 - 1),(w8 - 2 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	if (((w7 - 2) >= 1) && ((w8 - 1) >= 1))
		if (WCsk[(w7 - 2 - 1),(w8 - 1 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	if (((w7 - 2) >= 1) && ((w8 + 1) <= 8))
		if (WCsk[(w7 - 2 - 1),(w8 + 1 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	if (((w7 - 1) >= 1) && ((w8 + 2) <= 8))
		if (WCsk[(w7 - 1 - 1),(w8 + 2 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	if (((w7 + 2) <= 8) && ((w8 + 1) <= 8))
		if (WCsk[(w7 + 2 - 1),(w8 + 1 - 1)]->CompareTo("BN") == 0)
			h7 = true;

	return h7;
	}



	
bool chForWHk9(array<String^, 2>^ WMsk)                   
	{                         
	// TODO: Add your control notification handler code here

	bool k9;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////
	// ��������� ��� ���������� ���� ������ ��� �� �� ������� ��� (��. ����������� chForWHk9() ���
	// chForBLk9()).
	// �������������, �� ��������� ������� �� ������ ������� ��� ���, �� �������, ������� �� ���� ��
	// ��� ������ �� ���������� �� �� ���������� ��� ��� ������ ������� �� ������ ��������� ���������.
	// � ��������� ���������� �� �� ��������� �� ������� ���������� �� ������� ��� ��� ��������.
	/////////////////////////////////////////////////////////////////////////////////////////////////////////

	bool dFork9;

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

	k9 = false;
	dFork9 = true;    // ������, �������� ������� ���������� �� ������� ��� ��� ��������.
	                         // ��, ������, ������ ������ ������ ��� �� � �������� ������ �� �����������
						     // �� ��� ������� ��������� ��� �� ����� �� ��������� ���, ���� ����� ��
							 // ������� ���������� �� ������� ��� (��������) ��� � ��������� ������� ���
							 // ���� false.


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

	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			
			if (WMsk[(i),(j)]->CompareTo("WK") == 0)
			{
				e15 = (i+1);
				e16 = (j+1);
			}

		}
	}


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


	if (a1->CompareTo("WH") == 0)
	{

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

	e2 = chForWHch(WMsk);

	if ( e2 == false )     // �� ���� �� ������ ��� ��������� ���, ���� �� �� ���������� � �������
		dFork9 = false;         // ����� ��� ��������� �� ��������� ���������� �� ������� ���.

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

	if (e16 < 8)
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1),(e16 - 1 + 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 + 1)<=7) )
	{
	
	// (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
	// � ������� ������� ���� �� ��� ��������� ��� ������������ ��������� � �������� ��� ������� ���� �������
	// ��� ����� �������� ��� �� ��� ��������� ��� ��, ������, � �������� ��� ������� ��� ��� �� �������� ��
	// ���� ��� ��� ������ ��� ��, ��������, ��������� �� ������� ���������� �� ������� ��� (����� �� ���
	// ������� ������ ����������, ���� � ������� ����� ��������).
		
		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1),(e16 - 1 + 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1),(e16 - 1 + 1)] = PK;

	}

	}

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

	if ((e15 < 8)&&(e16 < 8))
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 + 1),(e16 - 1 + 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 + 1)<=7)&&((e15 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 + 1),(e16 - 1 + 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 + 1),(e16 - 1 + 1)] = PK;

	}

	}


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

	if (e15 < 8)
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 + 1),(e16 - 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e15 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 + 1),(e16 - 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 + 1),(e16 - 1)] = PK;

	}

	}


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

	if ((e15 < 8)&&(e16 > 1))
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 + 1),(e16 - 1 - 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 - 1)>=0)&&((e15 - 1 + 1)<=7) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 + 1),(e16 - 1 - 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 + 1),(e16 - 1 - 1)] = PK;

	}

	}


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

	if (e16 > 1)
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1),(e16 - 1 - 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 - 1)>=0) )
	{
	
		// (���������) ���������� ��� ������� ���� �� ���� ��� ������� ��� �� ��������� ���� �� ������� ���.
		
		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1),(e16 - 1 - 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1),(e16 - 1 - 1)] = PK;

	}

	}


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

	if ((e15 > 1)&&(e16 > 1))
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 - 1),(e16 - 1 - 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 - 1)>=0)&&((e15 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 - 1),(e16 - 1 - 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 - 1),(e16 - 1 - 1)] = PK;

	}

	}


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

	if (e15 > 1)
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 - 1),(e16 - 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e15 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 - 1),(e16 - 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 - 1),(e16 - 1)] = PK;

	}

	}


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

	if ((e15 > 1)&&(e16 < 8))
	{

	a5 = WMsk[(e15 - 1),(e16 - 1)];
	PK = WMsk[(e15 - 1 - 1),(e16 - 1 + 1)];

	if ( (PK->CompareTo("WQ")==1)&&(PK->CompareTo("WR")==1)&&(PK->CompareTo("WN")==1)&&(PK->CompareTo("WB")==1)&&(PK->CompareTo("WP")==1)&&(dFork9 == true)&&((e16 - 1 + 1)<=7)&&((e15 - 1 - 1)>=0) )
	{
		
		// (���������) ���������� ��� ������� ��� ������� ��� �� ��������� ���� �� ������� ���.

		WMsk[(e15 - 1),(e16 - 1)] = "";
		WMsk[(e15 - 1 - 1),(e16 - 1 + 1)] = a5;
		e2 = chForWHch(WMsk);

		if (e2 == false)
			dFork9 = false;

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

		WMsk[(e15 - 1),(e16 - 1)] = a5;
		WMsk[(e15 - 1 - 1),(e16 - 1 + 1)] = PK;

	}

	}

	if (dFork9 == true)
		k9 = true;

	}

	return k9;
	}


		
void chm(array<String^, 2>^ CMsk)               
	{    
	// UNCOMMENT TO SHOW INNER THINKING MECHANISM!
	//if(huodebug == true)
	//{
	//	Console::WriteLine("chm called");
	//	Console::ReadKey();
	//}
	// Assign values to a2 and x25 variables,
	// which are necessary for the proper function of Elegxosns and Elegxosos
	a2 = "h";
	x25 = false;
	a5 = CMsk[(e19 - 1),(h9 - 1)];

	// ch correctness of move
	e21 = Elegxosos(CMsk);
	// if move is correct, then check the legality also
	if( e21 == true )
		x26 = Elegxosns(CMsk);

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

	///////////////////////////////////////////////////////////////////////////////////////////////////////////
	// CHECK FOR k9
	///////////////////////////////////////////////////////////////////////////////////////////////////////////

	if (((e21 == true)&&(x26 == true))&&(mA == 0))
	{

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

	CMsk[(e19 - 1),(h9 - 1)] = "";
	PK = CMsk[(e20 - 1),(q2 - 1)];   // ��������� ���������� ���
																					 // ��������� ��� ��������� ���
	                                                                                 // ��������� ����������
	                                                                                 // (��. ���� ��� �� �����������
	                                                                                 // ���, ���� ��� ������� ����-
	                                                                                 // ��� ��� �� �� ��������� ��
	                                                                                 // ��������� ���).

	CMsk[(e20 - 1),(q2 - 1)] = a5;


	//////////////////////////////////////////////////////////////////////////
	// is the king still under check?
	//////////////////////////////////////////////////////////////////////////
	
	e2 = chForWHch(CMsk);

	if ( (a1->CompareTo("WH") == 0) && (e2 == true) )
	{
		x26 = false;
	}


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

	e3 = chForBLch(CMsk);

	if ( (a1->CompareTo("BL") == 0) && (e3 == true) )
	{
		x26 = false;
	}


	// restore pieces to their initial positions
	CMsk[(e19 - 1),(h9 - 1)] = a5;
	CMsk[(e20 - 1),(q2 - 1)] = PK;

	}

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

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


	// check if HY moves the king next to the king of the opponent
	// (this case is not controlled in the lines above)
	if( a5->CompareTo("WK") == 0 )
	{
		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1 + 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1) >= 0) && ((e20 - 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1),(q2 - 1 + 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1 + 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1) >= 0) && ((q2 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1 - 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1) >= 0) && ((e20 - 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1),(q2 - 1 - 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1 - 1)]->CompareTo("BK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1) >= 0) && ((q2 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1)]->CompareTo("BK") == 0)
				x26 = false;
		}
	}


	if( a5->CompareTo("BK") == 0 )
	{
		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1 + 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1) >= 0) && ((e20 - 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1),(q2 - 1 + 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1 + 1) >= 0) && ((q2 - 1 + 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1 + 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1) >= 0) && ((q2 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 - 1) >= 0) && ((e20 - 1 - 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 - 1),(q2 - 1 - 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1) >= 0) && ((e20 - 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1),(q2 - 1 - 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1 - 1) >= 0) && ((q2 - 1 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1 - 1)]->CompareTo("WK") == 0)
				x26 = false;
		}

		if( ((e20 - 1 + 1) >= 0) && ((e20 - 1 + 1) <= 7) && ((q2 - 1) >= 0) && ((q2 - 1) <= 7) )
		{
			if(CMsk[(e20 - 1 + 1),(q2 - 1)]->CompareTo("WK") == 0)
				x26 = false;
		}
	}

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

	if ((e21 == true)&&(x26 == true))
	{
		// temporarily perform the move
		PK = CMsk[(e20 - 1),(q2 - 1)];
		CMsk[(e19 - 1),(h9 - 1)] = "";
		CMsk[(e20 - 1),(q2 - 1)] = a5;


		// check is there is a pawn promotion
		if (q2 == 8)
		{
			CMsk[(e20 - 1),(q2 - 1)] = "WQ";
			q4 = true;
		}
		else if (q2 == 1)
		{
			CMsk[(e20 - 1),(q2 - 1)] = "BQ";
			q4 = true;
		}


		// store the move to ***HY variables (because after continuous calls of hym the initial move under analysis will be lost...)
		if ( (mA == 0) && ( ((a4->CompareTo("WH") == 0) && ((a5->CompareTo("BP") == 0)||(a5->CompareTo("BR") == 0)||(a5->CompareTo("BN") == 0)||(a5->CompareTo("BB") == 0)||(a5->CompareTo("BQ") == 0)||(a5->CompareTo("BK") == 0)))     ||     ((a4->CompareTo("BL") == 0) && ((a5->CompareTo("WP") == 0)||(a5->CompareTo("WR") == 0)||(a5->CompareTo("WN") == 0)||(a5->CompareTo("WB") == 0)||(a5->CompareTo("WQ") == 0)||(a5->CompareTo("WK") == 0))) ) )
		{
			// CHECK IF THE COMPUTER MOVES THE PIECE TO A SQUARE THAT IS THREATENED BY A PAWN
			a11 = false;
			a12 = false;
			a9 = false;
			a10 = false;
			a13 = false;
			Counts(CMsk);

			// check is HY eats the opponents queen
			// (so it is preferable to do so...)
			// Changed in version 0.5
			if(( PK->CompareTo("WQ") == 0) || ( PK->CompareTo("BQ") == 0))
				x10 = true;
			else
				x10 = false;

			z14 = a5;
			z10 = e19;
			z11 = e20;
			z12 = h9;
			x24 = q2;
		}

		// if the HY moves its king in the initial moves, then there is a penalty
		if( (z14->CompareTo("WK") == 0) || (z14->CompareTo("BK") == 0) )
			x11 = true;
		else
			x11 = false;

		if ((z13 == true)&&(mA == z9))
		{
			z6 = z10;
			z7 = z11;
			z8 = z12;
			x3 = x24;

			// Measure the move score
			Counts(CMsk);
			z4 = z5;
			
			z13 = false;
			e6 = true;
		}

		if (mA == z9)
		{
		// Measure the move score
		Counts(CMsk);

		// HUO DEBUG
		// If the computer loses its queen...then penalty!
		//if(LoseQueenpenalty == true)
		//{
			//Console::WriteLine("d penalty noted!");
		//	if(a4->CompareTo("WH") == 0)
		//		z5 = z5 + 50;
		//	else if(a4->CompareTo("BL") == 0)
		//		z5 = z5 - 50;
		//}

		// record the score as the best move score, if it is the best
		// move score!
		// HUO DEBUG
		//if(LoseQueenpenalty == false)
		//{
		//Console::WriteLine("ched move...");
		if ( ((a4->CompareTo("BL") == 0)&&(z5 > z4)) || ((a4->CompareTo("WH") == 0)&&(z5 < z4)) )
		{
			// HUO DEBUG
			//StreamWriter^ swer = gcnew StreamWriter("z4.txt",true);
			//swer->WriteLine(String::Concat((z10).ToString(),(z12).ToString(),(z11).ToString(),(x24).ToString(),"  : b m Found!"));
			//swer->Close();

			z6 = z10;
			z7 = z11;
			z8 = z12;
			x3 = x24;
			z4 = z5;
		}
		else if ( ( z5 == z4 ) && ( ((a4->CompareTo("WH") == 0) && ((a5->CompareTo("BP") == 0)||(a5->CompareTo("BR") == 0)||(a5->CompareTo("BN") == 0)||(a5->CompareTo("BB") == 0)||(a5->CompareTo("BQ") == 0)||(a5->CompareTo("BK") == 0)))     ||     ((a4->CompareTo("BL") == 0) && ((a5->CompareTo("WP") == 0)||(a5->CompareTo("WR") == 0)||(a5->CompareTo("WN") == 0)||(a5->CompareTo("WB") == 0)||(a5->CompareTo("WQ") == 0)||(a5->CompareTo("WK") == 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^ randomnumber = gcnew Random();
			int Arithmos = randomnumber->Next(1, 20);

			if (Arithmos > 13)
			{
			z6 = z10;
			z7 = z11;
			z8 = z12;
			x3 = x24;
			z4 = z5;
			}
		}
		//}

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

		// restore promoted pawn (if exists)
		if ((q2 == 8) && (q4 == true))
		{
			CMsk[(e20 - 1),(q2 - 1)] = "WP";
			q4 = false;
		}
		else if ((e20 == 1) && (q4 == true))
		{
			CMsk[(e20 - 1),(q2 - 1)] = "BP";
			q4 = false;
		}

		// restore pieces
		CMsk[(e19 - 1),(h9 - 1)] = a5;
		CMsk[(e20 - 1),(q2 - 1)] = PK;
		}

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

	if (mA < z9)
	{
		//////////////////////////////////////////////////////////////
		// is human's king in check?
		//////////////////////////////////////////////////////////////
		x7 = false;
		
		e2 = chForWHch(CMsk);
		if ( (a4->CompareTo("WH") == 0) && (e2 == true) )
			x7 = true;

		e3 = chForBLch(CMsk);
		if ( (a4->CompareTo("BL") == 0) && (e3 == true) )
			x7 = true;

		mA = mA + 1;

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

		wa = "h";
		v3 = true;
		
		// check human move (to find the best possible answer of the human
		// to the move currently analyzed by the HY Thought process)
		hm(z2);
		// UNCOMMENT TO SHOW INNER THINKING MECHANISM!
		//if(huodebug == true)
		//{
		//	Console::WriteLine("RETURNED TO chm");
		//	Console::ReadKey();
		//}
	}

	} 
	}


		
void hym(array<String^, 2>^ skthinit)              
{   
	// UNCOMMENT TO SHOW INNER THINKING MECHANISM!
	//if(huodebug == true)
	//{
	//	Console::WriteLine("hym called");
	//	Console::ReadKey();
	//}
	// set k9=false, to avoid false alarms for k9.
	// if the program finds out in a next step that k9 exists,
	// then it will tell it to you, don't worry! :)
	k9 = false;

	int iii;
	int jjj;

	if (z13 == true)
	{
			// store the initial position in the chessboard
			for (iii = 0; iii <= 7; iii++)
			{
				for (jjj = 0; jjj <= 7; jjj++)
				{
					z3[iii,jjj] = skthinit[(iii),(jjj)];
					z1[(iii),(jjj)] = skthinit[(iii),(jjj)];
				}
			}
	}


	// check is computer has thought as far as the z9 dictates
	if (mA > z9)
		sa = true;

	if (sa == false)
	{
	array<String^, 2>^ skdousSquares = gcnew array<String^, 2>(8,8);
	array<int, 2>^ noofdefenders = gcnew array<int,2>(8,8);
	array<int, 2>^ noofattackers = gcnew array<int,2>(8,8);
	array<int, 2>^ Valueofdefenders = gcnew array<int,2>(8,8);
	array<int, 2>^ Valueofattackers = gcnew array<int,2>(8,8);
	array<int, 2>^ Exceptiondefendercolumn = gcnew array<int,2>(8,8);
	array<int, 2>^ Exceptiondefenderrank = 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 (='sk' 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++)
		{
			skdousSquares[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++)
		{
			noofattackers[di,dj] = 0;
			noofdefenders[di,dj] = 0;
			Valueofattackers[di,dj] = 0;
			Valueofdefenders[di,dj] = 0;
			Exceptiondefendercolumn[di,dj] = -9;
			Exceptiondefenderrank[di,dj] = -9;
		}
	}

	for (int iii2 = 0; iii2 <= 7; iii2++)
	{
		for (int jjj2 = 0; jjj2 <= 7; jjj2++)
		{
	if ( (( ( ((z3[(iii2),(jjj2)]->CompareTo("WK") == 0) || (z3[(iii2),(jjj2)]->CompareTo("WQ") == 0) || (z3[(iii2),(jjj2)]->CompareTo("WR") == 0) || (z3[(iii2),(jjj2)]->CompareTo("WN") == 0) || (z3[(iii2),(jjj2)]->CompareTo("WB") == 0)  || (z3[(iii2),(jjj2)]->CompareTo("WP") == 0)) && (a4->CompareTo("WH") == 0) ) || ( ((z3[(iii2),(jjj2)]->CompareTo("BK") == 0) || (z3[(iii2),(jjj2)]->CompareTo("BQ") == 0) || (z3[(iii2),(jjj2)]->CompareTo("BR") == 0) || (z3[(iii2),(jjj2)]->CompareTo("BN") == 0) || (z3[(iii2),(jjj2)]->CompareTo("BB") == 0)  || (z3[(iii2),(jjj2)]->CompareTo("BP") == 0)) && (a4->CompareTo("BL") == 0) ) ) )  )
	{
	
	// find squares where the human opponent can hit
		for( int w2=0; w2<=7; w2++)
		{
			for( int r2=0; r2<=7; r2++)
			{
				a5 = z3[(iii2),(jjj2)];
				e19 = iii2+1;
				e20 = w2+1;
				h9 = jjj2+1;
				q2 = r2+1;

				// check the move
				a2 = "h";
				x25 = false;
				e21 = Elegxosos(z3);
				if( e21 == true )
					x26 = Elegxosns(z3);
				// restore normal value of mwhoplays
				a2 = "HY";
				if(( e21 == true )&&(x26 == true))
				{
					// Another attacker on that square found!
					noofattackers[(e20-1),(q2-1)] = noofattackers[(e20-1),(q2-1)] + 1;
					skdousSquares[(e20-1),(q2-1)] = "d";
					
					//if(skdousSquares[(e20-1),(q2-1)]->ToString()->Equals("d") == true)
					//	Console::WriteLine("Added new dangerous square!");

					// Calculate the value (total value) of the attackers
					if ((a5->CompareTo("WR") == 0)||(a5->CompareTo("BR") == 0))
						Valueofattackers[(e20-1),(q2-1)] = Valueofattackers[(e20-1),(q2-1)] + 5;
					else if ((a5->CompareTo("WB") == 0)||(a5->CompareTo("BB") == 0))
						Valueofattackers[(e20-1),(q2-1)] = Valueofattackers[(e20-1),(q2-1)] + 3;
					else if ((a5->CompareTo("WN") == 0)||(a5->CompareTo("BN") == 0))
						Valueofattackers[(e20-1),(q2-1)] = Valueofattackers[(e20-1),(q2-1)] + 3;
					else if ((a5->CompareTo("WQ") == 0)||(a5->CompareTo("BQ") == 0))
						Valueofattackers[(e20-1),(q2-1)] = Valueofattackers[(e20-1),(q2-1)] + 9;
					else if ((a5->CompareTo("WP") == 0)||(a5->CompareTo("BP") == 0))
						Valueofattackers[(e20-1),(q2-1)] = Valueofattackers[(e20-1),(q2-1)] + 1;
				}
			}
		}
	}
		}
	}

	///////////////////////////////////////////////////////////////////////////////////////
	// ���������� ��� ����������� ����������
	// USE FOR DEBUGGING PURPOSES ONLY!
	//StreamWriter^ srw = gcnew StreamWriter(String::Concat("log1.txt"));
	//srw->WriteLine(String::Concat("m: ",m.ToString()));
	//srw->WriteLine("*************************************");
	//for (iii = 0; iii <= 7; iii++)
	//{
	//	for (jjj = 0; jjj <= 7; jjj++)
	//	{
	//		if(skdousSquares[(iii),(jjj)]->ToString()->Equals("d") == true)
	//			srw->WriteLine(String::Concat(iii.ToString(),jjj.ToString()," DANGER!"));
	//		else if(skdousSquares[(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 ( ((wa->CompareTo("HY") == 0) && ( ( ((z3[(iii3),(jjj3)]->CompareTo("WK") == 0) || (z3[(iii3),(jjj3)]->CompareTo("WQ") == 0) || (z3[(iii3),(jjj3)]->CompareTo("WR") == 0) || (z3[(iii3),(jjj3)]->CompareTo("WN") == 0) || (z3[(iii3),(jjj3)]->CompareTo("WB") == 0)  || (z3[(iii3),(jjj3)]->CompareTo("WP") == 0)) && (a4->CompareTo("BL") == 0) ) || ( ((z3[(iii3),(jjj3)]->CompareTo("BK") == 0) || (z3[(iii3),(jjj3)]->CompareTo("BQ") == 0) || (z3[(iii3),(jjj3)]->CompareTo("BR") == 0) || (z3[(iii3),(jjj3)]->CompareTo("BN") == 0) || (z3[(iii3),(jjj3)]->CompareTo("BB") == 0)  || (z3[(iii3),(jjj3)]->CompareTo("BP") == 0)) && (a4->CompareTo("WH") == 0) ) ) ) )
	{
		for( int w1=0; w1<=7; w1++)
		{
			for( int r1=0; r1<=7; r1++)
			{
				a5 = z3[(iii3),(jjj3)];
				e19 = iii3+1;
				e20 = w1+1;
				h9 = jjj3+1;
				q2 = r1+1;

				// ������� ��� �������
				// ������� ����� ���� ���������� a2 ��� x25, �� ������ ����� ����������� ��� �� ������������ ����� �� ����������� Elegxosns ��� Elegxosos
				a2 = "h";
				x25 = false;
				e21 = Elegxosos(z3);
				if( e21 == true )
					x26 = Elegxosns(z3);
				// ��������� ��� ��������� ����� ��� a2
				a2 = "HY";
				if(( e21 == true )&&(x26 == true))
				{
					// Changed in version 0.5
					// A new defender for that square is found!
					noofdefenders[(e20-1),(q2-1)] = noofdefenders[(e20-1),(q2-1)] + 1;
					
					// Calculate the value (total value) of the defenders
					if ((a5->CompareTo("WR") == 0)||(a5->CompareTo("BR") == 0))
						Valueofdefenders[(e20-1),(q2-1)] = Valueofdefenders[(e20-1),(q2-1)] + 5;
					else if ((a5->CompareTo("WB") == 0)||(a5->CompareTo("BB") == 0))
						Valueofdefenders[(e20-1),(q2-1)] = Valueofdefenders[(e20-1),(q2-1)] + 3;
					else if ((a5->CompareTo("WN") == 0)||(a5->CompareTo("BN") == 0))
						Valueofdefenders[(e20-1),(q2-1)] = Valueofdefenders[(e20-1),(q2-1)] + 3;
					else if ((a5->CompareTo("WQ") == 0)||(a5->CompareTo("BQ") == 0))
						Valueofdefenders[(e20-1),(q2-1)] = Valueofdefenders[(e20-1),(q2-1)] + 9;
					else if ((a5->CompareTo("WP") == 0)||(a5->CompareTo("BP") == 0))
						Valueofdefenders[(e20-1),(q2-1)] = Valueofdefenders[(e20-1),(q2-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( noofdefenders[(e20-1),(q2-1)] == 1 )
					{
					Exceptiondefendercolumn[(e20-1),(q2-1)] = (e19 - 1);
					Exceptiondefenderrank[(e20-1),(q2-1)] = (h9 - 1);	
					}
					// PLAYING: Change 1 to 2 ???
					if( noofdefenders[(e20-1),(q2-1)] > 1 )
					{
					Exceptiondefendercolumn[(e20-1),(q2-1)] = -99;
					Exceptiondefenderrank[(e20-1),(q2-1)] = -99;	
					}
					
					if(skdousSquares[(e20-1),(q2-1)]->CompareTo("d")==0)
					{
						skdousSquares[(e20-1),(q2-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("m: ",m.ToString()));
	//srw2->WriteLine("*************************************");
	//for (iii = 0; iii <= 7; iii++)
	//{
	//	for (jjj = 0; jjj <= 7; jjj++)
	//	{
	//		if(skdousSquares[(iii),(jjj)]->ToString()->Equals("d") == 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 ( ((wa->CompareTo("HY") == 0) && ( ( ((z3[(iii),(jjj)]->CompareTo("WK") == 0) || (z3[(iii),(jjj)]->CompareTo("WQ") == 0) || (z3[(iii),(jjj)]->CompareTo("WR") == 0) || (z3[(iii),(jjj)]->CompareTo("WN") == 0) || (z3[(iii),(jjj)]->CompareTo("WB") == 0)  || (z3[(iii),(jjj)]->CompareTo("WP") == 0)) && (a4->CompareTo("BL") == 0) ) || ( ((z3[(iii),(jjj)]->CompareTo("BK") == 0) || (z3[(iii),(jjj)]->CompareTo("BQ") == 0) || (z3[(iii),(jjj)]->CompareTo("BR") == 0) || (z3[(iii),(jjj)]->CompareTo("BN") == 0) || (z3[(iii),(jjj)]->CompareTo("BB") == 0)  || (z3[(iii),(jjj)]->CompareTo("BP") == 0)) && (a4->CompareTo("WH") == 0) ) ) ) || ( (wa->CompareTo("h") == 0) && ( ( ((z3[(iii),(jjj)]->CompareTo("WK") == 0) || (z3[(iii),(jjj)]->CompareTo("WQ") == 0) || (z3[(iii),(jjj)]->CompareTo("WR") == 0) || (z3[(iii),(jjj)]->CompareTo("WN") == 0) || (z3[(iii),(jjj)]->CompareTo("WB") == 0)  || (z3[(iii),(jjj)]->CompareTo("WP") == 0)) && (a4->CompareTo("WH") == 0) ) || ( ((z3[(iii),(jjj)]->CompareTo("BK") == 0) || (z3[(iii),(jjj)]->CompareTo("BQ") == 0) || (z3[(iii),(jjj)]->CompareTo("BR") == 0) || (z3[(iii),(jjj)]->CompareTo("BN") == 0) || (z3[(iii),(jjj)]->CompareTo("BB") == 0)  || (z3[(iii),(jjj)]->CompareTo("BP") == 0)) && (a4->CompareTo("BL") == 0) ) ) ))
	{
	
		for( int w=0; w<=7; w++)
		{
			for( int r=0; r<=7; r++)
			{
				// Changed in version 0.5
				h1 = false;
				a7 = false;
				a6 = false;

				a5 = z3[(iii),(jjj)];
				e19 = iii+1;
				e20 = w+1;
				h9 = jjj+1;
				q2 = r+1;

				// check move, ONLY if the destination square is not
				// one of the dangerous squares found above.
				if((skdousSquares[(e20-1),(q2-1)]->CompareTo("d")==0))
				{
				}
				else 
				{
						//if((Exceptiondefendercolumn[(e20-1),(q2-1)] == (e19-1)) && (Exceptiondefenderrank[(e20-1),(q2-1)] == (h9-1)))
						//{
						//	h1 = true;
						//}
						//else
						//{
							// Penalty for moving your piece to a square that the human opponent can hit with more power than the computer.
							if(noofattackers[(e20-1),(q2-1)] > noofdefenders[(e20-1),(q2-1)])
							{	a7 = 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(Valueofattackers[(e20-1),(q2-1)] > Valueofdefenders[(e20-1),(q2-1)])
							{	a6 = 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((Exceptiondefendercolumn[(e20-1),(q2-1)] == (e19-1)) && (Exceptiondefenderrank[(e20-1),(q2-1)] == (h9-1)))
								h1 = true;

							// HUO DEBUG
							//LoseQueenpenalty = false;

							chm(z3);
							// UNCOMMENT TO SHOW INNER THINKING MECHANISM!
							//if(huodebug == true)
							//{
							//	Console::WriteLine("RETURNED TO hym");
							//	Console::ReadKey();
							//}
						//}
				}
					
			}
		}

	}


		}
	}


	}


	/////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// find if there is k9
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////

	if ((mA == 0) && ((e2 == true)||(e3 == true)))
	{
	
		// �� � ����������� ��� ��������� �� ���� ����� ������ ������ �� ����� �������� ��� ��� ����� ���

		if (e6 == false)
		{
			k9 = true;

			if (a4->CompareTo("WH") == 0)
				Console::WriteLine("BL is k9!");
			else if (a4->CompareTo("BL") == 0)
				Console::WriteLine("WH is k9!");
		}

	}


	// DO THE BEST MOVE FOUND

	if (mA == 0)
	{
	// ��������� ��� ����� ��� sa (��. ��� ����)
	sa = false;

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

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

		a5 = sk[(z6 - 1),(z8 - 1)];
		sk[(z6 - 1),(z8 - 1)] = "";

		if (z6 == 1)
			x1 = "a";
		else if (z6 == 2)
			x1 = "b";
		else if (z6 == 3)
			x1 = "c";
		else if (z6 == 4)
			x1 = "d";
		else if (z6 == 5)
			x1 = "e";
		else if (z6 == 6)
			x1 = "f";
		else if (z6 == 7)
			x1 = "g";
		else if (z6 == 8)
			x1 = "h";

		// position piece to the square of destination

		sk[(z7 - 1),(x3 - 1)] = a5;

		if (z7 == 1)
			x2 = "a";
		else if (z7 == 2)
			x2 = "b";
		else if (z7 == 3)
			x2 = "c";
		else if (z7 == 4)
			x2 = "d";
		else if (z7 == 5)
			x2 = "e";
		else if (z7 == 6)
			x2 = "f";
		else if (z7 == 7)
			x2 = "g";
		else if (z7 == 8)
			x2 = "h";

		// if king is moved, no castling can occur
		if (a5->CompareTo("WK") == 0)
			q6 = true;
		else if (a5->CompareTo("BK") == 0)
			q7 = false;
		else if (a5->CompareTo("WR") == 0)
		{
            if ((z6 == 1) && (z8 == 1))
				q8 = false;
			else if ((z6 == 8) && (z8 == 1))
				q9 = false;
		}
		else if (a5->CompareTo("BR") == 0)
		{
			if ((z6 == 1) && (z8 == 8))
				w1 = false;
			else if ((z6 == 8) && (z8 == 8))
				w2 = false;
		}
			
		// is there a pawn to promote?
		if ( ( (a5->CompareTo("WP") == 0) || (a5->CompareTo("BP") == 0) ) && (a2->CompareTo("HY") == 0) )
		{

			if (x3 == 8)
			{
				sk[(z7 - 1),(x3 - 1)] = "WQ";
				Console::WriteLine( "���� ���������!" );
			}
			else if (x3 == 1)
			{
				sk[(z7 - 1),(x3 - 1)] = "BQ";
				Console::WriteLine( "���� ���������!" );
			}

		}


	//////////////////////////////////////////////////////////////////////
	// show HY move
	//////////////////////////////////////////////////////////////////////
	String^ NextLine= String::Concat( x1, z8.ToString(), " -> ", x2, x3.ToString() );
	Console::WriteLine(String::Concat("My move is: ", NextLine));

	// �� � ����������� ������ �� �� �����, ���� ��������� ���� �� ������� ��� �������.
	if(a4->CompareTo("BL") == 0)
		m = m + 1;

	// now it is the other color's turn to play
	if (a4->CompareTo("BL") == 0)
		a1 = "BL";
	else if (a4->CompareTo("WH") == 0)
		a1 = "WH";

	// now it is the human's turn to play
	a2 = "h";

	}
	else
	{
		mA = mA - 2;
		wa = "HY";
		for (i = 0; i <= 7; i++)
		{
			for (j = 0; j <= 7; j++)
			{
				z3[i,j] = z1[i,j];
			}
		}
	}
}

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

	z5 = 0;

		// Changed in version 0.5
	// PENALTIES SECTION
	// (see hym for explanation of the dous Squares)
	
	if(h1 == true)
	{
		if(a4->CompareTo("WH") == 0)
			z5 = z5 + 5;
		else if(a4->CompareTo("BL") == 0)
			z5 = z5 - 5;
	}

	if(a7 == true)
	{
		if(a4->CompareTo("WH") == 0)
			z5 = z5 + 4;
		else if(a4->CompareTo("BL") == 0)
			z5 = z5 - 4;
	}

	if(a6 == true)
	{
		if(a4->CompareTo("WH") == 0)
			z5 = z5 + 4;
		else if(a4->CompareTo("BL") == 0)
			z5 = z5 - 4;
	}

	// Pawn threat penalties: if the computer moves its piece at a square where it is
	// threatened by an opponent's pawn, there is a penalty (see chm and Counts).
	// ADDED IN VERSION 0.6
	if(a11 == true)
	{
		if(a4->CompareTo("BL") == 0)
			z5 = z5 - 10;
		else if(a4->CompareTo("WH") == 0)
			z5 = z5 + 10;
	}

	if(a9 == true)
	{
		if(a4->CompareTo("BL") == 0)
			z5 = z5 - 6;
		else if(a4->CompareTo("WH") == 0)
			z5 = z5 + 6;
	}

	if(a10 == true)
	{
		if(a4->CompareTo("BL") == 0)
			z5 = z5 - 6;
		else if(a4->CompareTo("WH") == 0)
			z5 = z5 + 6;
	}

	if(a12 == true)
	{
		if(a4->CompareTo("BL") == 0)
			z5 = z5 - 20;
		else if(a4->CompareTo("WH") == 0)
			z5 = z5 + 20;
	}


	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			if (CSsk[(i),(j)]->CompareTo("WP") == 0)
				z5 = z5 + 1;
			else if (CSsk[(i),(j)]->CompareTo("WR") == 0)
			{
				z5 = z5 + 5;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("BL")==0)
				{
					if(((i+1)<=7)&&((j+1)<=7))
					{
						if(CSsk[(i+1),(j+1)]->CompareTo("BP") == 0)
							a11 = true;
					}

					if(((i-1)>=0)&&((j+1)<=7))
					{
						if(CSsk[(i-1),(j+1)]->CompareTo("BP") == 0)
							a11 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("WN") == 0)
			{
				z5 = z5 + 3;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("BL")==0)
				{
					if(((i+1)<=7)&&((j+1)<=7))
					{
						if(CSsk[(i+1),(j+1)]->CompareTo("BP") == 0)
							a9 = true;
					}

					if(((i-1)>=0)&&((j+1)<=7))
					{
						if(CSsk[(i-1),(j+1)]->CompareTo("BP") == 0)
							a9 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("WB") == 0)
			{
				z5 = z5 + 3;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("BL")==0)
				{
					if(((i+1)<=7)&&((j+1)<=7))
					{
						if(CSsk[(i+1),(j+1)]->CompareTo("BP") == 0)
							a10 = true;
					}

					if(((i-1)>=0)&&((j+1)<=7))
					{
						if(CSsk[(i-1),(j+1)]->CompareTo("BP") == 0)
							a10 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("WQ") == 0)
			{
				z5 = z5 + 9;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("BL")==0)
				{
					if(((i+1)<=7)&&((j+1)<=7))
					{
						if(CSsk[(i+1),(j+1)]->CompareTo("BP") == 0)
							a12 = true;
					}

					if(((i-1)>=0)&&((j+1)<=7))
					{
						if(CSsk[(i-1),(j+1)]->CompareTo("BP") == 0)
							a12 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("WK") == 0)
			{
				z5 = z5 + 15;
			}
			else if (CSsk[(i),(j)]->CompareTo("BP") == 0)
				z5 = z5 - 1;
			else if (CSsk[(i),(j)]->CompareTo("BR") == 0)
			{
				z5 = z5 - 5;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("WH")==0)
				{
					if(((i+1)<=7)&&((j-1)>=0))
					{
						if(CSsk[(i+1),(j-1)]->CompareTo("WP") == 0)
							a11 = true;
					}

					if(((i-1)>=0)&&((j-1)>=0))
					{
						if(CSsk[(i-1),(j-1)]->CompareTo("WP") == 0)
							a11 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("BN") == 0)
			{
				z5 = z5 - 3;

				// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("WH")==0)
				{
					if(((i+1)<=7)&&((j-1)>=0))
					{
						if(CSsk[(i+1),(j-1)]->CompareTo("WP") == 0)
							a9 = true;
					}

					if(((i-1)>=0)&&((j-1)>=0))
					{
						if(CSsk[(i-1),(j-1)]->CompareTo("WP") == 0)
							a9 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("BB") == 0)
			{
				z5 = z5 - 3;

								// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("WH")==0)
				{
					if(((i+1)<=7)&&((j-1)>=0))
					{
						if(CSsk[(i+1),(j-1)]->CompareTo("WP") == 0)
							a10 = true;
					}

					if(((i-1)>=0)&&((j-1)>=0))
					{
						if(CSsk[(i-1),(j-1)]->CompareTo("WP") == 0)
							a10 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("BQ") == 0)
			{
					z5 = z5 - 9;

									// Penalty if the piece of the computer is threatened by a pawn (see chm)
				if(a13 == false)
				{
				if(a4->CompareTo("WH")==0)
				{
					if(((i+1)<=7)&&((j-1)>=0))
					{
						if(CSsk[(i+1),(j-1)]->CompareTo("WP") == 0)
							a12 = true;
					}

					if(((i-1)>=0)&&((j-1)>=0))
					{
						if(CSsk[(i-1),(j-1)]->CompareTo("WP") == 0)
							a12 = true;
					}
				}
				}
			}
			else if (CSsk[(i),(j)]->CompareTo("BK") == 0)
			{
				z5 = z5 + 15;
			}

		}
	}

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

	if (m < 11)
	{

	// control the center with your pawns

	if (CSsk[3,2]->CompareTo("WP") == 0)
		z5 = z5 + 0.4;
		
	if (CSsk[3,3]->CompareTo("WP") == 0)
		z5 = z5 + 0.4;
		
	if (CSsk[4,2]->CompareTo("WP") == 0)
		z5 = z5 + 0.4;
	
	if (CSsk[4,3]->CompareTo("WP") == 0)
		z5 = z5 + 0.4;
		
	if (CSsk[3,5]->CompareTo("BP") == 0)
		z5 = z5 - 0.4;
		
	if (CSsk[3,4]->CompareTo("BP") == 0)
		z5 = z5 - 0.4;
		
	if (CSsk[4,5]->CompareTo("BP") == 0)
		z5 = z5 - 0.4;
		
	if (CSsk[4,4]->CompareTo("BP") == 0)
		z5 = z5 - 0.4;

	// don't play a4, h4, etc

	if (CSsk[0,3]->CompareTo("WP") == 0)
		z5 = z5 - 0.2;

	if (CSsk[1,3]->CompareTo("WP") == 0)
		z5 = z5 - 0.2;

	if (CSsk[6,3]->CompareTo("WP") == 0)
		z5 = z5 - 0.2;

	if (CSsk[7,3]->CompareTo("WP") == 0)
		z5 = z5 - 0.2;

	if (CSsk[0,4]->CompareTo("BP") == 0)
		z5 = z5 + 0.4;

	if (CSsk[1,4]->CompareTo("BP") == 0)
		z5 = z5 + 0.4;

	if (CSsk[6,4]->CompareTo("BP") == 0)
		z5 = z5 + 0.4;

	if (CSsk[7,4]->CompareTo("BP") == 0)
		z5 = z5 + 0.4;

	// don't play the rook

	if (CSsk[0,0]->CompareTo("") == 0)
		z5 = z5 - 0.1;

	if (CSsk[7,0]->CompareTo("") == 0)
		z5 = z5 - 0.1;

	if (CSsk[0,7]->CompareTo("") == 0)
		z5 = z5 + 0.1;

	if (CSsk[7,7]->CompareTo("") == 0)
		z5 = z5 + 0.1;

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

	if (CSsk[0,2]->CompareTo("WN") == 0)
		z5 = z5 - 0.1;

	if (CSsk[7,2]->CompareTo("WN") == 0)
		z5 = z5 - 0.1;

	if (CSsk[0,5]->CompareTo("BN") == 0)
		z5 = z5 + 0.1;

	if (CSsk[7,5]->CompareTo("BN") == 0)
		z5 = z5 + 0.1;
	} 

	if (m < 10)
	{
		// ��� ������ �� ��������� �����

		if(a4->CompareTo("BL") == 0)
		{
			if (CSsk[3,0]->CompareTo("") == 0)
				z5 = z5 - 10.9;
		}

		if(a4->CompareTo("WH") == 0)
		{
			if (CSsk[3,7]->CompareTo("") == 0)
				z5 = z5 + 10.9;
		}
	}

	if (m < 8)
	{
		// ��� ������ �� ������� �����

		if ( (CSsk[4,0]->CompareTo("") == 0) && (a4->CompareTo("BL") == 0) )
			z5 = z5 - 3;

		if ( (CSsk[4,7]->CompareTo("") == 0) && (a4->CompareTo("WH") == 0) )
			z5 = z5 + 3;
	}

//	if( m < 7 )
//	{
//		// don't go to check too early!
//
//		if(a4->CompareTo("BL") == 0)
//		{
//			chForBLch(CSsk);
//			if (e3 == true)
//				z5 = z5 - 3;
//		}
//
//		if(a4->CompareTo("WH") == 0)
//		{
//			chForWHch(CSsk);
//			if (e2 == true)
//				z5 = z5 + 3;
//		}
//	}

	// HY likes to eat the opponent's queen, so as to simplify the game!
	if( x10 == true )
	{
		if( a4->CompareTo("WH") == 0 )
			z5 = z5 - 1;
		else if( a4->CompareTo("BL") == 0 )
			z5 = z5 + 1;
	}

	// if k9 is possible, go for it!
	//if( x6 == true )
	//{
	//	if( a4->CompareTo("WH") == 0 )
	//		z5 = z5 - 0.2;
	//	else if( a4->CompareTo("BL") == 0 )
	//		z5 = z5 + 0.2;
	//}

	// don't move the king early in the game!
	//if( (x11 == true) && (m < 10) )
	//{
	//	if( a4->CompareTo("WH") == 0 )
	//		z5 = z5 + 0.4;
	//	else if( a4->CompareTo("BL") == 0 )
	//		z5 = z5 - 0.4;
	//}


	}


void Countsh(array<String^, 2>^ CSsk)             
	{      
	// count score for human moves analyzed
	// SEE RESPECTIVE Counts funtion for analytical comments in English!
	// All pieces values here are increased by +2 relatively to the respective values
	// in Counts. This is to show/emphasize to the computer that its human opponent
	// will aim at killing his pieces!
	x17 = 0;

	for (i = 0; i <= 7; i++)
	{
		for (j = 0; j <= 7; j++)
		{
			if (CSsk[(i),(j)]->CompareTo("WP") == 0)
			{
				x17 = x17 + 1;

				// �� �� ����� ���� �� ���� ���������.
				// � ������� ������� ���� ��� �� ������ ��� ���������,
				// ������ � �� �� ��������� ������� �� ������ ���
				// no matter what!
				//if( a4->CompareTo("WH") == 0 )
				//{
				//	if( j == 5 )
				//		x17 = x17 + 1;
				//	else if( j == 6 )
				//		x17 = x17 + 1.1;
				//	else if( j == 7 )
				//		x17 = x17 + 1.2;
				//}
			}
			else if (CSsk[(i),(j)]->CompareTo("WR") == 0)
				x17 = x17 + 7;
			else if (CSsk[(i),(j)]->CompareTo("WN") == 0)
				x17 = x17 + 5;
			else if (CSsk[(i),(j)]->CompareTo("WB") == 0)
				x17 = x17 + 5;
			else if (CSsk[(i),(j)]->CompareTo("WQ") == 0)
					x17 = x17 + 11;
			else if (CSsk[(i),(j)]->CompareTo("WK") == 0)
			{
				// � (������) �������� ���� ���� ����� ����.
				// ���� ������� ����� ��� � ������ �������� ���� �.�.
				// ���� 100 (���� ���� ������), ���� � ������
				// ����������� �� ������� ��� �� �������� ���
				// �� �������� ����� �� ���� �� ������� ��� ���������,
				// ��� �� ����� �������� ��������.
				// �.�. �� ��� ����� ��� 5 �������� ��� ������ �� �����
				// � ����������� ������ ��� �� ������ ��� �������� �������,
				// ���� ������ �� ������ ����� ��� �� ��������� ��� ����
				// ����� ��� �������� � �� �������� ��� ������ ��� ��� ��
				// ��� ����� � ��������� 1 ������ ���� (���� ��� ����� ����
				// ��� �������� �� �������� �� ������ ���� ��� ����� ���
				// �� ������ ��� �� ���� ��� ����: �� +100 ��� ������ �������
				// �� ��������������� ��� �� -100 ��� ������ ��� ��� ��
				// "������������" ����!
				// �� ���������� ��������� �� ��� ����� �������.
				x17 = x17 + 17;
			}
			else if (CSsk[(i),(j)]->CompareTo("BP") == 0)
			{
				x17 = x17 - 1;

				// �� �� ����� ���� �� ���� ���������.
				// � ������� ������� ���� ��� �� ������ ��� ���������,
				// ������ � �� �� ��������� ������� �� ������ ���
				// no matter what!
				//if( a4->CompareTo("BL") == 0 )
				//{
					//if( j == 2 )
						x17 = x17 - 1;
					//else if( j == 1 )
					//	x17 = x17 - 1.1;
					//else if( j == 0 )
					//	x17 = x17 - 1.2;
				//}
			}
			else if (CSsk[(i),(j)]->CompareTo("BR") == 0)
				x17 = x17 - 7;
			else if (CSsk[(i),(j)]->CompareTo("BN") == 0)
				x17 = x17 - 5;
			else if (CSsk[(i),(j)]->CompareTo("BB") == 0)
				x17 = x17 - 5;
			else if (CSsk[(i),(j)]->CompareTo("BQ") == 0)
					x17 = x17 - 11;
			else if (CSsk[(i),(j)]->CompareTo("BK") == 0)
				x17 = x17 - 17;

		}
	}

	}


// FUNCTION TO CHECK THE LEGALITY (='n' in Greek) OF A MOVE
// (i.e. if between the initial and the destination square lies another
// piece, then the move is not legal).
bool Elegxosns(array<String^, 2>^ ENsk)              
	{												         
	// TODO: Add your control notification handler code here

	bool n;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// ������� ��� "�����������" ��� �������. �� �.�. � ������� ���� �������� �� ������� ���� ����� ���
	// �� �2 ��� �5, ���� ��� �4 ������� ������ ����� ���, ���� � n ���� ���� false.
	// � ��������� "����������" �� boolean ��������� n.
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////

	n = true;

	if( ((q2-1) > 7) || ((q2-1) < 0) || ((e20-1) > 7) || ((e20-1) < 0) )
		n = false;

	// if a piece of the same colout is in the destination square...
	if ( (a5->CompareTo("WK") == 0) || (a5->CompareTo("WQ") == 0) || (a5->CompareTo("WR") == 0) || (a5->CompareTo("WN") == 0) || (a5->CompareTo("WB") == 0)  || (a5->CompareTo("WP") == 0) )
	{
		if ( (ENsk[((e20-1)),((q2-1))]->CompareTo("WK") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("WQ") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("WR") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("WN") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("WB") == 0)  || (ENsk[((e20-1)),((q2-1))]->CompareTo("WP") == 0) )
		{
			n = false;
		}
	}
	else if ( (a5->CompareTo("BK") == 0) || (a5->CompareTo("BQ") == 0) || (a5->CompareTo("BR") == 0) || (a5->CompareTo("BN") == 0) || (a5->CompareTo("BB") == 0)  || (a5->CompareTo("BP") == 0) )
	{
		if ( (ENsk[((e20-1)),((q2-1))]->CompareTo("BK") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("BQ") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("BR") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("BN") == 0) || (ENsk[((e20-1)),((q2-1))]->CompareTo("BB") == 0)  || (ENsk[((e20-1)),((q2-1))]->CompareTo("BP") == 0) )
			n = false;
	}

	if (a5->CompareTo("WK") == 0)
	{
		/////////////////////////
		// white king
		/////////////////////////
		// is the king threatened in the destination square?
		// temporarily move king
		ENsk[(e19 - 1), (h9 - 1)] = "";
		h2 = ENsk[(e20 - 1), (q2 - 1)];
		ENsk[(e20 - 1), (q2 - 1)] = "WK";

		e2 = chForWHch(ENsk);

		if (e2 == true)
			n = false;

		// restore pieces
		ENsk[(e19 - 1), (h9 - 1)] = "WK";
		ENsk[(e20 - 1), (q2 - 1)] = h2;

	}
	else if (a5->CompareTo("BK") == 0)
	{
		///////////////////////////
		// black king
		///////////////////////////
		// is the black king threatened in the destination square?
		// temporarily move king
		ENsk[(e19 - 1), (h9 - 1)] = "";
		h2 = ENsk[(e20 - 1), (q2 - 1)];
		ENsk[(e20 - 1), (q2 - 1)] = "BK";

		e3 = chForBLch(ENsk);

		if (e3 == true)
			n = false;

		// restore pieces
		ENsk[(e19 - 1), (h9 - 1)] = "BK";
		ENsk[(e20 - 1), (q2 - 1)] = h2;

	}
	else if (a5->CompareTo("WP") == 0)
	{
		/////////////////////
		// white pawn
		/////////////////////

		// move forward

		if ( (q2 == (h9 + 1)) && (e20 == e19) )
		{
			if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 1)
					n = false;
		}

		// move forward for 2 squares
		else if ((q2 == (h9 + 2)) && (e20 == e19))
		{
			if (h9 == 2)
			{
				if ((ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 1)|| (ENsk[(e20 - 1),(q2 - 1 - 1)]->CompareTo("") == 1))
						n = false;
			}
		}

		// eat forward to the right

		else if ((q2 == (h9 + 1)) && (e20 == e19 + 1))
		{
			if( q3 == false )
			{
				if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 0)
						n = false;
			}
			else
			{
				if((q2 != x9) || (e20 != x8))
					n = false;
			}
		}

		// eat forward to the left

		else if ((q2 == (h9 + 1)) && (e20 == e19 - 1))
		{
			if( q3 == false )
			{
				if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 0)
						n = false;
			}
			else
			{
				if((q2 != x9) || (e20 != x8))
					n = false;
			}
		}

	}
	else if (a5->CompareTo("BP") == 0)
	{
		/////////////////////
		// black pawn
		/////////////////////

		// move forward

		if ( (q2 == (h9 - 1)) && (e20 == e19) )
		{
			if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 1)
					n = false;
		}

		// move forward for 2 squares
		else if ((q2 == (h9 - 2)) && (e20 == e19))
		{
			if (h9 == 7)
			{
				if ((ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 1)|| (ENsk[(e20 - 1),(q2 + 1 - 1)]->CompareTo("") == 1))
						n = false;
			}
		}

		// eat forward to the right

		else if ((q2 == (h9 - 1)) && (e20 == e19 + 1))
		{
			if( q3 == false )
			{
			if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 0)
					n = false;
			}
			else
			{
				if((q2 != x9) || (e20 != x8))
					n = false;
			}
		}

		// eat forward to the left

		else if ((q2 == (h9 - 1)) && (e20 == e19 - 1))
		{
			if( q3 == false )
			{
			if (ENsk[(e20 - 1),(q2 - 1)]->CompareTo("") == 0)
					n = false;
			}
			else
			{
				if((q2 != x9) || (e20 != x8))
					n = false;
			}
		}

	}
	else if( (a5->CompareTo("WR") == 0) || (a5->CompareTo("WQ") == 0) || (a5->CompareTo("WB") == 0) || (a5->CompareTo("BR") == 0) || (a5->CompareTo("BQ") == 0) || (a5->CompareTo("BB") == 0) )
	{
		h = 0;
		p = 0;
		h5 = 0;
		h3 = 0;
		h4 = 0;

		if(((q2-1) > (h9-1)) || ((q2-1) < (h9-1)))
			h3 = ((q2-1) - (h9-1))/System::Math::Abs((q2-1) - (h9-1));
			
		if(((e20-1) > (e19-1)) || ((e20-1) < (e19-1)) )
			h4 = ((e20-1) - (e19-1))/System::Math::Abs((e20-1) - (e19-1));

		a8 = false;

		do
		{
			h = h + h3;
			p = p + h4;

			if( (((h9-1) + h) == (q2-1)) && ((((e19-1) + p)) == (e20-1)) )
				a8 = true;

			if((e19 - 1 + p)<0)
				a8 = true;
			else if((h9 - 1 + h)<0)
				a8 = true;
			else if((e19 - 1 + p)>7)
				a8 = true;
			else if((h9 - 1 + h)>7)
				a8 = true;

			// if a piece exists between the initial and the destination square,
			// then the move is illegal!
			if( a8 == false )
			{
				if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WR") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WN") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WB") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WQ") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WK") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("WP") == 0)
				{
					n = false;
					a8 = true;
				}
				
				if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BR") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BN") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BB") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BQ") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BK") == 0)
				{
					n = false;
					a8 = true;
				}
				else if(ENsk[(e19 - 1 + p),(h9 - 1 + h)]->CompareTo("BP") == 0)
				{
					n = false;
					a8 = true;
				}
			}
		}while(a8 == false);
	}
	return n;
	}


// FUNCTION TO CHECK THE CORRECTNESS (='o' in Greek) OF THE MOVE
// (i.e. a Bishop can only move in diagonals, rooks in lines and columns etc)
bool Elegxosos(array<String^, 2>^ EOsk)        
	{      
	// TODO: Add your control notification handler code here

	bool o;
	o = false;
	q3 = false;

	if ( (a2->CompareTo("h") == 0) && (x25 == false) && (a5->CompareTo("") == 1) )    // �� � ������� ���� ������ ��� ������ ����� ��� ����
	{                                                         // �������� �� ������� ��� ������� (��� ��� ���� ���-
		                                                      // ����� �� ������� ��� "����" ���������) ��� ����� � ����� ��� �� ������, ���� �� ��-
		                                                      // ��� ������� ��� ��������� ��� �������. 

	// ROOK

	if ( (a5->CompareTo("WR") == 0)||(a5->CompareTo("BR") == 0) )
	{
		if ( (e20 != e19)&&(q2 == h9) )       // ������ �� �����
			o = true;
		else if ( (q2 != h9)&&(e20 == e19) )  // ������ �� ������
			o = true;
	}

	// horse (with knight...)

	if ( (a5->CompareTo("WN") == 0)||(a5->CompareTo("BN") == 0) )
	{
		if ( (e20 == (e19 + 1)) && (q2 == (h9 + 2)) )
			o = true;
		else if ( (e20 == (e19 + 2)) && (q2 == (h9 - 1)) )
			o = true;
		else if ( (e20 == (e19 + 1)) && (q2 == (h9 - 2)) )
			o = true;
		else if ( (e20 == (e19 - 1)) && (q2 == (h9 - 2)) )
			o = true;
		else if ( (e20 == (e19 - 2)) && (q2 == (h9 - 1)) )
			o = true;
		else if ( (e20 == (e19 - 2)) && (q2 == (h9 + 1)) )
			o = true;
		else if ( (e20 == (e19 - 1)) && (q2 == (h9 + 2)) )
			o = true;
		else if ( (e20 == (e19 + 2)) && (q2 == (h9 + 1)) )
			o = true;
	}

	// bishop

	if ( (a5->CompareTo("WB") == 0)||(a5->CompareTo("BB") == 0) )
	{
		if((Math::Abs(e20-e19))==(Math::Abs(q2-h9)))
			o = true;
	}

	// queen

	if ( (a5->CompareTo("WQ") == 0)||(a5->CompareTo("BQ") == 0) )
	{
		if ( (e20 != e19)&&(q2 == h9) )       // ������ �� �����
			o = true;
		else if ( (q2 != h9)&&(e20 == e19) )  // ������ �� ������
			o = true;

		// move in diagonals
		if((Math::Abs(e20-e19))==(Math::Abs(q2-h9)))
			o = true;
	}

	// king

	if ( (a5->CompareTo("WK") == 0)||(a5->CompareTo("BK") == 0) )
	{
		// move in rows and columns

		if ( (e20 == (e19 + 1)) && (q2 == h9) )
			o = true;
		else if ( (e20 == (e19 - 1)) && (q2 == h9) )
			o = true;
		else if ( (q2 == (h9 + 1)) && (e20 == e19) )
			o = true;
		else if ( (q2 == (h9 - 1)) && (e20 == e19) )
			o = true;

		// move in diagonals

		else if ( (e20 == (e19 + 1)) && (q2 == (h9 + 1)) )
			o = true;
		else if ( (e20 == (e19 + 1)) && (q2 == (h9 - 1)) )
			o = true;
		else if ( (e20 == (e19 - 1)) && (q2 == (h9 - 1)) )
			o = true;
		else if ( (e20 == (e19 - 1)) && (q2 == (h9 + 1)) )
			o = true;

	}

	// white pawn

	if (a5->CompareTo("WP") == 0)
	{
		// move forward

		if ( (q2 == (h9 + 1)) && (e20 == e19) )
			o = true;

		// move forward for 2 squares
		else if ( (q2 == (h9 + 2)) && (e20 == e19) && (h9 == 2) )
			o = true;

		// eat forward to the left
		else if ( (q2 == (h9 + 1)) && (e20 == (e19 - 1)) && ((EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BP") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BR") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BN") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BB") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BQ") == 0) ))
			o = true;

		// eat forward to the right
		else if ( (q2 == (h9 + 1)) && (e20 == (e19 + 1)) && ((EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BP") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BR") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BN") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BB") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("BQ") == 0) ))
			o = true;

		// En Passant eat forward to the left
		else if ( (q2 == (h9 + 1)) && (e20 == (e19 - 1)) )
		{
			if((q2 == 4) && (EOsk[(e20 - 1),(4)]->CompareTo("BP") == 0))
			{
			o = true;
			q3 = true;
			EOsk[(e20 - 1),(q2 - 1 - 1)] = "";
			}
			else
			{
			o = false;
			q3 = false;
			}
		}

		// En Passant eat forward to the right
		else if ( (q2 == (h9 + 1)) && (e20 == (e19 + 1)) )
		{
			if((q2 == 4) && (EOsk[(e20 - 1),(4)]->CompareTo("BP") == 0))
			{
			o = true;
			q3 = true;
			EOsk[(e20 - 1),(q2 - 1 - 1)] = "";
			}
			else
			{
			o = false;
			q3 = false;
			}
		}

	}


	// black pawn

	if (a5->CompareTo("BP") == 0)
	{
		// move forward

		if ( (q2 == (h9 - 1)) && (e20 == e19) )
			o = true;

		// move forward for 2 squares
		else if ( (q2 == (h9 - 2)) && (e20 == e19) && (h9 == 7) )
			o = true;

		// eat forward to the left
		else if ( (q2 == (h9 - 1)) && (e20 == (e19 + 1)) && ((EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WP") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WR") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WN") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WB") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WQ") == 0) ))
			o = true;

		// eat forward to the right
		else if ( (q2 == (h9 - 1)) && (e20 == (e19 - 1)) && ((EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WP") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WR") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WN") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WB") == 0) || (EOsk[(e20 - 1),(q2 - 1)]->CompareTo("WQ") == 0) ))
			o = true;

		// En Passant eat forward to the left
		else if ( (q2 == (h9 - 1)) && (e20 == (e19 + 1)) )
		{
			if((q2 == 3)&&(EOsk[(e20 - 1),(3)]->CompareTo("WP") == 0))
			{
			o = true;
			q3 = true;
			EOsk[(e20 - 1),(q2 + 1 - 1)] = "";
			}
			else
			{
			o = false;
			q3 = false;
			}
		}

		// En Passant eat forward to the right
		else if ( (q2 == (h9 - 1)) && (e20 == (e19 - 1)) )
		{
			if((q2 == 3)&&(EOsk[(e20 - 1),(3)]->CompareTo("WP") == 0))
			{
			o = true;
			q3 = true;
			EOsk[(e20 - 1),(q2 + 1 - 1)] = "";
			}
			else
			{
			o = false;
			q3 = false;
			}
		}

	}

	}

	return o;
	}


		
void Entermove(void)                       
	{                   
	// TODO: Add your control notification handler code here

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// show the move entered by the human player
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////

	if (h8->CompareTo("A") == 0)
		e19 = 1;
	else if (h8->CompareTo("B") == 0)
		e19 = 2;
	else if (h8->CompareTo("C") == 0)
		e19 = 3;
	else if (h8->CompareTo("D") == 0)
		e19 = 4;
	else if (h8->CompareTo("E") == 0)
		e19 = 5;
	else if (h8->CompareTo("F") == 0)
		e19 = 6;
	else if (h8->CompareTo("G") == 0)
		e19 = 7;
	else if (h8->CompareTo("H") == 0)
		e19 = 8;


	if (q1->CompareTo("A") == 0)
		e20 = 1;
	else if (q1->CompareTo("B") == 0)
		e20 = 2;
	else if (q1->CompareTo("C") == 0)
		e20 = 3;
	else if (q1->CompareTo("D") == 0)
		e20 = 4;
	else if (q1->CompareTo("E") == 0)
		e20 = 5;
	else if (q1->CompareTo("F") == 0)
		e20 = 6;
	else if (q1->CompareTo("G") == 0)
		e20 = 7;
	else if (q1->CompareTo("H") == 0)
		e20 = 8;


	/////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// record which piece is moving
	/////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////

	if (a2->CompareTo("HY") == 0)   // �� ����� � ����� ��� ���������� �� ������ (��� ��� ��� ������), ���� �����!!
		Console::WriteLine("It's not your turn.");

	// �� ������� ���� ������� ��� ������ ����� (�.�. "�" � "�") ��� ���� �� ������� ��� ������� ��� ������
	// �������� (�.�. ���� ����� ���� ��� ����� �������� � ����� ��� ������ �� �������) ���� �� ���������� ��
	// ��������� �� �,�� �����.
	// ��� ����� ���������� �� ����� ��� ������� ��� �� � ������� ���� ������ ����� ������ (���� ���
	// ������� ��� �� 1 ��� �� 8), ����� ���� ������������ ��� �� ������ ��� ���������� h9 ���
	// q2 (�� ������ ����� ������� ��� �������� ��� �������� ����� ��� 1 ��� 8).

	else if ( ((a2->CompareTo("h") == 0)||(a4->CompareTo("Self") == 0)) && ( ((a1->CompareTo("WH") == 0) && ((sk[(e19 - 1),(h9 - 1)]->CompareTo("WP") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("WR") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("WN") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("WB") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("WQ") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("WK") == 0))) || ((a1->CompareTo("BL") == 0) && ((sk[(e19 - 1),(h9 - 1)]->CompareTo("BP") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("BR") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("BN") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("BB") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("BQ") == 0)||(sk[(e19 - 1),(h9 - 1)]->CompareTo("BK") == 0))) ) )
	{

	x25 = false;
	a5 = "";

	// is the king under check?
	if (a4->CompareTo("WH") == 0)
		e2 = chForWHch(sk);
	else if (a4->CompareTo("BL") == 0)
		e3 = chForBLch(sk);

	a5 = sk[(e19 - 1),(h9 - 1)];
		
	// if he chooses to move a piece of different colour...
	if ( ((a4->CompareTo("WH") == 0)||(a4->CompareTo("Self") == 0) && ((sk[(e19 - 1),((h9 - 1))]->CompareTo("WR") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("WN") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("WB") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("WQ") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("WK") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("WP") == 0)))  ||  ( ((a4->CompareTo("BL") == 0)||(a4->CompareTo("Self") == 0)) && ((sk[(e19 - 1),((h9 - 1))]->CompareTo("BR") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("BN") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("BB") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("BQ") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("BK") == 0) || (sk[(e19 - 1),((h9 - 1))]->CompareTo("BP") == 0))))
	{
		sk[(e19 - 1),(h9 - 1)] = "";
	}

	}
	else
	{
		if (a1->CompareTo("WH") == 0)
			Console::WriteLine("WH plays.");
		else if (a1->CompareTo("BL") == 0)
			Console::WriteLine("BL plays.");

		x25 = true;          // � ��������� ���� ������� true ��� �� ���� "�� ����" � ������ ���
		                               // �� ��������� ��� ��������� ������� ��� ���� ��� ������� ��� "��������"
		                               // ��� �������.
	}

	// ch correctness of move entered
	e21 = E