Inheritance: MonoBehaviour
        public void AddTwoPlayersWithSameNameAndScoreTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.Add("Pesho", 23);
            scoreBoard.Add("Pesho", 23);
        }
 static void ExecuteCommand(string command, ScoreBoard scoreBoard, besenica game)
 {
     switch (command)
     {
         case "top":
             {
                 scoreBoard.Print();
             }
             break;
         case "help":
             {
                 char revealedLetter = game.RevealALetter();
                 Console.WriteLine("OK, I reveal for you the next letter '{0}'.", revealedLetter);
             }
             break;
         case "restart":
             {
                 scoreBoard.ReSet();
                 Console.WriteLine("\nWelcome to “Hangman” game. Please try to guess my secret word.");
                 game.ReSet();
             }
             break;
         case "exit":
             {
                 Console.WriteLine("Good bye!");
                 return;
             } break;
         default:
             {
                 Console.WriteLine("Incorrect guess or command!");
             }
             break;
     }
 }
Beispiel #3
0
 public void Execute()
 {
     var consoleWrapper = new ConsoleWrapper();
     ScoreBoard scores = new ScoreBoard(consoleWrapper);
     scores.Source = "../../Resources/topScores.txt";
     scores.Load();
     scores.Print();
 }
 public void AddPlayerScoreTest()
 {
     string playerName = "Pesho";
     int playerScore = 20;
     var scoreBoard = new ScoreBoard();
     scoreBoard.AddPlayer(playerName, playerScore);
     Assert.AreEqual(true, scoreBoard.scoreBoard.ContainsKey(playerScore));
 }
        public void TestGetScoreboardFileLocation()
        {
            ScoreBoard scoreboard = new ScoreBoard();
            string scoreboardActualLocation = scoreboard.GetScoreboardFileLocation();
            string scoreboardExpectedLocation = "../../scoreboard.txt";

            Assert.AreEqual(scoreboardExpectedLocation, scoreboardActualLocation);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayCommand"/> class.
 /// </summary>
 /// <param name="currentCommand">Given command.</param>
 /// <param name="topPlayers">Top players of the game.</param>
 /// <param name="scoreBoard">Current score board.</param>
 /// <param name="board">Current play board.</param>
 /// <param name="printer">Given printer.</param>
 public PlayCommand(string currentCommand, string[,] topPlayers, ScoreBoard scoreBoard, Board board, IPrinterManager printer)
 {
     this.currentCommand = currentCommand;
     this.topPlayers = topPlayers;
     this.scoreBoard = scoreBoard;
     this.board = board;
     this.printer = printer;
 }
Beispiel #7
0
    void Awake()
    {
        SP = this;
        gameSetupScript = GetComponent<GameSetup>() as GameSetup;

        highscoreText = GetComponent<GUIText>() as GUIText;
        highscoreText.enabled = false;
    }
Beispiel #8
0
 public TennisMatch(ScoreBoard scoreBoard, Player player1, Player player2, Sets sets, Game game)
 {
     _scoreBoard = scoreBoard;
     _player1 = player1;
     _player2 = player2;
     _sets = sets;
     _game = game;
 }
 public void AddShortMaxValueNumberOfPlayersTest()
 {
     ScoreBoard scoreBoard = new ScoreBoard();
     for (int i = 0; i < short.MaxValue; i++)
     {
         scoreBoard.Add(i.ToString(), 23);
     }
 }
Beispiel #10
0
 static void Main()
 {
     ScoreBoard scoreBoard = new ScoreBoard();
     besenica game = new besenica();
     Console.WriteLine("Welcome to “Hangman” game. Please try to guess my secret word.");
     string command = null;
     do
     {
         Console.WriteLine();
         game.PrintCurrentProgress();
         if (game.isOver())
         {
             if (game.HelpUsed)
             {
                 Console.WriteLine("You won with {0} mistake(s) but you have cheated." +
                     " You are not allowed to enter into the scoreboard.", game.Mistackes);
             }
             else
             {
                 if (scoreBoard.GetWorstTopScore() <= game.Mistackes)
                 {
                     Console.WriteLine("You won with {0} mistake(s) but you score did not enter in the scoreboard",
                         game.Mistackes);
                 }
                 else
                 {
                     Console.Write("Please enter your name for the top scoreboard: ");
                     string name = Console.ReadLine();
                     scoreBoard.AddNewScore(name, game.Mistackes);
                     scoreBoard.Print();
                 }
             }
             game.ReSet();
         }
         else
         {
             Console.Write("Enter your guess: ");
             command = Console.ReadLine();
             command.ToLower();
             if (command.Length == 1)
             {
                 int occuranses = game.NumberOccuranceOfLetter(command[0]);
                 if (occuranses == 0)
                 {
                     Console.WriteLine("Sorry! There are no unrevealed letters “{0}”.", command[0]);
                 }
                 else
                 {
                     Console.WriteLine("Good job! You revealed {0} letter(s).", occuranses);
                 }
             }
             else
             {
                 ExecuteCommand(command, scoreBoard, game);
             }
         }
     } while (command != "exit");
 }
        public void TestShowScoreboard_WhenEmpty()
        {
            ScoreBoard scoreboard = new ScoreBoard();
            File.Delete(scoreboard.GetScoreboardFileLocation());
            var actual = scoreboard.ShowScoreboard();
            string expected = "Scoreboard is empty. Congratulations, you will be the first who will play that game!";

            Assert.AreEqual(expected, actual);
        }
        public void AddEmptyNameToScoreBoard()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.Add(string.Empty, 23);

            string str = scoreBoard.Scores().Values.ToString();
            str += scoreBoard.Scores().Keys.ToString();
            Assert.AreEqual(str, "{Anonymous}{23}");
        }
        public void TestGetTopResults()
        {
            Playfield playfield = new Playfield();
            GameEngine engine = new GameEngine(playfield);

            string expected = engine.GetTopResults();
            string actual = new ScoreBoard().ShowScoreboard();
            Assert.AreEqual(expected, actual);
        }
        public void AddZeroPlayerScoreTest()
        {
            string playerName = "Pesho";
            int playerScore = 0;

            var newScoreBoard = new ScoreBoard();
            newScoreBoard.AddPlayer(playerName, playerScore);
            Assert.AreEqual("0", newScoreBoard.scoreBoard.ContainsKey(playerScore).ToString());
        }
        public void AddNegativePlayerScoreTest()
        {
            string playerName = "Pesho";
            int playerScore = -1;

            var newScoreBoard = new ScoreBoard();
            newScoreBoard.AddPlayer(playerName, playerScore);
            Assert.AreEqual("Enter your name, please", newScoreBoard.scoreBoard.Contains(playerScore, playerName));
        }
    void Start()
    {
        scoreboard = this.GetComponent<ScoreBoard>();
        
        id = UnityEngine.Random.Range(0, int.MaxValue);


        size = new Vector2(100, 300);
        //Application.ExternalCall("GetUrl");
    }
 public ConsoleMinesweeperEngine(IRenderer renderer)
 {
     this.scoreBoard = new ScoreBoard(renderer);
     this.renderer = renderer;
     this.cellsOpened = 0;
     this.topList = new List<Player>();
     this.emptyScoreboard = true;
     this.playerAddedToScoreboard = false;
     this.gameInProgress = true;
 }
        public void AddScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            int actual = scoreBoard.Scores.Count;
            int expected = 3;

            Assert.AreEqual(expected, actual);
        }
