Exemple #1
0
        private void OneTurn()
        {
            (int row, int col)pos1, pos2;
            Tile[] situation = new Tile[TileUtil.NUM_NEIGHBORS];

            RobbyWorld world = new RobbyWorld(10, 10, 0.5f);

            IList <Reaction> rules = world.GenerateRandomRules();

            StringBuilder sb = new StringBuilder();

            int ruleIndex;

            pos1 = world.RobbyPos;
            world.GetSituationAt(pos1, situation);
            ruleIndex = TileUtil.ToDecimal(situation);

            sb.AppendFormat(
                "Robby's position: ({0},{1})\n", pos1.row, pos1.col);
            sb.AppendFormat(
                "Robby's situation: {0} [ {1} ]\n",
                ruleIndex, TileUtil.ToString(situation));
            sb.AppendFormat(
                "Robby's action to take for situation {0}: {1}\n",
                ruleIndex, rules[ruleIndex]);
            sb.AppendFormat("Robby's original score: {0}", world.Score);

            sb.AppendLine("\nActing up...");
            world.NextTurn(rules);

            pos2 = world.RobbyPos;

            sb.AppendFormat(
                "Robby's new position: ({0},{1})\n", pos2.row, pos2.col);
            sb.AppendFormat(
                "Situation in original position: {0}\n",
                world[pos1.row, pos1.col]);
            sb.AppendFormat("Robby's new score: {0}", world.Score);

            Debug.Log(sb.ToString());
        }