private double GetCurrentPositionScore(Pod creaturepod) { TransformedPodBrain pb = new TransformedPodBrain(); pb.SetConditions(creaturepod, _raceInfo, new[] { 2.342, 30.91, 0.02181 }); int finnisch = (_pod.NextCheckPointId + 2) % _raceInfo.CheckpointCount; double score = 0; while (creaturepod.NextCheckPointId != finnisch && score < 100) { pb.GetAction(); //creaturepod.SetAction(v, 100, false, false); creaturepod.Rotate(); creaturepod.Thrust(); creaturepod.Move(); if ((_raceInfo.Checkpoints[creaturepod.NextCheckPointId].Position - creaturepod.Position).Size < 600) { creaturepod.NextCheckPointId = (creaturepod.NextCheckPointId + 1) % _raceInfo.CheckpointCount; } score++; } return(score); }
public void CaluculateScore(Creature creature) { Pod creaturepod = _pod.Clone(); for (int i = 0; i < GenomeSize / 3; i++) // move the pod x steps { double turnGen = creature.Genome[i * 3]; double trustGen = creature.Genome[i * 3 + 1]; double shieldGen = creature.Genome[i * 3 + 2]; Vector v = Vector.CreateVectorAngleSizeRad(creaturepod.AngleRad + (turnGen - 0.5) * Math.PI / 5.0, 1000); v += creaturepod.Position; int thrust = (int)(trustGen * 150) - 20; thrust = (thrust > 100) ? 100 : (thrust < 0) ? 0 : thrust; creaturepod.SetAction(v, thrust, false, false); creaturepod.Rotate(); creaturepod.Thrust(); // bounces here creaturepod.Move(); if ((_raceInfo.Checkpoints[creaturepod.NextCheckPointId].Position - creaturepod.Position).Size < 500) { creaturepod.NextCheckPointId = (creaturepod.NextCheckPointId + 1) % _raceInfo.CheckpointCount; } } // calculate the score of that position creature.Score = GetCurrentPositionScore(creaturepod); }
public int?Move() { // iedere pod bepaalt zijn actie foreach (IPodBrain podbrain in _podBrains) { podbrain.GetAction(); } // draai en stel throttle in foreach (Pod pod in _pods) { pod.Rotate(); pod.Thrust(); } // bereken de botsingen List <Collision> collisions = new List <Collision>(); for (int i = 0; i < _pods.Length - 1; i++) { for (int j = i + 1; j < _pods.Length; j++) { Collision collision = GameUnit.GetCollisionData(_pods[i], _pods[j]); if (collision != null) { collisions.Add(collision); } } } foreach (Collision c in collisions) { c.Bounce(); } // plaats pods op nieuwe locaties for (int i = 0; i < _pods.Length; i++) { Pod pod = _pods[i]; pod.Move(); // bepaal of pod checkpoint heeft bereikt if ((_raceInfo.Checkpoints[pod.NextCheckPointId].Position - pod.Position).Size < 600) { pod.NextCheckPointId = (pod.NextCheckPointId + 1) % _raceInfo.CheckpointCount; if (pod.Lap > _raceInfo.LapCount) { return(i); } } } return(null); }