public EndgameTrainingSession(string sessionId, ChessGame game)
        {
            SessionID = sessionId;
            Game      = game;
            if (Game is AtomicChessGame && Game.IsInCheck(Player.Black))
            {
                Game = new AtomicChessGame(Game.GetFen().Replace(" w ", " b "));
                ReadOnlyCollection <Move> validMoves = Game.GetValidMoves(Player.Black);
                if (validMoves.Count == 0)
                {
                    WasAlreadyLost = true;
                }
                else
                {
                    Game.ApplyMove(validMoves[rnd.Next(0, validMoves.Count)], true);
                    Game = new AtomicChessGame(string.Join(" ", Game.GetFen().Split(' ').Take(4)) + " 0 1");
                }
            }
            ReadOnlyCollection <Move> antiValidMoves;

            if (Game is AntichessGame && (antiValidMoves = Game.GetValidMoves(Player.White)).Count == 1 && Game.GetPieceAt(antiValidMoves[0].NewPosition) != null)
            {
                WasAlreadyLost = true;
            }
            InitialFEN = Game.GetFen();
        }
        public EndgameTrainingSession(string sessionId, ChessGame game)
        {
            SessionID = sessionId;
            Game      = game;
            if (Game is AtomicChessGame && Game.IsInCheck(Player.Black))
            {
                Game = new AtomicChessGame(Game.GetFen().Replace(" w ", " b "));
                ReadOnlyCollection <Move> validMoves = Game.GetValidMoves(Player.Black);
                if (validMoves.Count == 0)
                {
                    WasAlreadyLost = true;
                }
                else
                {
                    Game.MakeMove(validMoves[rnd.Next(0, validMoves.Count)], true);
                    Game = new AtomicChessGame(string.Join(" ", Game.GetFen().Split(' ').Take(4)) + " 0 1");
                }
            }
            ReadOnlyCollection <Move> antiValidMoves;

            if (Game is AntichessGame)
            {
                if ((antiValidMoves = Game.GetValidMoves(Player.White)).Count == 1 && Game.GetPieceAt(antiValidMoves[0].NewPosition) != null)
                {
                    WasAlreadyLost = true;
                }
                else
                {
                    WasAlreadyLost = true;
                    foreach (Move valid in antiValidMoves)
                    {
                        AntichessGame copy = new AntichessGame(Game.GetFen());
                        copy.MakeMove(valid, true);
                        ReadOnlyCollection <Move> validMoves2 = copy.GetValidMoves(copy.WhoseTurn);
                        bool wonForAll = true;
                        foreach (Move valid2 in validMoves2)
                        {
                            AntichessGame copy2 = new AntichessGame(copy.GetFen());
                            copy2.MakeMove(valid2, true);
                            if (copy2.GetValidMoves(copy2.WhoseTurn).Any(x => copy2.GetPieceAt(x.NewPosition) != null))
                            {
                                wonForAll = false;
                                break;
                            }
                        }
                        if (wonForAll)
                        {
                            WasAlreadyLost = false;
                            break;
                        }
                    }
                }
            }
            InitialFEN = Game.GetFen();
        }