Exemple #1
0
        public void BotPlaysRandomMove()
        {
            SimpleBot simplebot = new SimpleBot();
            int       random    = simplebot.GenerateRandomNumber(0, 5);

            Assert.AreNotEqual(random, 6);
        }
Exemple #2
0
        public void BotPlaysLessThan100Dynamites()
        {
            SimpleBot simplebot = new SimpleBot();

            Round[] rounds = new Round[1000];
            game.SetRounds(rounds);

            simplebot.GetTestValue(true);

            bool fail = true;

            for (int i = 0; i < rounds.Length; i++)
            {
                simplebot.MakeMove(game);
            }
            if (simplebot.DynamiteCount > 100)
            {
                fail = true;
            }
            else
            {
                fail = false;
            }
            Assert.IsFalse(fail);
        }
Exemple #3
0
        public void AddToHandTest()
        {
            IPlayer player = new SimpleBot("Fred");
            ICard   card   = new Card(CardID.Eight, CardPower.EightFail, Suit.Clubs);

            player.AddToHand(card);
            Assert.AreEqual(card, player.Hand.GetCard(0));
        }
    // Start is called before the first frame update
    void Start()
    {
        SpeechToText stt  = GetComponentInChildren <SpeechToText>();
        TextToSpeech tts  = GetComponentInChildren <TextToSpeech>();
        SimpleBot    chat = GetComponentInChildren <SimpleBot>();

        stt.settings  = settings;
        tts.settings  = settings;
        chat.settings = settings;
    }
        public void CheckIfTicBotAddsCrosses()
        {
            var game = new Game();

            game.InitHistory();
            game.InitBoard();
            var ticBot = new SimpleBot(Side.Tic);

            ticBot.MakeAutoMove(game);
            Assert.Equal(Side.Tic, game.History.LastTurn.Side);
        }
Exemple #6
0
        public void BotPlaysDynamite()
        {
            SimpleBot simplebot = new SimpleBot();
            Round     round     = new Round();

            Move move = Move.W;

            round.SetP1(move);

            move = simplebot.PlayDynamite(round);
            Assert.AreEqual(move, Move.D);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Server = new Server
            {
                Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };
            Server.Services.Add(SimpleChat.BindService((SimpleChat.SimpleChatBase)Activator.CreateInstance(typeof(SimpleChatService))));
            Server.Services.Add(SimpleBot.BindService((SimpleBot.SimpleBotBase)Activator.CreateInstance(typeof(SimpleBotService))));
            Server.Start();

            Console.WriteLine($"Server start localhost:{Port}");
            Console.ReadLine();
        }
    void Update()
    {
        /* Wait for audio clip of the output speech to finish before listening and converting
         * new input speech
         */

        nearestBotIndex = GetNearestBotIndex();

        for (int i = 0; i < botList.Count; i++)
        {
            SpeechToText stt  = botList[i].GetComponentInChildren <SpeechToText>();
            TextToSpeech tts  = botList[i].GetComponentInChildren <TextToSpeech>();
            SimpleBot    chat = botList[i].GetComponentInChildren <SimpleBot>();

            if (stt.ServiceReady())
            {
                if (nearestBotIndex != i || chat.GetStatus() == SimpleBot.ProcessingStatus.Processing || !tts.IsFinished())
                {
                    stt.Active = false;
                    stt.StopRecording();
                }
                else
                {
                    stt.Active = true;
                    stt.StartRecording();
                    Debug.Log("Bot " + i + " is active.");
                }
            }
        }

        /* I used to need to keep track of all the processing steps to known when to do
         * the next step, i.e. when to ask for a chat response and when to convert to audio.
         * This is now triggered by listeners in InputFields. I still need to keep track
         * of processing to know when to record or stop recording speech as above.
         * /
         * /*
         * if (stt.GetStatus() == SpeechToText.ProcessingStatus.Processed && chat.ServiceReady())
         * {
         *  // GetResult obtains the result of the speech to text conversion and changes the speech input status to Idle.
         *  Runnable.Run(chat.ProcessChat(stt.GetResult()));
         * }
         */
        /*
         * if (chat.GetStatus() == SimpleBot.ProcessingStatus.Processed && tts.ServiceReady())
         * {
         *  // GetResult obtains the chat response and adds it to the queue for conversion to speech audio.
         *  tts.AddTextToQueue(chat.GetResult());
         * }
         */
    }
        public void PlayBotVersusBot()
        {
            var game = new Game();

            game.InitHistory();
            game.InitBoard();
            var ticBot = new SimpleBot(Side.Tic);
            var tacBot = new SimpleBot(Side.Tac);

            while (!BoardIsFull(game.Board) && !TicTacToeRulesHelper.HasWinner(game.Board.Squares))
            {
                ticBot.MakeAutoMove(game);
                tacBot.MakeAutoMove(game);
            }
        }
Exemple #10
0
    // Start is called before the first frame update
    void Start()
    {
        SpeechToText stt  = GetComponentInChildren <SpeechToText>();
        TextToSpeech tts  = GetComponentInChildren <TextToSpeech>();
        SimpleBot    chat = GetComponentInChildren <SimpleBot>();

        stt.settings = settings;
        Runnable.Run(stt.CreateService());

        tts.settings = settings;
        Runnable.Run(tts.CreateService());

        chat.settings = settings;
        Runnable.Run(chat.CreateService());
    }
Exemple #11
0
        private void InitSimpleBot()
        {
            this.bot = new SimpleBot
            {
#if TRACE
                LogLevel = LogLevel.Trace,
#elif DEBUG
                LogLevel = LogLevel.Trace,
#elif RELEASE
                LogLevel = LogLevel.Debug,
#elif PUBLISH
                LogLevel = LogLevel.Information,
#endif
                InteractiveServiceConfig = new InteractiveServiceConfig
                {
                    DefaultTimeout = TimeSpan.FromHours(1)
                }
            };
            this.bot.Init();
        }
Exemple #12
0
    private void Start()
    {
        _planets = PlanetGenerator.Instance.Planets;

        for (int i = 1; i <= _playerCount; i++)
        {
            int playerPlanet = Random.Range(0, _planets.Count);

            _planets[playerPlanet].SetPlayer(i, _colorPallete.GetColor(i - 1));

            _planets[playerPlanet].GetComponent <Hangar>().SetDefault(_playersRefill, _playersStartShips);

            if (i > 1)
            {
                SimpleBot simpleBot = gameObject.AddComponent <SimpleBot>();
                simpleBot.Init(i);
            }

            _planets.RemoveAt(playerPlanet);
        }
    }