Beispiel #19
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if(col.tag == "Player")
        {
            Time.timeScale = 0;
            scoreBoard.SetActive(true);
            scoreBoardScript = GameObject.Find("GameController").GetComponent<ScoreBoard>();
            scoreBoardScript.ExitActive = true;

        }
    }
        public void ScoreBoard_AddMethod()
        {
            var pesho = new Player("Pesho");

            ScoreBoard<Player> scoreBoard = new ScoreBoard<Player>();
            scoreBoard.Add(pesho);

            foreach (var player in scoreBoard)
            {
                Assert.AreSame(pesho,player);
            }
        }
        public void AddToScoreBoard()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.Add("Pesho", 23);
            scoreBoard.Add("Gosho", 13);
            scoreBoard.Add("Tosho", 17);
            string str = scoreBoard.Scores().Values.ToString();
            str += scoreBoard.Scores().Keys.ToString();

            Assert.AreEqual(str, "{Gosho,Tosho,Pesho}{13,17,23}");
        }
        public void AddSixScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            scoreBoard.AddNewScore(8, "Petkan");
            scoreBoard.AddNewScore(3, "Temelko");
            scoreBoard.AddNewScore(3, "Temelko");
            List<Score> actual = scoreBoard.Scores;

            Assert.AreEqual(5, actual.Count);
        }
