Exemple #1
0
		internal override void Update(Creature creature, Map map) {
			// Look at it's own ore
			value = NeuralNet.sigmoid(creature.ore, 0, creature.property != null ? // Max sigmoid value = cost to improve a tile
														(creature.property.tileFoodImprovementNumerator + creature.property.tileOreImprovementNumerator) * 5 :
														10);	// If creature does not own a tile, default value is cost to improve a tile at level 1
			if(value == float.NaN) {
				throw new Exception();
			}
		}
Exemple #2
0
		internal override void Update(Creature creature, Map map) {
			// Get market price of ore
			float profit = 0;
			value = 0;
			foreach(Creature creatureResident in creature.currentTile.creatureResidentList) {
				profit = creature.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][5].value - creatureResident.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][5].value;
				if(profit > value) {
					value = profit;
				}
			}
			value = NeuralNet.sigmoid(value) - 500;
		}
Exemple #3
0
		internal override void Update(Creature creature, Map map) {
			value = float.MinValue;
			creature.fightVictim = null;
			// Consider creatures to loot
			foreach(Creature prey in creature.currentTile.creatureResidentList) {
				if(prey.food * creature.foodValueForLooting + prey.ore * creature.oreValueForLooting > value) {
					// How jucy the prey is
					value = prey.food * creature.foodValueForLooting + prey.ore * creature.oreValueForLooting;
					// Remember prey for later ;)
					creature.fightVictim = prey;
				}
			}
			if(value == float.MinValue) {
				value = 0;
			}
			// Bound between 0 and 1
			value = NeuralNet.sigmoid500singleEnded(value);
		}
Exemple #4
0
		internal override void Update(Creature creature, Map map) {
			// Get market price of food
			// Since we only ever buy, take the difference between selling and buying price
			float profit = 0;
			value = 0;
			foreach(Creature creatureResident in creature.currentTile.creatureResidentList) {
				profit = creature.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][4].value - creatureResident.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][4].value;
				if(profit > value) {
					value = profit;
				}
			}
			if(creature.Equals(map.selectedCreature) && value > 0) {
				Console.WriteLine("Profit: {0}", value);
			}
			value = NeuralNet.sigmoid(value) - 500;
			//value = creature.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][4].value;	// Default buy value is our own sell value
			//foreach(Creature creatureResident in creature.currentTile.creatureResidentList) {
			//	if(creatureResident.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][4].value < value) {
			//		value = creatureResident.mainNet.nodeList[creature.mainNet.nodeList.Count - 1][4].value;
			//	}
			//}
		}
Exemple #5
0
        public Creature(int posX, int posY, Creature creature = null)
        {
            bodySize     = bodySizeDefault;
            position.X   = posX;
            position.Y   = posY;
            moveTarget.X = posX;
            moveTarget.Y = posY;
            pen          = new Pen(Color.FromArgb(255, 0, 0, 0));

            // Set request
            request = Request.NONE;

            // Set activity
            activity = Activity.THINK;

            // Set skills
            if (creature != null)
            {
                this.farmSkill  = creature.farmSkill * 5 / 10;
                this.mineSkill  = creature.mineSkill * 5 / 10;
                this.fightSkill = creature.fightSkill * 5 / 10;
                if (fightSkill < 10)
                {
                    fightSkill = 10;
                }
            }
            else
            {
                this.farmSkill  = creatureAverageFarmSkill;
                this.mineSkill  = creatureAverageMiningSkill;
                this.fightSkill = 10;
            }

            // Set resources
            if (creature != null)
            {
                // Take resources from parent
                this.food      = creature.food / 2;
                creature.food /= 2;
                this.ore       = creature.ore / 2;
                creature.ore  /= 2;
            }
            else
            {
                // Set initial resources
                this.food = 100;
                this.ore  = 50;
            }

            // Set neural net
            if (creature != null)
            {
                mainNet = new MainNet(creature.mainNet);
                mainNet.Evolve();

                // Set preferences
                foodValueForLooting *= NeuralNet.logit((float)rand.NextDouble()) + 1;
                oreValueForLooting  *= NeuralNet.logit((float)rand.NextDouble()) + 1;
            }
            else
            {
                mainNet = new MainNet();
            }

            // Set appearance
            if (creature != null)
            {
                // Set colour
                bodyR = creature.bodyR;
                bodyG = creature.bodyG;
                bodyB = creature.bodyB;
                int  colourIndex  = rand.Next() % 6;
                byte colourOffset = Convert.ToByte(rand.Next() % 10);
                switch (colourIndex)
                {
                case 0:
                    bodyR += colourOffset;
                    break;

                case 1:
                    bodyR -= colourOffset;
                    break;

                case 2:
                    bodyG += colourOffset;
                    break;

                case 3:
                    bodyG -= colourOffset;
                    break;

                case 4:
                    bodyB += colourOffset;
                    break;

                case 5:
                    bodyB -= colourOffset;
                    break;
                }
            }
            else
            {
                bodyR = Convert.ToByte(rand.Next() % 256);
                bodyG = Convert.ToByte(rand.Next() % 256);
                bodyB = Convert.ToByte(rand.Next() % 256);
            }
            brush = new SolidBrush(Color.FromArgb(255, bodyR, bodyG, bodyB));
        }
Exemple #6
0
		internal override void Update(Creature creature, Map map) {
			// Look at it's own food
			value = NeuralNet.sigmoid100singleEnded(creature.food);
		}