static async Task Main(string[] args) { Console.Title = ".NET Marion Kart Bot"; Console.WriteLine("Waiting for 5 sec in order to prepare the game window!"); await Task.Delay(5000); ///*** generate training data *** /// simple play Mario game while the application is running /// the app will automatically collect training data /// N64 emulator must be in top left corner with 800x640 resolution /// In case N64 emulator is not running no data is generating //uncomment this line to generate training data await GenerateData.Start(); //***teach Mario to drive Kart by train LSTM RNN model*** //uncomment this line to train Mario usually do that on GPU //run this line in case you have GPU compatible graphic card //CNTKDeepNN.Train(DeviceDescriptor.GPUDevice(0)); //run this in case you dont have GPU //CNTKDeepNN.Train(DeviceDescriptor.CPUDevice); //*****play a game**** //uncomment those three lines to play game with RNN model //var dev = DeviceDescriptor.CPUDevice; //MarioKartPlay.LoadModel("../../../../training/mario_kart_modelv1", dev); //MarioKartPlay.PlayGame(dev); }
public static void PlayGame(DeviceDescriptor device) { ////test for image show //var wnd = new ImgWnd(); ////show image dialog from different thread //Task mytask = Task.Run(() => { wnd.ShowDialog(); }); Task.Delay(2000).Wait(); //wait for quit key while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) { //capture image at specific location and size var rec = new Rectangle() { X = GenerateData.m_ImageX, Y = GenerateData.m_ImageY, Width = GenerateData.m_ImageWidth, Height = GenerateData.m_ImageHeight }; var b = GenerateData.Capture(rec); //process Image //var b1 = GenerateData.ResizeAndGray(b, true); //wnd.LoadImage(b1); var retValue = GenerateData.ResizeAndCHWExctraction(b, true).ToArray(); Play(retValue, device); } }