Beispiel #23
0
    void Start()
    {
        scoreBoard = GetComponent<ScoreBoard>();

        for (int i = 0; i < maxTeam; i++)
        {
            Spawn(1);
        }

        for (int b = 0; b < maxTeam; b++)
        {
            Spawn(2);
        }
    }
        public void TestAddPlayerInScoreboard_Add1Player()
        {
            ScoreBoard scoreboard = new ScoreBoard();
            File.Delete(scoreboard.GetScoreboardFileLocation());

            scoreboard.AddPlayerInScoreboard("Plamen", 1);
            int playerPosition = 0;

            StringBuilder expectedScoreboard = new StringBuilder();
            expectedScoreboard.AppendFormat("{0}: {1} -> {2}", ++playerPosition, "Plamen", 1).AppendLine();
            var actualScoreboard = scoreboard.ShowScoreboard();

            Assert.AreEqual(expectedScoreboard.ToString(), actualScoreboard);
        }
        public void AddEmptyPlayerNameTest()
        {
            var output = new StringBuilder();
            var textWriter = new StringWriter(output);
            Console.SetOut(textWriter);

            string playerName = "";
            int playerScore = 20;
            var newScoreBoard = new ScoreBoard();
            newScoreBoard.AddPlayer(playerName, playerScore);

            string outputStr = output.ToString();

            Assert.AreEqual("Enter your name, please\r\n", outputStr);
        }
        public void AddMoreThanFiveOnScoreBoardTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            scoreBoard.Add("Pesho", 23);
            scoreBoard.Add("Gosho", 13);
            scoreBoard.Add("Ivan", 18);
            scoreBoard.Add("Kiro", 17);
            scoreBoard.Add("Stamat", 14);
            scoreBoard.Add("Mimi", 12);
            scoreBoard.Add("Tosho", 10);

            string str = scoreBoard.Scores().Values.ToString();
            str += scoreBoard.Scores().Keys.ToString();
            Assert.AreEqual(str, "{Tosho,Mimi,Gosho,Stamat,Kiro,Ivan,Pesho}{10,12,13,14,17,18,23}");
        }
        public void AddThreeScoresCountTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Dragan");
            List<Score> actual = scoreBoard.Scores;
            List<Score> expected = new List<Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            Assert.AreEqual(expected.Count, actual.Count);
        }
        public void AddThreeDifferentScoresTest()
        {
            ScoreBoard scoreBoard = new ScoreBoard();
            scoreBoard.AddNewScore(4, "Pesho");
            scoreBoard.AddNewScore(7, "Gosho");
            scoreBoard.AddNewScore(5, "Drago");
            List<Score> actual = scoreBoard.Scores;
            List<Score> expected = new List<Score>()
            {
                new Score(4, "Pesho"),
                new Score(7, "Gosho"),
                new Score(5, "Dragan")
            };

            expected.Sort();

            CollectionAssert.AreNotEqual(expected, actual);
        }
