// constructor for Encog public WindowLessTraining(int mazeId, int totalIterations, int maxTemp, int minTemp, int encogCycles) { InitializeComponent(); mazerepo = new MazeRepo(); maze = mazerepo.GetByID(mazeId); MazeId = mazeId; TotalIterations = totalIterations; this.maxTemp = maxTemp; this.minTemp = minTemp; this.encogCycles = encogCycles; isEncog = true; lbl1.Content = "# of Iterations:"; lbl2.Content = "Iterations done:"; lbl3.Content = "# of Cycles per:"; lbl4.Content = "Cycles done:"; lbl5.Visibility = Visibility.Hidden; lblMazeName.Content = maze.Name; lblSessionCount.Content = totalIterations.ToString(); lblCurrentSession.Content = 0; lblMoveCount.Content = encogCycles.ToString(); lblSessionsCompleted.Content = 0; lblRandomness.Visibility = Visibility.Hidden; this.Title = "No Maze Encog Learning"; }
private void btnSaveMaze_Click(object sender, RoutedEventArgs e) { var repo = new MazeRepo(); // check name for duplicate if (repo.HasDuplicate(txtBoxMazeName.Text) && !editMode) { MessageBox.Show($"'{txtBoxMazeName.Text}' maze name already exist.", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } else if (String.IsNullOrWhiteSpace(txtBoxMazeName.Text)) { MessageBox.Show("Please provide a name for the maze."); return; } var maze = new MazeInfo() { Name = txtBoxMazeName.Text, StartingPosition = generator.StartingPosition, GoalPosition = generator.GoalLocation, PerfectGameMovesCount = generator.PerfectGameMovesCount, Grid = generator.TheMazeGrid, Width = width, Height = height }; if (editMode) { repo.UpdateMaze(MazeId, maze); } else { repo.CreateMaze(maze); } //var newMaze = repo.CreateMaze(maze); MessageBox.Show("Maze successfully saved!"); this.Close(); //try get by id //var mazefromdb = repo.GetByID(newMaze.ID); // try to update maze //newMaze.PerfectScore = 100; //repo.UpdateMaze(newMaze.ID, newMaze); // try to get ID Name dic //var result = repo.GetIDNameDictionary(); }
public StartGameWindow() { InitializeComponent(); this.Closed += StartGameWindow_Closed; // create Mazes database if not exists yet mazeRepo = new MazeRepo(); mazeRepo.CreateDBSchemaIfNotExist(); mazes = mazeRepo.GetIDNameDictionary(); ControlButtonVisible(); errorCount = 0; }
public MazeCreator(int mazeId = -1) { InitializeComponent(); var repo = new MazeRepo(); if (mazeId != -1) //we are editing the maze { generated = false; MazeId = mazeId; editMode = true; ResetGrid(); var mazeToEdit = repo.GetByID(mazeId); width = mazeToEdit.Width; height = mazeToEdit.Height; generator.GoalLocation = mazeToEdit.GoalPosition; generator.StartingPosition = mazeToEdit.StartingPosition; generator.TheMazeGrid = mazeToEdit.Grid; generator.PerfectGameMovesCount = mazeToEdit.PerfectGameMovesCount; mazeName = mazeToEdit.Name; txtBoxHeight.Text = height.ToString(); txtBoxWidth.Text = width.ToString(); txtBoxMazeName.Text = mazeToEdit.Name; lblMoveCount.Content = $"Perfect Move Count: {mazeToEdit.PerfectGameMovesCount}"; this.Title = $"Maze Designer Editing {mazeToEdit.Name}"; initializeGrid(mazeGrid, width, height); generateMaze(mazeGrid); } else { editMode = false; ResetGrid(); //initialize the grid with all the blocks initializeGrid(mazeGrid, width, height); //build the maze generator.Generate(width, height); //Generate the maze in the UI generateMaze(mazeGrid); int mazeCount = repo.Count(); txtBoxMazeName.Text = $"New Maze({mazeCount + 1})"; generated = true; } }
// constructor for RNN public WindowLessTraining(int mazeId, Boolean learn, int totalIterations, int temp_num_sessions, int startRandomness = 1, int endRandomness = 1) { InitializeComponent(); mazerepo = new MazeRepo(); maze = mazerepo.GetByID(mazeId); MazeId = mazeId; Learn = learn; TotalIterations = totalIterations; Temp_num_sessions = temp_num_sessions; StartRandomness = startRandomness; EndRandomness = endRandomness; isEncog = false; lblMazeName.Content = maze.Name; lblCurrentSession.Content = 1; lblSessionCount.Content = totalIterations.ToString(); lblMoveCount.Content = 0; this.Title = "No Maze RNN Learning"; }
public MainWindow(int mazeId, PlayerType type, Boolean learn = false, int temp_num_sessions = 1, int currentIteration = 1, int totalIterations = 1, int startRandomness = 1, int endRandomness = 1) { InitializeComponent(); mazerepo = new MazeRepo(); mazeInfo = mazerepo.GetByID(mazeId); RandomnessOver = temp_num_sessions; ClosedDueToGameOver = false; Learn = learn; Type = type; if (Type == PlayerType.Human) { this.Title = "Human Player"; StatusText.Visibility = Visibility.Visible; } else if (Type == PlayerType.RNN) { if (learn) { Temp_num_sessions = totalIterations; StartRandomness = startRandomness; EndRandomness = endRandomness; this.Title = "RNN Learning"; statGrid.Visibility = Visibility.Visible; lblMazeName.Content = mazeInfo.Name; lblTotalSession.Content = totalIterations; lblCurrentSession.Content = CurrentIteration = currentIteration; lblScore.Content = LastScore; lblMoves.Content = LastMovesCount; } else { this.Title = "RNN Player"; } } else { this.Title = "Encog Player"; } game = new MazeGameLib.MazeGame(); maze = new Maze(); game.InitGame(mazeInfo); //Initialize Grid game.TheMazeGrid = mazeInfo.Grid; maze.InitializeMaze(game, mazeGrid); //Init Game //game.InitGame(this.MainGrid, new RunThreadUI_Delegate(RunUIThread)); //Send Keys to Game if (Type == PlayerType.Human) { this.KeyDown += MainWindow_KeyDown; } // reset static session count if (currentIteration == 1) { //RNNMazeTraveler.ResestStaticSessionData(); } //Send shutdown event to game //this.Closed += MainWindow_Closed; }