public override void Calc() { computer com = new computer(); com.inputProgram = input; com.Init(); com.Calc(); /* * while (com.outputs.Count>0) * { * com.outputs.Dequeue(); * //Console.Write((char)(int)(com.outputs.Dequeue())); * } */ string prog = "NOT T T\nAND A T\nAND B T\nAND C T\nNOT T J\nAND D J\nWALK\n"; foreach (var c in prog) { com.inputs.Enqueue(c); } com.Calc(); while (com.outputs.Count > 0) { output = com.outputs.Dequeue() + ""; // Console.WriteLine((com.outputs.Dequeue())); } }
public override void Calc() { computer com = new computer(); long count = 0; int cx = 50; int cy = 0; bool down = true; bool search = true; while (true) { com.inputProgram = input; com.Init(); com.inputs.Enqueue(cx); com.inputs.Enqueue(cy); com.Calc(); var r = com.outputs.Dequeue(); if (r == 0) { down = true; } else { down = false; com.inputProgram = input; com.Init(); com.inputs.Enqueue(cx - 99); com.inputs.Enqueue(cy + 99); com.Calc(); var r2 = com.outputs.Dequeue(); if (r2 == 1) { output = ((cx - 99) * 10000 + cy) + ""; break; } } if (down) { cy++; } else { cx++; } } }
public override void Calc() { computer com = new computer(); com.inputProgram = input; com.Init(); com.Calc(); string scr = ""; while (com.outputs.Count > 0) { scr += getAscii(com.outputs.Dequeue() + ""); } // Console.WriteLine(scr); var r = scr.Split('\n'); int sum = 0; for (int i = 1; i < r.Length - 3; i++) { // Console.WriteLine(r[i] + r[i].Length); if (r[i].Length >= 2) { for (int j = 1; j < r[i].Length - 1; j++) { if (r[i][j] == '#' && r[i + 1][j] == '#' && r[i - 1][j] == '#' && r[i][j + 1] == '#' && r[i][j - 1] == '#') { sum += i * j; } } } } output = sum + ""; }
public override void Calc() { computer com = new computer(); com.inputProgram = input; com.Init(); com.Calc(); int count = 0; while (com.outputs.Count > 0) { com.outputs.Dequeue(); com.outputs.Dequeue(); var a = com.outputs.Dequeue(); if (a == 2) { count++; } } output = count + ""; }
public override void Calc() { for (int i = 0; i < 50; i++) { computer com = new computer(); // com.toLog = true; com.inputProgram = input; com.Init(); com.inputs.Enqueue(i); // com.inputs.Enqueue(-1); com.Calc(); coms.Add(com); } while (true) { for (int i = 0; i < 50; i++) { var com = coms[i]; if (com.inputs.Count == 0) { com.inputs.Enqueue(-1); } com.Calc(); while (com.outputs.Count > 0) { var addr = com.outputs.Dequeue(); var X = com.outputs.Dequeue(); var Y = com.outputs.Dequeue(); if (addr == 255) { output = Y + ""; break; } else { coms[(int)addr].inputs.Enqueue(X); coms[(int)addr].inputs.Enqueue(Y); } } if (output != "") { break; } } if (output != "") { break; } } }
void OrganiseInv(List <string> items) { QueueCom("inv"); com.outputs.Clear(); com.Calc(); var itemString = getRes(); var eq = getItems(itemString); string cmd = ""; foreach (var item in items) { if (!eq.Contains(item)) { cmd += "take " + item; cmd += (char)(10); } } foreach (var item in eq) { if (!items.Contains(item)) { cmd += "drop " + item; cmd += (char)(10); } } QueueCom(cmd); com.Calc(); com.outputs.Clear(); }
public override void Calc() { //Console.WriteLine("1125899906842624"); //Console.WriteLine(long.MaxValue); computer com = new computer(); com.inputProgram = input; com.Init(); com.Calc(); output = com.output + ""; }
public override void Calc() { computer com = new computer(); com.inputProgram = input; // com.inputs.Enqueue(0); com.Init(); while (!com.done) { if (whites.Contains(new PointS(pos.X, pos.Y))) { com.inputs.Enqueue(1); } else { com.inputs.Enqueue(0); } com.Calc(); if (com.outputs.Dequeue() == 1) { whites.Add(new PointS(pos.X, pos.Y)); } else { whites.Remove(new PointS(pos.X, pos.Y)); } if (!countColor.Contains(new PointS(pos.X, pos.Y))) { countColor.Add((new PointS(pos.X, pos.Y))); } if (com.outputs.Dequeue() == 1) { currentDir = TurnFrom(currentDir, direction.right); } else { currentDir = TurnFrom(currentDir, direction.left); } move(currentDir); } output = countColor.Count + ""; }
void TryCombo(string ord) { int res = 0; var order = Tools.StringToIntArray(ord); Console.WriteLine(Tools.ArrayToString(order)); for (int i = 0; i < 5; i++) { computer c = new computer(); c.inputProgram = input; c.inputs.Enqueue(order[i]); c.inputs.Enqueue(res); c.Calc(); res = c.output; } output2 = Math.Max(output2, res); }
public override void Calc() { computer com = new computer(); long count = 0; for (int i = 0; i <= 49; i++) { for (int j = 0; j <= 49; j++) { com.inputProgram = input; com.Init(); com.inputs.Enqueue(i); com.inputs.Enqueue(j); com.Calc(); // Console.Write(com.outputs.Dequeue()); count += com.outputs.Dequeue(); } //Console.WriteLine(); } output = count + ""; }
public override void Calc() { screen = new char[h][]; for (int i = 0; i < h; i++) { screen[i] = new char[w]; for (int j = 0; j < w; j++) { screen[i][j] = ' '; } } spaces.Add(new point(0, 0)); // special.Add(new point(0, 0)); computer com = new computer(); com.inputProgram = input; // com.toLog = true; com.Init(); Random rng = new Random(); while (true) { com.Calc(); var dirn = 0; // Console.ReadLine(); var ch = findDir(); dirn = ch; bool isBack = false; if (dirn >= 1 && dirn <= 4) { com.inputs.Enqueue(dirn); com.Calc(); isBack = false; } else { if (moves.Count == 0) { break; } dirn = anti(moves.Pop()); com.inputs.Enqueue(dirn); com.Calc(); isBack = true; } if (com.outputs.Count > 0) { var o = com.outputs.Dequeue(); if (o == 0)//wall { switch (dirn) { case 1: walls.Add(new point(pos.x, pos.y + 1)); break; case 2: walls.Add(new point(pos.x, pos.y - 1)); break; case 3: walls.Add(new point(pos.x - 1, pos.y)); break; case 4: walls.Add(new point(pos.x + 1, pos.y)); break; } } else if (o == 1) //empty { switch (dirn) { case 1: spaces.Add(new point(pos.x, pos.y + 1)); pos.y++; break; case 2: spaces.Add(new point(pos.x, pos.y - 1)); pos.y--; break; case 3: spaces.Add(new point(pos.x - 1, pos.y)); pos.x--; break; case 4: spaces.Add(new point(pos.x + 1, pos.y)); pos.x++; break; } if (!isBack) { moves.Push(dirn); } } else if (o == 2)//found { switch (dirn) { case 1: special.Add(new point(pos.x, pos.y + 1)); pos.y++; break; case 2: special.Add(new point(pos.x, pos.y - 1)); pos.y--; break; case 3: special.Add(new point(pos.x - 1, pos.y)); pos.x--; break; case 4: special.Add(new point(pos.x + 1, pos.y)); pos.x++; break; } if (!isBack) { moves.Push(dirn); } } } /* clear(); * setScreen(); * Console.Clear(); * writeScreen();*/ //Thread.Sleep(50); } // clear(); setScreen(); // Console.Clear(); // writeScreen(); oxygen.Add(special[0]); while (special.Contains(oxygen[0])) { special.Remove(special[0]); } int ox = w / 2 - pos.x; int oy = h / 2 - pos.y; int timer = 0; while (true) { List <point> more = new List <point>(); foreach (var o in oxygen) { if (screen[o.y + 1 + oy][o.x + ox] == '.') { more.Add(new point(o.x, o.y + 1)); } if (screen[o.y - 1 + oy][o.x + ox] == '.') { more.Add(new point(o.x, o.y - 1)); } if (screen[o.y + oy][o.x + 1 + ox] == '.') { more.Add(new point(o.x + 1, o.y)); } if (screen[o.y + oy][o.x - 1 + ox] == '.') { more.Add(new point(o.x - 1, o.y)); } } if (more.Count > 0) { foreach (var a in more) { oxygen.Add(a); } // clear(); setScreen(); //Console.Clear(); //writeScreen(); timer++; } else { output = timer + ""; break; } } /* clear(); * setScreen(); * Console.Clear(); * writeScreen(); */ }
public override void Calc() { for (int i = 0; i < 50; i++) { computer com = new computer(); // com.toLog = true; com.inputProgram = input; com.Init(); com.inputs.Enqueue(i); // com.inputs.Enqueue(-1); com.Calc(); coms.Add(com); } long lastY = -1; long natX = 0; long natY = 0; while (true) { bool allEmpty = true; for (int i = 0; i < 50; i++) { var com = coms[i]; if (com.inputs.Count == 0) { com.inputs.Enqueue(-1); } else { allEmpty = false; } com.Calc(); if (com.outputs.Count != 0) { allEmpty = false; } while (com.outputs.Count > 0) { var addr = com.outputs.Dequeue(); var X = com.outputs.Dequeue(); var Y = com.outputs.Dequeue(); if (addr == 255) { // Console.WriteLine("FOUND 255: {0} {1}",X,Y); natX = X; natY = Y; } else { coms[(int)addr].inputs.Enqueue(X); coms[(int)addr].inputs.Enqueue(Y); } } } if (allEmpty) { coms[0].inputs.Enqueue(natX); coms[0].inputs.Enqueue(natY); if (lastY == natY) { output = natY + ""; break; } lastY = natY; // Console.WriteLine("EMPTY"); // Console.WriteLine("LAST 255: {0} {1}", natX, natY); // Console.ReadLine(); } } }
public override void Calc() { computer com = new computer(); com.inputProgram = 2 + input.Remove(0, 1); com.Init(); com.Calc(); string scr = ""; while (com.outputs.Count > 0) { scr += getAscii(com.outputs.Dequeue() + ""); } Console.WriteLine(scr); var r = scr.Split('\n'); int start = scr.IndexOf('^'); int startY = start / r[0].Length; int startX = r[startY].IndexOf('^'); int x = startX; int y = startY; int sx = 0; int sy = -1; int curDir = 0; turn(0); look(); char rr(int gy, int gx) { if (gy >= 0 && gx >= 0) { if (r.Length > gy && r[gy].Length > gx) { return(r[gy][gx]); } } return('.'); } void turn(int dir) { dir += 4; dir %= 4; switch (dir) { case 0: sx = 0; sy = -1; break; case 1: sx = 1; sy = 0; break; case 2: sx = 0; sy = 1; break; case 3: sx = -1; sy = 0; break; } curDir = dir; } int look() { bool l = false, rt = false, u = false, d = false; if (rr(y - 1, x) == '#') { u = true; } if (rr(y + 1, x) == '#') { d = true; } if (rr(y, x - 1) == '#') { l = true; } if (rr(y, x + 1) == '#') { rt = true; } // Console.WriteLine(u + " " + d + " " + l + " " + rt); // Console.WriteLine(curDir); int res = 0; switch (curDir) { case 0: if (l) { res = -1; } if (rt) { res = 1; } break; case 1: if (u) { res = -1; } if (d) { res = 1; } break; case 2: if (l) { res = 1; } if (rt) { res = -1; } break; case 3: if (u) { res = 1; } if (d) { res = -1; } break; } // Console.WriteLine(res); return(res); } List <string> paths = new List <string>(); while (true) { int count = 0; while (rr(y + sy, x + sx) == '#') { count++; y += sy; x += sx; } paths.Add(count + ""); var l = look(); turn(curDir + l); if (l == 1) { paths.Add("R"); } else if (l == -1) { paths.Add("L"); } else { break; } } if (paths[0] == "0") { paths.RemoveAt(0); } Console.WriteLine(String.Join(",", paths)); while (!com.done) { // Console.ReadLine(); Console.WriteLine("waiting for input"); var c = Console.ReadLine(); foreach (char a in c) { com.inputs.Enqueue((int)a); } com.inputs.Enqueue((int)'\n'); com.Calc(); while (com.outputs.Count > 0) { Console.Write(getAscii(com.outputs.Dequeue() + "")); } } output = com.output + ""; }
public override void Calc() { whites.Add(new PointS(0, 0)); computer com = new computer(); com.inputProgram = input; com.Init(); while (!com.done) { if (whites.Contains(new PointS(pos.X, pos.Y))) { com.inputs.Enqueue(1); } else { com.inputs.Enqueue(0); } com.Calc(); if (com.outputs.Dequeue() == 1) { if (!whites.Contains(new PointS(pos.X, pos.Y))) { whites.Add(new PointS(pos.X, pos.Y)); } } else { whites.Remove(new PointS(pos.X, pos.Y)); } if (!countColor.Contains(new PointS(pos.X, pos.Y))) { countColor.Add((new PointS(pos.X, pos.Y))); } if (com.outputs.Dequeue() == 1) { currentDir = TurnFrom(currentDir, direction.right); } else { currentDir = TurnFrom(currentDir, direction.left); } move(currentDir); } Point min = new Point(9999, 9999); Point max = new Point(-9999, -9999); foreach (var a in whites) { min.X = Math.Min(min.X, a.X); max.X = Math.Max(max.X, a.X); min.Y = Math.Min(min.Y, a.Y); max.Y = Math.Max(max.Y, a.Y); } int offx = min.X; int offy = min.Y; char[][] code = new char[max.Y - min.Y + 1][]; for (int i = 0; i < code.Length; i++) { code[i] = new char[max.X - min.X + 1]; for (int j = 0; j < code[i].Length; j++) { code[i][j] = '.'; } } foreach (var a in whites) { code[max.Y - a.Y][a.X - min.X] = '#'; } for (int i = 0; i < code.Length; i++) { for (int j = 0; j < code[i].Length; j++) { output += code[i][j]; } output += '\n'; } }
public override void Calc() { com = new computer(); com.inputProgram = input; com.Init(); com.Calc(); var res = ""; foreach (var a in com.outputs) { res += ((char)a); } visited.Add("", res); toExplore.Push(""); while (toExplore.Count > 0) { var p = toExplore.Pop(); if (p != "") { var expRes = explore(p); // Console.WriteLine("Path: {0}", p); //Console.WriteLine("log: {0}", expRes); // Console.ReadLine(); visited.Add(p, expRes); } var l = checkDirs(p, visited[p]); foreach (var entry in l) { toExplore.Push(entry); } } com.Calc(); var cout = ""; foreach (var a in com.outputs) { cout += ((char)a); } travelTo(pathToGoal);; QueueCom("inv"); com.Calc(); var itemString = getRes(); List <string> itemsList = getItems(itemString); var comboList = GenerateCombinations(itemsList); foreach (var combo in comboList) { OrganiseInv(combo); QueueCom(fullAct(dirToGoal)); com.Calc(); cout = getRes(); if (!cout.Contains("Alert")) { var st = cout.IndexOf("typing") + "typing".Length + 1; var ed = cout.IndexOf(" ", st); output = cout.Substring(st, ed - st); break; } } }
public override void Calc() { screen = new char[h][]; for (int i = 0; i < h; i++) { screen[i] = new char[w]; for (int j = 0; j < w; j++) { screen[i][j] = ' '; } } spaces.Add(new point(0, 0)); special.Add(new point(0, 0)); computer com = new computer(); com.inputProgram = input; // com.toLog = true; com.Init(); bool autoMode = false; Random rng = new Random(); while (true) { com.Calc(); //var dir = Console.ReadKey(); //Console.WriteLine(dir.Key); //Console.ReadLine(); var dirn = 0; /* switch (dir.Key) * { * case ConsoleKey.UpArrow: dirn=1; break; * case ConsoleKey.DownArrow: dirn = 2; break; * case ConsoleKey.LeftArrow: dirn = 3; break; * case ConsoleKey.RightArrow: dirn = 4; break; * case ConsoleKey.A: autoMode = true; break; * case ConsoleKey.S: autoMode = false; break; * } */ /* * 1 check if there are unexplored spaces around * 2 if found, move to any unexplored space * 3 if the move was successfull add a move direction on to a stack, else add 0 * (2) if it wasn't found move back one time */ var ch = findDir(); dirn = ch; bool isBack = false; if (dirn >= 1 && dirn <= 4) { com.inputs.Enqueue(dirn); com.Calc(); isBack = false; } else { if (moves.Count == 0) { break; } dirn = anti(moves.Pop()); com.inputs.Enqueue(dirn); com.Calc(); isBack = true; } if (com.outputs.Count > 0) { var o = com.outputs.Dequeue(); if (o == 0)//wall { switch (dirn) { case 1: walls.Add(new point(pos.x, pos.y + 1)); break; case 2: walls.Add(new point(pos.x, pos.y - 1)); break; case 3: walls.Add(new point(pos.x - 1, pos.y)); break; case 4: walls.Add(new point(pos.x + 1, pos.y)); break; } } else if (o == 1) //empty { switch (dirn) { case 1: spaces.Add(new point(pos.x, pos.y + 1)); pos.y++; break; case 2: spaces.Add(new point(pos.x, pos.y - 1)); pos.y--; break; case 3: spaces.Add(new point(pos.x - 1, pos.y)); pos.x--; break; case 4: spaces.Add(new point(pos.x + 1, pos.y)); pos.x++; break; } if (!isBack) { moves.Push(dirn); } moveCount++; } else if (o == 2)//found { switch (dirn) { case 1: special.Add(new point(pos.x, pos.y + 1)); pos.y++; break; case 2: special.Add(new point(pos.x, pos.y - 1)); pos.y--; break; case 3: special.Add(new point(pos.x - 1, pos.y)); pos.x--; break; case 4: special.Add(new point(pos.x + 1, pos.y)); pos.x++; break; } if (!isBack) { moves.Push(dirn); } moveCount = 0; // Console.WriteLine(moves.Count); //Console.WriteLine("FOUND!!!"); // Console.ReadLine(); output = moves.Count + ""; break; } } /* * clear(); * setScreen(); * Console.Clear(); * writeScreen(); */ } /* clear(); * setScreen(); * Console.Clear(); * writeScreen();*/ }
public override void Calc() { int w = 50; int h = 25; screen = new char[h][]; for (int i = 0; i < h; i++) { screen[i] = new char[w]; for (int j = 0; j < w; j++) { screen[i][j] = ' '; } } computer com = new computer(); com.inputProgram = input; com.Init(); // com.toLog = true; com.code[0] = 2; int step = 0; while (true) { com.Calc(); int ballx = 0; int padx = 0; int countB = 10; int wait = 10; while (com.outputs.Count > 0) { var x = (int)com.outputs.Dequeue(); var y = (int)com.outputs.Dequeue(); var id = (int)com.outputs.Dequeue(); if (x < 0) { score = id; } else { /* * 0 is an empty tile. No game object appears in this tile. * 1 is a wall tile. Walls are indestructible barriers. * 2 is a block tile. Blocks can be broken by the ball. * 3 is a horizontal paddle tile. The paddle is indestructible. * 4 is a ball tile. The ball moves diagonally and bounces off objects. */ switch (id) { case 0: screen[y][x] = ' '; break; case 1: screen[y][x] = '+'; break; case 2: screen[y][x] = '#'; countB++; break; case 3: screen[y][x] = '='; padx = x; break; case 4: screen[y][x] = 'o'; ballx = x; break; } } } bool found = false; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (screen[i][j] == '#') { found = true; break; } if (found) { break; } } } if (!found) { break; } step++; if (step % 100 == 0) { /* * * * Console.Clear(); * * for (int i = 0; i < h; i++) * { * for (int j = 0; j < w; j++) * { * Console.Write(screen[i][j]); * } * Console.WriteLine(); * } * Console.WriteLine(score); */ } //var inp = int.Parse(Console.ReadLine()); //com.inputs.Enqueue(inp); //Console.ReadLine(); if (padx > ballx) { com.inputs.Enqueue(-1); } else if (padx < ballx) { com.inputs.Enqueue(1); } else { com.inputs.Enqueue(0); } } output = score + ""; }