public string RealExecute(FungeContext fungeContext) { var values = fungeContext.GetTopStackTopValues(fungeContext.Dimension + 1); var targetCell = new DeltaVector(values.Reverse().Skip(1).ToArray()) + fungeContext.CurrentThread.StorageOffset; fungeContext.ModifyCell(targetCell, values.Last()); return(null); }
public string RealExecute(FungeContext fungeContext) { var value = fungeContext.GetTopStackTopValues(1)[0]; fungeContext.ModifyCell(fungeContext.CurrentThread.CurrentPosition + fungeContext.CurrentThreadDeltaVector, value); fungeContext.MoveCurrentThread(); return(null); }
public string RealExecute(FungeContext fungeContext) { var filename = fungeContext.PopString(); var flag = fungeContext.GetTopStackTopValues(1)[0]; var vec = new DeltaVector(fungeContext.GetTopStackTopValues(fungeContext.Dimension).Reverse().ToArray()); if (!File.Exists(filename)) { fungeContext.CurrentThreadDeltaVector = fungeContext.CurrentThreadDeltaVector.Reflect(); return(null); } var y = 0; int maxX = 0; if ((flag & 1) == 1) { using var fs = File.OpenRead(filename); using var reader = new BinaryReader(fs); var target = vec + fungeContext.CurrentThread.StorageOffset; while (reader.BaseStream.Position != reader.BaseStream.Length) { var c = reader.Read(); fungeContext.ModifyCell(target, c); target.X += 1; } maxX = (int)(reader.BaseStream.Length + fungeContext.CurrentThread.StorageOffset.X); } else { foreach (var line in File.ReadLines(filename)) { for (var x = 0; x < line.Length; x++) { if (line[x] == ' ' || line[x] == '\f') { continue; } fungeContext.ModifyCell( new DeltaVector(x, y, 0) + vec + fungeContext.CurrentThread.StorageOffset, line[x]); } if (line.Length > maxX) { maxX = line.Length; } y++; } } fungeContext.PushToTopStack(maxX); fungeContext.PushToTopStack(y); foreach (var c in vec.Coords(fungeContext.Dimension)) { fungeContext.PushToTopStack(c); } return(null); }