public static MineSweeperSettings Sweeper() { var settings = new MineSweeperSettings { Ticks = 2000, SweeperCount = 30, MineCount = 40, ReplaceMine = true, DrawWidth = 640, DrawHeight = 520, Fast = false, MaxSpeed = 2, MaxRotation = 0.5, MutationRate = 0.1, CrossoverRate = 0.7, MaxPerturbation = 0.3, EliteCount = 4, HiddenLayers = 1, HiddenLayerNeurons = 6, SweeperType = SweeperType.Sweeper }; return(settings); }
public void Reset(MineSweeperSettings settings) { Width = settings.DrawWidth; Image = new Bitmap(Width, Height); _worstColor = settings.WorstColor; _bestColor = settings.BestColor; _neutralColor = settings.NeutralColor; }
private void mainFormSettingsChanged(object sender, MineSweeperSettings settings) { _settings = settings; _runner.DisableSimulation(); _setupNeeded = true; }
public void Reset(MineSweeperSettings settings) { _worstColor = settings.WorstColor; _bestColor = settings.BestColor; _neutralColor = settings.NeutralColor; setupLabels(); lblAvgValue.Text = "0"; lblWorstValue.Text = "0"; lblBestValue.Text = "0"; lblLastAvg.Text = "(0.00)"; lblLastWorst.Text = "(0)"; lblLastBest.Text = "(0)"; }
public void Update(IList<ICreature> creatures, IList<Tuple<ObjectType, IList<double>>> objects, MineSweeperSettings settings) { Image = new Bitmap(Width, Height); using (var graphics = Graphics.FromImage(Image)) { var eliteSweeperPen = new Pen(_bestColor); var sweeperPen = new Pen(_neutralColor); var minePen = new Pen(Color.DarkGray); var blackPen = new Pen(Color.Black); var redPen = new Pen(Color.Maroon); // Elite Sweepers foreach (var sweeper in creatures.OrderByDescending(x => x.Fitness).Take(settings.EliteCount)) { drawSweeper(graphics, eliteSweeperPen, eliteSweeperPen.Brush, sweeper, settings.SweeperSize); } // Normal Sweepers foreach (var sweeper in creatures.OrderByDescending(x => x.Fitness).Skip(settings.EliteCount)) { drawSweeper(graphics, sweeperPen, sweeperPen.Brush, sweeper, settings.SweeperSize); } // Mines var mines = objects.Where(x => x.Item1 == ObjectType.Mine).Select(x => x.Item2); foreach (var mine in mines) { drawMine(graphics, redPen, minePen.Brush, mine, settings.MineSize); } // ClusterMines var clusterMines = objects.Where(x => x.Item1 == ObjectType.ClusterMine).Select(x => x.Item2); foreach (var mine in clusterMines) { drawMine(graphics, blackPen, sweeperPen.Brush, mine, settings.MineSize + 1); } // Holes var holes = objects.Where(x => x.Item1 == ObjectType.Hole).Select(x => x.Item2); foreach (var hole in holes) { drawMine(graphics, redPen, redPen.Brush, hole, settings.MineSize + 1); } eliteSweeperPen.Dispose(); sweeperPen.Dispose(); minePen.Dispose(); blackPen.Dispose(); redPen.Dispose(); } }
public void DisplayCurrentSettings(MineSweeperSettings settings) { tbMaxSpeed.Text = settings.MaxSpeed.ToString(); tbMaxRotation.Text = settings.MaxRotation.ToString(); tbWidth.Text = settings.DrawWidth.ToString(); tbHeight.Text = settings.DrawHeight.ToString(); tbMutation.Text = settings.MutationRate.ToString(); tbCrossover.Text = settings.CrossoverRate.ToString(); tbPerturb.Text = settings.MaxPerturbation.ToString(); tbTicks.Text = settings.Ticks.ToString(); tbMine.Text = settings.MineCount.ToString(); tbSweepers.Text = settings.SweeperCount.ToString(); tbElites.Text = settings.EliteCount.ToString(); tbHiddenLayer.Text = settings.HiddenLayers.ToString(); tbHiddenNeuron.Text = settings.HiddenLayerNeurons.ToString(); this.ForeColor = settings.BestColor; }
public MineSweeperSettings GetNewSettings(MineSweeperSettings settings) { settings.SweeperCount = getIntValue(tbSweepers, settings.SweeperCount); settings.MineCount = getIntValue(tbMine, settings.MineCount); settings.MutationRate = getDoubleValue(tbMutation, settings.MutationRate); settings.CrossoverRate = getDoubleValue(tbCrossover, settings.CrossoverRate); settings.MaxPerturbation = getDoubleValue(tbPerturb, settings.MaxPerturbation); settings.Ticks = getIntValue(tbTicks, settings.Ticks); settings.EliteCount = getIntValue(tbElites, settings.EliteCount); settings.HiddenLayers = getIntValue(tbHiddenLayer, settings.HiddenLayers); settings.HiddenLayerNeurons = getIntValue(tbHiddenNeuron, settings.HiddenLayerNeurons); settings.DrawWidth = getIntValue(tbWidth, settings.DrawWidth); settings.DrawHeight = getIntValue(tbHeight, settings.DrawHeight); settings.MaxSpeed = getDoubleValue(tbMaxSpeed, settings.MaxSpeed); settings.MaxRotation = getDoubleValue(tbMaxRotation, settings.MaxRotation); return settings; }
public ClusterSweeperSpec(MineSweeperSettings settings) : base(settings) { Objects = new List<Tuple<ObjectType, IList<double>>>(); }
private void setupSpec(IMineSweeperSpec spec) { _setupNeeded = true; _spec = spec; _settings = _spec.Settings; _spec.NextGenerationEnded += specNextGeneration; _spec.TickEnded += specTickEnded; }
public RecurrentSpec() : this(MineSweeperSettings.Sweeper()) { }
public RecurrentSpec(MineSweeperSettings settings) { Settings = settings; _mines = new List <IList <double> >(); }
public MineSweeperSpec(MineSweeperSettings Settings) : base(Settings) { _mines = new List <IList <double> >(); }
public MineSweeperSpec() : this(MineSweeperSettings.Sweeper()) { }
public EliteMineSweeperSpec() : this(MineSweeperSettings.EliteSweeper()) { }
public MineSweeperHoleDodgerSpec(MineSweeperSettings settings) : base(settings) { Objects = new List <Tuple <ObjectType, IList <double> > >(); }
public MineSweeperHoleDodgerSpec() : this(MineSweeperSettings.SweeperDodger()) { }
public RecurrentSpec(MineSweeperSettings settings) { Settings = settings; _mines = new List<IList<double>>(); }
public ClusterSweeperSpec() : this(MineSweeperSettings.ClusterSweeper()) { }
public SweeperSpecBase(MineSweeperSettings settings) { Settings = settings; }
public static MineSweeperSettings SweeperDodger() { var settings = new MineSweeperSettings { Ticks = 2000, SweeperCount = 20, MineCount = 40, ReplaceMine = true, DrawWidth = 640, DrawHeight = 520, Fast = false, MaxSpeed = 1, MaxRotation = 0.5, MutationRate = 0.1, CrossoverRate = 0.7, MaxPerturbation = 0.3, EliteCount = 4, HiddenLayers = 1, HiddenLayerNeurons = 8, SweeperType = SweeperType.SweeperDodger }; return settings; }
public EliteMineSweeperSpec(MineSweeperSettings Settings) : base(Settings) { _mines = new List<IList<double>>(); }