Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Last active November 4, 2019 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/eb88c04262e15e2425efb390b6c96120 to your computer and use it in GitHub Desktop.
Save IntegerMan/eb88c04262e15e2425efb390b6c96120 to your computer and use it in GitHub Desktop.
namespace MattEland.FSharpGeneticAlgorithm.WindowsClient.ViewModels
{
internal class MainViewModel : NotifyPropertyChangedBase
{
public MainViewModel()
{
RandomizeCommand = new ActionCommand(RandomizeBrain);
BrainCommand = new ActionCommand(GetArtificialIntelligenceMove);
ResetCommand = new ActionCommand(Reset);
RandomizeBrain();
Reset();
}
public ActionCommand RandomizeCommand { get; }
public ActionCommand ResetCommand { get; }
public ActionCommand BrainCommand { get; }
private void RandomizeBrain() =>
Brain = new BrainInfoViewModel(Genes.getRandomChromosome(_random));
private void GetArtificialIntelligenceMove() =>
State = Simulator.handleChromosomeMove(_state, _random, Brain.Model);
private BrainInfoViewModel _brain;
public BrainInfoViewModel Brain
{
get => _brain;
set {
if (_brain != value)
{
_brain = value;
OnPropertyChanged();
}
}
}
// Old code omitted for simplicity
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment