Beispiel #1
0
        public void DepthTakesPrecedence_OverDuration()
        {
            string fen = "k2r4/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            string move = "e5e8";

            string[] args = {"-fen", fen, "-move", move, "-depth", "5", "-duration", "30"};
            var fishyArgs = new FishyArgs (args);
            IUCIEngine engine = UCIEngine.Create (EngineKey.Stockfish);

            new Fishy.CommandLine.Fishy (fishyArgs, engine);

            Assert.AreEqual (UCIAnalysisType.ResultBased, engine.AnalysisMode);

            // order shouldn't matter either

            args = new string[] {"-fen", fen, "-move", move, "-duration", "30", "-depth", "5"};
            fishyArgs = new FishyArgs (args);
            engine = UCIEngine.Create (EngineKey.Stockfish);

            new Fishy.CommandLine.Fishy (fishyArgs, engine);

            Assert.AreEqual (UCIAnalysisType.ResultBased, engine.AnalysisMode);

            // values shouldn't matter

            args = new string[] {"-fen", fen, "-move", move, "-depth", "5", "-duration", "5"};
            fishyArgs = new FishyArgs (args);
            engine = UCIEngine.Create (EngineKey.Stockfish);

            new Fishy.CommandLine.Fishy (fishyArgs, engine);

            Assert.AreEqual (UCIAnalysisType.ResultBased, engine.AnalysisMode);
        }
Beispiel #2
0
        public void DurationDefaultsTo_20Seconds()
        {
            string fen = "k2r4/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            string[] args = {"-fen", fen};
            var fishyArgs = new FishyArgs(args);

            var fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            fishy.Run ();

            _uciMock.VerifySet (e => e.ThinkingDuration = 20);
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            try {
                var inputs = new FishyArgs(args);
                IUCIEngine engine = UCIEngine.Create (EngineKey.Stockfish);

                var fishy = new Fishy(inputs, engine);

                var feedback = fishy.Run();
                Console.WriteLine(feedback);
            }
            catch(Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #4
0
        public void UseDuration_IfSpecified()
        {
            int duration = 5;
            string fen = "k2r4/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            string[] args = {"-fen", fen, "-duration", duration.ToString ()};
            var fishyArgs = new FishyArgs(args);

            var fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            fishy.Run ();

            _uciMock.VerifySet (e => e.ThinkingDuration = duration);

            duration = 25;
            fishyArgs.ThinkingDuration = duration;

            fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            fishy.Run ();

            _uciMock.VerifySet (e => e.ThinkingDuration = duration);
        }
Beispiel #5
0
        public void ReturnUsage_WhenNoArguments()
        {
            string[] args = {};
            var fishyArgs = new FishyArgs(args);
            var fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);

            string feedback = fishy.Run();
            string[] feedbackLines = feedback.Split(Environment.NewLine.ToCharArray());

            Assert.IsNotEmpty(feedbackLines);
            Assert.AreEqual(true, feedbackLines[0].Contains("Usage:"));
        }
Beispiel #6
0
        public void ReturnScore_GivePositionAndAMove()
        {
            string fen = "k2r4/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            string move= "e5e8";

            string[] args = {"-fen", fen, "-move", move};

            // centipawns score
            IScore score = Score.Create ("info depth 19 seldepth 26 score cp 44 nodes 10051581 nps 1911310 time 5259");

            _uciMock.Setup (e => e
                .GetScore (It.IsAny<string> (), It.IsAny<string> ()))
                .Returns (() => score);

            var fishyArgs = new FishyArgs(args);
            var fishy = new Fishy.CommandLine.Fishy (fishyArgs, _engine);
            string output = fishy.Run ();

            Assert.AreEqual("44", output);

            // mate score
            score = Score.Create ("info depth 19 seldepth 26 score mate 4 nodes 10051581 nps 1911310 time 5259");

            fishy = new Fishy.CommandLine.Fishy (fishyArgs, _engine);
            output = fishy.Run ();

            Assert.AreEqual("#4", output);
        }
Beispiel #7
0
        public void ReturnBestMove_GivenFEN()
        {
            // start pos
            string fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
            string[] args = {"-fen", fen};
            var fishyArgs = new FishyArgs(args);
            string expected = "e2e4";

            _uciMock.Setup (e => e
                .GiveBestMove(It.IsAny<string>()))
                .Returns (() => expected);

            var fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            string bestMove = fishy.Run ();
            Assert.AreEqual (expected, bestMove);

            // back rank mate
            fen = "k3r3/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            fishyArgs.Position = fen;
            expected = "e5e8";

            fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            bestMove = fishy.Run ();
            Assert.AreEqual (expected, bestMove);

            // smothered mate
            fen = "k2r4/pp6/8/3NQ3/8/8/3q1PPP/6K1 w - - 0 1";
            fishyArgs.Position = fen;
            expected = "d5c7";

            fishy = new Fishy.CommandLine.Fishy(fishyArgs, _engine);
            bestMove = fishy.Run ();
            Assert.AreEqual (expected, bestMove);
        }
Beispiel #8
0
 public Fishy(FishyArgs args, IUCIEngine uciEngine)
 {
     _args = args;
     InitEngine (uciEngine);
 }