// threaded implementation sot hat I can test my draw routine public void PlayThread() { prog = new IntCode.ParallelCodeRunner(); threadThis.Instance = this; threadThis.RunInThread(); prog.Code = code; prog.ExternalOutput = gameOutput; prog.RunInThread(); }
public void PlayUnlimited() { prog = new IntCode.ParallelCodeRunner(); //start listener thread threadThis.Instance = this; threadThis.RunInThread(); // set the program to play infinitely char[] array = code.ToCharArray(); array[0] = '2'; code = new string(array); //prog.InitRAM(0, 2); prog.Code = code; prog.ExternalOutput = gameOutput; // start code prog.RunInThread(); }
public void Play() { prog = new IntCode.ParallelCodeRunner(); prog.Code = code; prog.ExternalOutput = prog.ExternalInput; // run it to completion, then look at the output prog.Run(); if (prog.ExternalInput.Count % 3 != 0) { MessageBox.Show("Not a multiple of 3: " + prog.ExternalInput.Count.ToString()); Debugger.Break(); } int totalCmds = prog.ExternalInput.Count / 3; int initCnt = prog.ExternalInput.Count; for (int i = 0; i < initCnt && prog.ExternalInput.Count > 0; i += 3) { string xStr = prog.ExternalInput.Take(); string yStr = prog.ExternalInput.Take(); string tileStr = prog.ExternalInput.Take(); int x, y, tile; bool ok = false; ok = Int32.TryParse(xStr, out x); if (!ok) { Debugger.Break(); } ok = Int32.TryParse(yStr, out y); if (!ok) { Debugger.Break(); } ok = Int32.TryParse(tileStr, out tile); if (!ok) { Debugger.Break(); } if (x == -1 && y == 0) { // score not location score = (ulong)tile; } else { Location l = new Location(x, y); board[l] = (GamePiece)tile; } } // everything is put on the board }