コード例 #1
0
        public void CalculateFitnessTest(string input, int expeceted)
        {
            var matrix    = input.StringToByteMatrix(4);
            var weights   = new TsitsiklisWeights(1, 3);
            var algorithm = new Tsitsiklis(weights);

            Assert.AreEqual(expeceted, algorithm.CalculateFitness(matrix, null, 0, 0));
        }
コード例 #2
0
        public void GetBestMoveTest(string input, Color color1, Color color2, int expeceted)
        {
            var matrix    = input.StringToByteMatrix(10);
            var weights   = new TsitsiklisWeights(1, 3);
            var algorithm = new Tsitsiklis(weights);
            var manager   = new BoardManager(matrix);

            manager.SpawnPill(color1, color2);
            var engine   = new AiEngine(algorithm);
            var bestMove = engine.GetNextMove(manager);

            Assert.AreEqual(expeceted, bestMove.Fitness);
        }
コード例 #3
0
        public void GetBestMoveTest(string input, BlockType newBlockType, int expeceted)
        {
            var boolMatrix = input.StringToBoolMatrix(10);
            var weights    = new TsitsiklisWeights(1, 3);
            var algorithm  = new Tsitsiklis(weights);
            var manager    = new BoardManager(boolMatrix);

            manager.SpawnBlock(newBlockType);
            var engine   = new Engine(algorithm);
            var bestMove = engine.GetNextMove(manager);

            Assert.AreEqual(expeceted, bestMove.Fitness);
        }
コード例 #4
0
        public void MovesAreCorrect(string input, BlockType newBlockType, Move[] expeceted)
        {
            var boolMatrix = input.StringToBoolMatrix(8);
            var weights    = new TsitsiklisWeights(1, 3);
            var algorithm  = new Tsitsiklis(weights);
            var manager    = new BoardManager(boolMatrix);

            manager.SpawnBlock(newBlockType);
            var engine = new Engine(algorithm);

            var bestMove = engine.GetNextMove(manager);
            var moves    = bestMove.Moves;

            Assert.IsTrue(bestMove.IsValid);
            Assert.That(bestMove.Fitness, Is.AtMost(1), "Fitness");

            Assert.AreEqual(expeceted.Where(x => x == Move.Right).Count(), moves.Where(x => x == Move.Right).Count());
            Assert.AreEqual(expeceted.Where(x => x == Move.Left).Count(), moves.Where(x => x == Move.Left).Count());
            Assert.AreEqual(expeceted.Where(x => x == Move.RotateLeft).Count(), moves.Where(x => x == Move.RotateLeft).Count());
            Assert.AreEqual(expeceted.Where(x => x == Move.RotateRight).Count(), moves.Where(x => x == Move.RotateRight).Count());
        }
コード例 #5
0
 //////////////////////////////////////////////////////////////////////////
 public Tsitsiklis(TsitsiklisWeights tsitsiklisWeights)
 {
     m_Height = tsitsiklisWeights.Height;
     m_Holes  = tsitsiklisWeights.Holes;
 }
コード例 #6
0
 public Tsitsiklis(TsitsiklisWeights tsitsiklisWeights)
 {
     this.height = tsitsiklisWeights.Height;
     this.holes  = tsitsiklisWeights.Holes;
 }