コード例 #1
0
        public void SellsBuildings_ByPreference()
        {
            var geneticCode = new GeneticCode();

            _player = new Player(geneticCode);

            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.FleetStreet, 0.1f);
            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.TrafalgarSquare, 0.2f);
            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.TheStrand, 0.3f);

            _player.SetCashTotal(5000);

            _player.PurchaseAsset(_assetManager.FleetStreet);
            _player.PurchaseAsset(_assetManager.TheStrand);
            _player.PurchaseAsset(_assetManager.TrafalgarSquare);

            _player.PurchaseBuilding(_assetManager.FleetStreet);
            _player.PurchaseBuilding(_assetManager.TheStrand);
            _player.PurchaseBuilding(_assetManager.TrafalgarSquare);
            _player.PurchaseBuilding(_assetManager.FleetStreet);
            _player.PurchaseBuilding(_assetManager.TheStrand);
            _player.PurchaseBuilding(_assetManager.TrafalgarSquare);

            // need to sell all but one house

            _player.SetCashTotal(0);
            _player.Pay(75 * 5, _bank, _bank);

            Assert.AreEqual(1, _assetManager.TheStrand.BuildingCount);
            Assert.AreEqual(0, _assetManager.FleetStreet.BuildingCount);
            Assert.AreEqual(0, _assetManager.TrafalgarSquare.BuildingCount);
        }
コード例 #2
0
        public void UnmortgageProperties_ByPreference()
        {
            var geneticCode = new GeneticCode();

            _player = new Player(geneticCode);

            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.FleetStreet, 0.1f);
            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.TrafalgarSquare, 0.2f);
            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.TheStrand, 0.3f);

            _player.PurchaseAsset(_assetManager.FleetStreet);
            _player.PurchaseAsset(_assetManager.TheStrand);
            _player.PurchaseAsset(_assetManager.TrafalgarSquare);

            // mortgage the properties
            _player.SetCashTotal(0);
            _player.Pay(250, _bank, _bank);

            // enough to unmortgage one
            _player.SetCashTotal(160);

            _player.ConsiderUnmortgaging();

            Assert.IsFalse(_assetManager.TheStrand.Mortgaged);
            Assert.IsTrue(_assetManager.FleetStreet.Mortgaged);
            Assert.IsTrue(_assetManager.TrafalgarSquare.Mortgaged);
        }
コード例 #3
0
        public void ConsiderPurchase_ByPreference()
        {
            var geneticCode = new GeneticCode();

            _player = new Player(geneticCode);

            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.FleetStreet, 0.2f);
            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.TrafalgarSquare, 0.2f);
            geneticCode.SetGeneExpression(GeneType.PropertyValue, _assetManager.TheStrand, 0.9f);

            _player.SetCashTotal(300);
            _player.ConsiderPurchase(_assetManager.TrafalgarSquare);
            _player.SetCashTotal(300);
            _player.ConsiderPurchase(_assetManager.FleetStreet);
            _player.SetCashTotal(300);
            _player.ConsiderPurchase(_assetManager.TheStrand);

            Assert.AreEqual(_player, _assetManager.TheStrand.Owner);
            Assert.AreEqual(_bank, _assetManager.FleetStreet.Owner);
            Assert.AreEqual(_bank, _assetManager.TrafalgarSquare.Owner);
        }
コード例 #4
0
        public void ConsiderBuilding_ByPreference()
        {
            var geneticCode = new GeneticCode();

            _player = new Player(geneticCode);

            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.FleetStreet, 0.1f);
            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.TrafalgarSquare, 0.2f);
            geneticCode.SetGeneExpression(GeneType.ImprovementValue, _assetManager.TheStrand, 0.3f);

            _player.PurchaseAsset(_assetManager.FleetStreet);
            _player.PurchaseAsset(_assetManager.TheStrand);
            _player.PurchaseAsset(_assetManager.TrafalgarSquare);

            // enough for 1 house
            _player.SetCashTotal(200);

            _player.ConsiderBuilding();

            Assert.AreEqual(1, _assetManager.TheStrand.BuildingCount);
            Assert.AreEqual(0, _assetManager.FleetStreet.BuildingCount);
            Assert.AreEqual(0, _assetManager.TrafalgarSquare.BuildingCount);
        }
コード例 #5
0
        public void Cross_SwapsGenes()
        {
            var geneticCode1 = new GeneticCode(10);
            var geneticCode2 = new GeneticCode(14);

            geneticCode1.SetGeneExpression(GeneType.Mortgage, AssetReference.BondStreet, 0.2f);
            geneticCode2.SetGeneExpression(GeneType.Mortgage, AssetReference.RegentStreet, 0.8f);
            geneticCode1.SetGeneExpression(GeneType.Mortgage, AssetReference.OldKentRoad, 0.7f);
            geneticCode2.SetGeneExpression(GeneType.Mortgage, AssetReference.OldKentRoad, 0.3f);
            geneticCode1.SetGeneExpression(GeneType.Mortgage, AssetReference.Whitehall, 0.1f);
            geneticCode2.SetGeneExpression(GeneType.Mortgage, AssetReference.Whitehall, 0.3f);
            geneticCode1.SetGeneExpression(GeneType.Mortgage, AssetReference.Mayfair, 0.4f);
            geneticCode2.SetGeneExpression(GeneType.Mortgage, AssetReference.Mayfair, 0.4f);

            var offspring = geneticCode1.Cross(geneticCode2, false);

            Assert.AreEqual(15, offspring.Generation);
            Assert.IsTrue(0.7f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.OldKentRoad) || 0.3f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.OldKentRoad));
            Assert.IsTrue(0.1f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.Whitehall) || 0.3f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.Whitehall));
            Assert.IsTrue(0.4f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.Mayfair));
            Assert.IsTrue(0.2f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.BondStreet));
            Assert.IsTrue(0.8f == offspring.GetGeneExpression(GeneType.Mortgage, AssetReference.RegentStreet));
        }