Exemple #1
0
        //	Sets option name to value
        //	NOTE: If the engine doesn't have an option with the specified name,
        //	nothing happens.
        public void SetOption(string name, object value)
        {
            if (State == PlayerState.Starting || State == PlayerState.NotStarted)
            {
                optionBuffer[name] = value;
                return;
            }

            EngineOption option = getOption(name);

            if (option == null)
            {
                //qDebug( "%s doesn't have option %s", qPrintable( this->name() ), qPrintable( name ) );
                return;
            }

            if (!option.IsValid(value))
            {
                //qDebug( "Invalid value for option %s: %s", qPrintable( name ), qPrintable( value.toString() ) );
                return;
            }

            option.Value = value;
            sendOption(option.Name, option.Value);
        }
Exemple #2
0
 //	Adds new option
 public void AddOption(EngineOption option)
 {
     if (EngineOptions == null)
     {
         EngineOptions = new List <EngineOption>();
     }
     EngineOptions.Add(option);
 }
Exemple #3
0
 //	Adds option to the engine options list
 protected void addOption(EngineOption option)
 {
     options.Add(option);
 }
        private void setFeature(string name, string val)
        {
            if (name == "ping")
            {
                ftPing = (val == "1");
                if (ftPing)
                {
                    SupportedFeatures.Add("ping");
                }
            }
            else if (name == "setboard")
            {
                ftSetboard = (val == "1");
                if (ftSetboard)
                {
                    SupportedFeatures.Add("setboard");
                }
            }

            /*			else if( name == "san" )
             *                      {
             *                              if( val == "1" )
             *                                      m_notation = MoveNotation.StandardAlgebraic;
             *                              else
             *                                      m_notation = MoveNotation.LongAlgebraic;
             *                      }*/
            else if (name == "usermove")
            {
                ftUsermove = (val == "1");
                if (ftUsermove)
                {
                    SupportedFeatures.Add("usermove");
                }
            }
            else if (name == "nps")
            {
                ftNps = (val == "1");
                if (ftNps)
                {
                    SupportedFeatures.Add("nps");
                }
            }
            else if (name == "time")
            {
                ftTime = (val == "1");
                if (ftTime)
                {
                    SupportedFeatures.Add("time");
                }
            }
            else if (name == "reuse")
            {
                ftReuse = (val == "1");
                if (ftReuse)
                {
                    SupportedFeatures.Add("reuse");
                }
            }
            else if (name == "myname")
            {
                if (Name == "XboardEngine")
                {
                    Name = val;
                }
            }
            else if (name == "variants")
            {
                clearVariants();
                string[] variants = val.Split(',');
                foreach (string str in variants)
                {
                    string variant = str.Trim();
                    if (variant != "")
                    {
                        addVariant(variant);
                    }
                }
            }
            else if (name == "name")
            {
                ftName = (val == "1");
                if (ftName)
                {
                    SupportedFeatures.Add("name");
                }
            }
            else if (name == "memory")
            {
                if (val == "1")
                {
                    addOption(new EngineSpinOption("memory", 32, 32, 0, 32768));
                    SupportedFeatures.Add("memory");
                }
            }
            else if (name == "smp")
            {
                if (val == "1")
                {
                    addOption(new EngineSpinOption("cores", 1, 1, 0, Environment.ProcessorCount));
                    SupportedFeatures.Add("smp");
                }
            }
            else if (name == "egt")
            {
                string[] splitVal = val.Split(',');
                foreach (string str in splitVal)
                {
                    string egtType = string.Format("egtpath {0}", str.Trim());
                    addOption(new EngineTextOption(egtType, null, null));
                }
            }
            else if (name == "option")
            {
                EngineOption option = parseOption(val);
                if (option == null || !option.IsValid())
                {
                    ;                     //qDebug() << "Invalid Xboard option from" << this->name() << ":" << val;
                }
                else
                {
                    addOption(option);
                }
            }
            else if (name == "done")
            {
                Write("accepted done", WriteMode.Unbuffered);
                initTimer.Stop();

                if (val == "1")
                {
                    initialize(this, null);
                }
                return;
            }
            else
            {
                Write("rejected " + name, WriteMode.Unbuffered);
                return;
            }

            Write("accepted " + name, WriteMode.Unbuffered);
        }