Beispiel #29
0
	void Start () {

        scoreBoard = GetComponent<ScoreBoard>();

        if (FlagTag != null)
        {
            flag = GameObject.FindGameObjectWithTag(FlagTag); 
        }
        
        if (RedBaseTag != null)
        {
            redBase = GameObject.FindGameObjectWithTag(RedBaseTag); 
        }
        
        if (BlueBaseTag != null)
        {
            blueBase = GameObject.FindGameObjectWithTag(BlueBaseTag); 
        }
	}
        /// <summary>
        /// Process the game.
        /// </summary>
        /// <param name="playBoard">Current play board value.</param>
        /// <param name="playerMoves">Current player moves.</param>
        public void ProcessGame(ref char[,] playBoard, ref int playerMoves)
        {
            byte rowLenght = (byte)playBoard.GetLength(0);
            byte columnLenght = (byte)playBoard.GetLength(1);
            Board boardGenerator = new Board(rowLenght, columnLenght);

            ScoreBoardFormatter formatter = new ScoreBoardFormatter();

            // ILogger fileLogger = new FileLogger("scorebord.txt", formatter);
            ILogger consoleLogger = new ConsoleLogger(formatter);
            ScoreBoard scoreBoard = new ScoreBoard(consoleLogger);

            var printer = PrintingManager.Instance;

            switch (this.currentCommand)
            {
                case "RESTART":
                    IInputCommand restart = new RestartCommand(boardGenerator, printer);
                    restart.Execute(ref playBoard, ref playerMoves);
                    break;

                case "TOP":
                    IInputCommand topscoreBoard = new TopCommand(scoreBoard, this.topPlayers);
                    topscoreBoard.Execute(ref playBoard, ref playerMoves);
                    break;

                case "EXIT":
                    break;

                default:
                    InputCommandValidator validator = new InputCommandValidator();
                    if (validator.IsValidInputCommand(this.currentCommand))
                    {
                        IInputCommand play = new PlayCommand(this.currentCommand, this.topPlayers, scoreBoard, boardGenerator, printer);
                        play.Execute(ref playBoard, ref playerMoves);
                        break;
                    }

                    Console.WriteLine("Wrong input ! Try Again ! ");
                    break;
            }
        }
Beispiel #31
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject obj = GameObject.Find("scoreText");

        scoreBoard = obj.GetComponent <ScoreBoard>();
    }
Beispiel #32
0
 public FormScoreBoard(ScoreBoard scoreBoard)
 {
     this.InitializeComponent();
     this.dataGridViewBoard.DataSource = scoreBoard.Entries.Where(entry => ScoreBoard.ValidateChecksum(entry)).OrderByDescending(x => x.Score).ToList();
     this.dataGridViewBoard.Columns[nameof(ScoreEntry.Checksum)].Visible = false;
 }
Beispiel #33
0
 // Start is called before the first frame update
 void Start()
 {
     AddSphereCollider();
     scoreBoard = FindObjectOfType <ScoreBoard>();
 }
Beispiel #34
0
 void Start()
 {
     scoreBoard = GameObject.Find("Score Board").GetComponent <ScoreBoard>();
 }
Beispiel #35
0
 // Use this for initialization
 void Start()       // Getting the scoreboard component
 {
     scoreBoard = FindObjectOfType <ScoreBoard>();
 }
Beispiel #36
0
        public void LastFrameMustBeLast()
        {
            var scoreBoard = new ScoreBoard();

            scoreBoard.Play(1, 1, 1);
        }
Beispiel #37
0
 public void SetUp()
 {
     scoreBoard = new ScoreBoard();
 }
Beispiel #38
0
 void Start()
 {
     AddBoxCollider();
     _scoreBoard = FindObjectOfType <ScoreBoard>();
 }
Beispiel #39
0
 // Use this for initialization
 private void Start()
 {
     scoreBoardRef = FindObjectOfType <ScoreBoard>();
 }
Beispiel #40
0
 void Start()
 {
     scoreBoard  = FindObjectOfType <ScoreBoard>();
     ammoCounter = FindObjectOfType <AmmoCounter>();
 }
 // Start is called before the first frame update
 void Start()
 {
     scoreBoard = FindObjectOfType <ScoreBoard>();
     parent     = FindObjectOfType <Parent>();
 }
Beispiel #42
0
 // Start is called before the first frame update
 void Start()
 {
     scoreBoard = FindObjectOfType <ScoreBoard>();
 }
Beispiel #43
0
        public void ScoreboardIsZeroAtGameStart()
        {
            ScoreBoard scoreBoard = new ScoreBoard();

            Assert.AreEqual(scoreBoard.Score, 0);
        }
