private void btnMoves_Click(object sender, EventArgs e)
        {
            var moves = MoveParser.Parse(txtAlg.Text);

            txtCubeMoves.Text = string.Join("\r\n", moves.Select(x => x.ToString()).ToArray());

            var calculator = new MoveCalculator();

            foreach (Move mv in moves)
            {
                calculator.AddCubeMove(mv);
            }

            txtMachineMoves.Text = string.Join("\r\n", calculator.MachineMoves.Select(x => x.ToString()).ToArray());

            txtMotorMoves.Text = string.Join("\r\n", calculator.MachineMoves.MotorMoves.Select(x => x.ToString()).ToArray());

            txtNBMotorMoves.Text = "1/4: " + calculator.MachineMoves.MotorMoves.Sum(x => x.QuarterNumber).ToString() + "  moves: " + calculator.MachineMoves.MotorMoves.Count;

            textLongMove.Text = string.Join("  ", calculator.MachineMoves.MotorMoves.Select(x => x.EquivalentCubeMove()));


            var dir = GetUriViewer(/*txtAlg.Text+ "%0A%2F%2F" +*/ textLongMove.Text, txtMoves.Text);

            viewer.FrameLoadEnd += ResetCubeOnLoad; // reset du cube au chargement

            viewer.Load(dir);
        }
Example #2
0
        public void MakeMove(string input)
        {
            IPawn toPromote = board.PromotionRequired() as IPawn;

            if (toPromote == null)
            {
                MoveParser parser = new MoveParser();
                IMove      move   = parser.Parse(input);
                IPiece     toMove = board.GetFigureAt(move.Start);
                if (toMove != null && board.CurrentTurn() == toMove.color)
                {
                    IBoard newBoard = board.Move(move);
                    if (newBoard != null)
                    {
                        board = newBoard;
                    }
                }
            }
            else
            {
                Promote(input);
            }
        }