Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.