Beispiel #44
0
        Unsafe16Array <Point> SearchFirstPlace()
        {
            Unsafe16Array <Point> newMyAgents = MyAgents;

            //均等に配置する
            //平方根を用いていろいろする
            uint xn    = (uint)Math.Sqrt(AgentsCount);
            uint yn    = (uint)AgentsCount / xn;
            uint ratio = (uint)(ScoreBoard.GetLength(0) / ScoreBoard.GetLength(1)); //縦横の比率

            if (ScoreBoard.GetLength(0) > ScoreBoard.GetLength(1))
            {
                uint tmp = xn;
                xn = yn;
                yn = tmp;
            }
            uint left   = (uint)(AgentsCount - (xn * yn)); //AgentsCountが7の時など、エージェントが余ってしまうときに
            uint spaceX = (uint)ScoreBoard.GetLength(0) / (xn * ratio);
            uint spaceY = (uint)ScoreBoard.GetLength(1) / yn;

            for (byte i = 0; i < AgentsCount - left;)
            {
                uint baseX = spaceX * (i % xn) + spaceX / 2, baseY = spaceY * (i / xn) + spaceY / 2;
                if (MyAgentsState[i] == AgentState.Move)
                {
                    goto next;
                }
                for (byte j = 0; j < spaceX / 2; j++)
                {
                    if (ScoreBoard[(baseX + j) * ratio, baseY] >= 0 && !EnemyBoard[(baseX + j) * ratio, baseY])
                    {
                        newMyAgents[i] = new Point((byte)((baseX + j) * ratio), (byte)baseY);
                        goto next;
                    }
                }
                for (byte j = 0; j < spaceX / 2; j++)
                {
                    if (ScoreBoard[(baseX - j) * ratio, baseY] >= 0 && !EnemyBoard[(baseX - j) * ratio, baseY])
                    {
                        newMyAgents[i] = new Point((byte)((baseX - j) * ratio), (byte)baseY);
                        goto next;
                    }
                }
                for (byte j = 0; j < spaceY / 2; j++)
                {
                    if (ScoreBoard[baseX * ratio, baseY + j] >= 0 && !EnemyBoard[baseX * ratio, baseY + j])
                    {
                        newMyAgents[i] = new Point((byte)(baseX * ratio), (byte)(baseY + j));
                        goto next;
                    }
                }
                for (byte j = 0; j < spaceX / 2; j++)
                {
                    if (ScoreBoard[baseX * ratio, baseY - j] >= 0 && !EnemyBoard[baseX * ratio, baseY - j])
                    {
                        newMyAgents[i] = new Point((byte)(baseX * ratio), (byte)(baseY - j));
                        goto next;
                    }
                }
                newMyAgents[i] = new Point((byte)(baseX * ratio), (byte)baseY);
next:
                ++i;
            }

            if (left == 0)
            {
                return(newMyAgents);
            }
            int cur = AgentsCount - (int)left - 1;

            for (;; ++cur)
            {
                if (cur >= AgentsCount)
                {
                    return(newMyAgents);
                }
                if (MyAgentsState[cur] == AgentState.Move)
                {
                    continue;
                }
                break;
            }
            Random       rand       = new Random();
            List <Point> recommends = new List <Point>();

            //余ったエージェントの配置
            // 10点より高いところに配置する
            for (byte x = 0; x < ScoreBoard.GetLength(0); ++x)
            {
                for (byte y = 0; y < ScoreBoard.GetLength(1); ++y)
                {
                    if (ScoreBoard[x, y] >= 10 && !EnemyBoard[x, y])
                    {
                        recommends.Add(new Point(x, y));
                    }
                }
            }

            foreach (var p in recommends.OrderBy(i => rand.Next()))
            {
                do
                {
                    cur++;
                    if (cur >= AgentsCount)
                    {
                        return(newMyAgents);
                    }
                } while (MyAgentsState[cur] == AgentState.Move);
                newMyAgents[cur] = p;
            }

            //まだ余っていたら
            for (byte x = 0; x < ScoreBoard.GetLength(0); ++x)
            {
                for (byte y = 0; y < ScoreBoard.GetLength(1); ++y)
                {
                    if (ScoreBoard[x, y] >= -1 && !EnemyBoard[x, y])
                    {
                        recommends.Add(new Point(x, y));
                    }
                }
            }

            foreach (var p in recommends.OrderBy(i => rand.Next()))
            {
                do
                {
                    cur++;
                    if (cur >= AgentsCount)
                    {
                        return(newMyAgents);
                    }
                } while (MyAgentsState[cur] == AgentState.Move);
                newMyAgents[cur] = p;
            }
            return(newMyAgents);
        }
Beispiel #45
0
        protected override void Solve()
        {
            var myAgents = SearchFirstPlace();

            Array.Clear(dp1, 0, dp1.Length);
            Array.Clear(dp2, 0, dp2.Length);

            int deepness = StartDepth;
            int maxDepth = (TurnCount - CurrentTurn) + 1;

            PointEvaluator.Base evaluator = (TurnCount / 3 * 2) < CurrentTurn ? PointEvaluator_Normal : PointEvaluator_Dispersion;
            SearchState         state     = new SearchState(MyBoard, EnemyBoard, myAgents, EnemyAgents, MySurroundedBoard, EnemySurroundedBoard);
            int score = 0;

            for (uint x = 0; x < ScoreBoard.GetLength(0); ++x)
            {
                for (uint y = 0; y < ScoreBoard.GetLength(1); ++y)
                {
                    if (MyBoard[x, y])
                    {
                        score += ScoreBoard[x, y];
                    }
                    else if (MySurroundedBoard[x, y])
                    {
                        score += Math.Abs(ScoreBoard[x, y]);
                    }
                    else if (EnemyBoard[x, y])
                    {
                        score -= ScoreBoard[x, y];
                    }
                    else if (EnemySurroundedBoard[x, y])
                    {
                        score -= Math.Abs(ScoreBoard[x, y]);
                    }
                }
            }

            Log("TurnCount = {0}, CurrentTurn = {1}", TurnCount, CurrentTurn);
            //if (!(lastTurnDecided is null)) Log("IsAgent1Moved = {0}, IsAgent2Moved = {1}, lastTurnDecided = {2}", IsAgent1Moved, IsAgent2Moved, lastTurnDecided);

            if (!(lastTurnDecided is null) && score > 0)    //勝っている状態で競合していたら
            {
                int i;
                for (i = 0; i < AgentsCount; ++i)
                {
                    if (IsAgentsMoved[i])
                    {
                        break;
                    }
                }
                if (i == AgentsCount)
                {
                    SolverResultList.Add(lastTurnDecided);
                    return;
                }
            }
            for (; deepness <= maxDepth; deepness++)
            {
                Decided resultList = new Decided();

                //普通にNegaMaxをして、最善手を探す
                for (int agent = 0; agent < AgentsCount; ++agent)
                {
                    if (MyAgentsState[agent] == AgentState.NonPlaced)
                    {
                        continue;
                    }
                    NegaMax(deepness, state, int.MinValue + 1, 0, evaluator, null, agent);
                }
                var res = dp1[0];
                for (int agent = 0; agent < AgentsCount; ++agent)
                {
                    if (MyAgentsState[agent] == AgentState.NonPlaced)
                    {
                        res[agent] = myAgents[agent];
                    }
                }
                Decision best1 = new Decision((byte)AgentsCount, res, agentStateAry);
                resultList.Add(best1);
                //競合手.Agent1 == 最善手.Agent1 && 競合手.Agent2 == 最善手.Agent2になった場合、競合手をngMoveとして探索をおこない、最善手を探す
                for (int i = 0; i < AgentsCount; ++i)
                {
                    if (IsAgentsMoved[i] || (!(lastTurnDecided is null) && lastTurnDecided.Agents[i] != best1.Agents[i]))
                    {
                        break;
                    }
                    if (i < AgentsCount - 1)
                    {
                        continue;
                    }

                    for (int agent = 0; agent < AgentsCount; ++agent)
                    {
                        if (MyAgentsState[agent] == AgentState.NonPlaced)
                        {
                            continue;
                        }
                        NegaMax(deepness, state, int.MinValue + 1, 0, evaluator, best1, agent);
                    }
                    res = dp2[0];
                    for (int agent = 0; agent < AgentsCount; ++agent)
                    {
                        if (MyAgentsState[agent] == AgentState.NonPlaced)
                        {
                            res[agent] = myAgents[agent];
                        }
                    }
                    Decision best2 = new Decision((byte)AgentsCount, res, agentStateAry);
                    resultList.Add(best2);
                }

                if (CancellationToken.IsCancellationRequested == false)
                {
                    SolverResultList = resultList;
                    if (SolverResultList.Count == 2 && score <= 0)  //現時点で引き分けか負けていたら競合を避けるのを優先してみる(デバッグ用)
                    {
                        var tmp = SolverResultList[0];
                        SolverResultList[0] = SolverResultList[1];
                        SolverResultList[1] = tmp;
                        Log("[SOLVER] Swaped! {0} {1}", SolverResult.Agents[0], SolverResult.Agents[1]);
                    }
                    Log("[SOLVER] SolverResultList.Count = {0}, score = {1}", SolverResultList.Count, score);
                }
                else
                {
                    return;
                }
                Log("[SOLVER] deepness = {0}", deepness);
            }
        }
