public void UnbuildableTest()
        {
            var set = new SetVariables(list, 10, 10, new SetVariables.Point(5, 5), new SetVariables.Point(0, 0));

            set.Unbuildable(4, 4);

            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    if (i == 4 && j == 4)
                    {
                        Assert.AreEqual(-1, set.Domain(0).IndexOf(i * 10 + j));
                    }
                    else
                    {
                        Assert.AreNotEqual(-1, set.Domain(0).IndexOf(i * 10 + j));
                    }
                }
            }

            var listPoint = new List <SetVariables.Point> {
                new SetVariables.Point(3, 9), new SetVariables.Point(8, 7), new SetVariables.Point(1, 1)
            };

            set.Unbuildable(listPoint);
            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    if ((i == 4 && j == 4)
                        ||
                        (i == 3 && j == 9)
                        ||
                        (i == 8 && j == 7)
                        ||
                        (i == 1 && j == 1))
                    {
                        Assert.AreEqual(-1, set.Domain(0).IndexOf(i * 10 + j));
                    }
                    else
                    {
                        Assert.AreNotEqual(-1, set.Domain(0).IndexOf(i * 10 + j));
                    }
                }
            }
#if DEBUG
            set.Print();
#endif
        }
Beispiel #2
0
        public void SimulateCostBaseTest()
        {
            setBuildings.SetValue(0, -1);
            setBuildings.SetValue(1, 0);
            setBuildings.SetValue(2, 8);
#if DEBUG
            setBuildings.Print();
#endif
            var varSimCost = new Dictionary <int, double[]>();
            for (int i = 0; i < setBuildings.Domain(1).MaxValue() + 1; ++i)
            {
                varSimCost[i] = new double[setBuildings.GetNumberVariables()];
                for (var j = 0; j < setBuildings.GetNumberVariables(); ++j)
                {
                    varSimCost[i][j] = -1;
                }
            }

            var noHoles  = new WallShape(setBuildings);
            var vecCosts = noHoles.SimulateCost(1, varSimCost);

            foreach (var tuple in vecCosts)
            {
                if (tuple.Key == 0 || tuple.Key == 7 || tuple.Key == 8 || tuple.Key == 12 || tuple.Key == 13)
                {
                    Assert.AreEqual(2.0, tuple.Value);
                }
                else if (tuple.Key == 1 || tuple.Key == 6 || tuple.Key == 11 || tuple.Key == 16 || tuple.Key == 17 || tuple.Key == 18)
                {
                    Assert.AreEqual(0.0, tuple.Value);
                }
                else
                {
                    Assert.AreEqual(4.0, tuple.Value);
                }
            }
        }
        public void UnbuildableTest()
        {
            var set = new SetVariables( list, 10, 10, new SetVariables.Point( 5, 5 ), new SetVariables.Point( 0, 0 ) );
              set.Unbuildable( 4, 4 );

              for( int i = 0 ; i < 10 ; ++i )
            for( int j = 0 ; j < 10 ; ++j )
              if( i == 4 && j == 4 )
            Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.EqualTo( -1 ) );
              else
            Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.Not.EqualTo( -1 ) );

              var listPoint = new List<SetVariables.Point> { new SetVariables.Point( 3, 9 ), new SetVariables.Point( 8, 7 ), new SetVariables.Point( 1, 1 )};
              set.Unbuildable( listPoint );
              for( int i = 0 ; i < 10 ; ++i )
            for( int j = 0 ; j < 10 ; ++j )
              if( ( i == 4 && j == 4 )
             ||
             ( i == 3 && j == 9 )
             ||
             ( i == 8 && j == 7 )
             ||
             ( i == 1 && j == 1 ) )
            Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.EqualTo( -1 ) );
              else
            Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.Not.EqualTo( -1 ) );
            #if DEBUG
              set.Print();
            #endif
        }