Beispiel #46
0
//    public ParticleSystem m_ExplosionParticles;

    // Use this for initialization
    void Start()
    {
        sb = GameObject.FindGameObjectWithTag("ScoreBoard").GetComponent <ScoreBoard>();
    }
Beispiel #47
0
    public void PlayMines()
    {
        ScoreBoard scoreBoard = new ScoreBoard();
        Random     randomMines;

        string[,] minichki;
        int  row;
        int  col;
        int  minesCounter;
        int  revealedCellsCounter;
        bool isBoomed;

        // oxo glei glei
        // i go to si imam :)
start:
        Zapochni(out minichki, out row, out col,
                 out isBoomed, out minesCounter, out randomMines, out revealedCellsCounter);

        FillWithRandomMines(minichki, randomMines);

        PrintInitialMessage();

        while (true)
        {
            Display(minichki, isBoomed);
enterRowCol:
            Console.Write("Enter row and column: ");
            string line = Console.ReadLine();
            line = line.Trim();

            if (IsMoveEntered(line))
            {
                string[] inputParams = line.Split();
                row = int.Parse(inputParams[0]);
                col = int.Parse(inputParams[1]);

                if ((row >= 0) && (row < minichki.GetLength(0)) && (col >= 0) && (col < minichki.GetLength(1)))
                {
                    bool hasBoomedMine = Boom(minichki, row, col);
                    if (hasBoomedMine)
                    {
                        isBoomed = true;
                        Display(minichki, isBoomed);
                        Console.Write("\nBooom! You are killed by a mine! ");
                        Console.WriteLine("You revealed {0} cells without mines.", revealedCellsCounter);

                        Console.Write("Please enter your name for the top scoreboard: ");
                        string currentPlayerName = Console.ReadLine();
                        scoreBoard.AddPlayer(currentPlayerName, revealedCellsCounter);

                        Console.WriteLine();
                        goto start;
                    }
                    bool winner = PichLiSi(minichki, minesCounter);
                    if (winner)
                    {
                        Console.WriteLine("Congratulations! You are the WINNER!\n");

                        Console.Write("Please enter your name for the top scoreboard: ");
                        string currentPlayerName = Console.ReadLine();
                        scoreBoard.AddPlayer(currentPlayerName, revealedCellsCounter);

                        Console.WriteLine();
                        goto start;
                    }
                    revealedCellsCounter++;
                }
                else
                {
                    Console.WriteLine("Enter valid Row/Col!\n");
                }
            }
            else if (proverka(line))
            {
                switch (line)
                {
                case "top":
                {
                    scoreBoard.PrintScoreBoard();
                    goto enterRowCol;
                }

                case "exit":
                {
                    Console.WriteLine("\nGood bye!\n");
                    Environment.Exit(0);
                    break;
                }

                case "restart":
                {
                    Console.WriteLine();
                    goto start;
                }
                }
            }
            else
            {
                Console.WriteLine("Invalid Command!");
            }
        }
    }
 void Update()
 {
     scoreText.text = "$" + ScoreBoard.GetScore(playerID) + "M";
 }
Beispiel #49
0
 // Start is called before the first frame update
 void Start()
 {
     rb          = GetComponent <Rigidbody>();
     audioSource = GetComponent <AudioSource>();
     scoreText   = GetComponent <ScoreBoard>();
 }
Beispiel #50
0
        /// <summary>
        /// Executes the commands for "Restart", for top players and to exit from the game
        /// </summary>
        /// <param name="commandList">Takes the command from the list at a specified index</param>
        public void ExecuteCommand(List <string> commandList)
        {
            if (commandList.Count == 0)
            {
                this.NextCommand();
            }

            try
            {
                string firstCommand = commandList.ElementAt(0);
                switch (firstCommand)
                {
                case "RESTART":
                    this.Start();
                    break;

                case "TOP":
                    this.PrintScoreBoard();
                    this.NextCommand();
                    break;

                case "EXIT":
                    this.Exit();
                    break;

                default:
                {
                    int  row      = 0;
                    int  column   = 0;
                    bool tryParse = false;

                    tryParse = int.TryParse(commandList.ElementAt(0), out row);
                    tryParse = int.TryParse(commandList.ElementAt(1), out column) && tryParse;

                    if (!tryParse || commandList.Count < 2)
                    {
                        throw new CommandUnknownException();
                    }

                    if (Grid.RevealCell(row, column) == '*')
                    {
                        Grid.MarkCell('-');
                        Grid.RevealMines();
                        Console.WriteLine(Grid.ToString());
                        Console.WriteLine(string.Format("Booooom! You were killed by a mine. You revealed {0} cells without mines.", this.Score));
                        Console.Write("Please enter your name for the top scoreboard: ");
                        string playerName = Console.ReadLine();
                        ScoreBoard.Add(new ScoreRecord(playerName, Score));
                        Console.WriteLine();
                        this.PrintScoreBoard();
                        this.Start();
                    }
                    else
                    {
                        Console.WriteLine(Grid.ToString());
                        this.Score++;
                        this.NextCommand();
                    }
                }

                break;
                }
            }
            catch (InvalidCellException)
            {
                Console.WriteLine("Illegal move!");
                this.NextCommand();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                this.NextCommand();
            }
        }
#pragma warning restore 649


    void Start()
    {
        AddNonTriggerColliderToBody();
        scoreBoard = FindObjectOfType <ScoreBoard>();
    }
Beispiel #52
0
 // Use this for initialization
 void Start()
 {
     xCenter    = transform.localPosition.x;
     yCenter    = (yMax + yMin) / 2;
     scoreBoard = FindObjectOfType <ScoreBoard>();
 }
Beispiel #53
0
 public bool IsNotValid()
 {
     return(string.IsNullOrEmpty(Map) || string.IsNullOrEmpty(GameMode) ||
            !FragLimit.HasValue || !TimeLimit.HasValue || !TimeElapsed.HasValue ||
            ScoreBoard.Any(sc => sc.IsNotValid()));
 }
 void Awake()
 {
     S = this;
 }
Beispiel #55
0
 // Use this for initialization
 void Start()
 {
     scoreBoard = GameObject.FindObjectOfType <ScoreBoard>();
     //LastChangeCounter = scoreBoard.GetChangeCounter();
 }
Beispiel #56
0
 private void Start()
 {
     AddNonTriggerBoxCollider();
     scoreBoard = FindObjectOfType <ScoreBoard>();
 }
 // Start is called before the first frame update
 void Start()
 {
     AddNonTriggerBoxCollider();
     scoreBoard = FindObjectOfType <ScoreBoard>();
     // TODO: How to instaniate our detroyed version when its needed? And should it generate its own Box Collider?
 }
Beispiel #58
0
 // Use this for initialization
 void Start()
 {
     scoreBoard = this;
 }
Beispiel #59
0
        public void TestEmptyScoreBoard()
        {
            ScoreBoard scores = new ScoreBoard();

            Assert.AreEqual("The score-board is empty.", scores.ToString());
        }
 ScoreBoard scoreBoard; //3amla zy GameObject obj  w b3d kda bt2ol en l obj da hwa el object ele mn no3 msln ele enta t7ddo
 // Start is called before the first frame update
 void Start()
 {
     AddNonTriggerBoxCollider();
     scoreBoard = FindObjectOfType <ScoreBoard>(); // Bt2olo dawrly 3la el object ele no3o ScoreBoard  , w hwa  Text !!
 }