Ejemplo n.º 1
0
		public static InterpretatorEndState Iterpretate(string pseudobfProgram, out bool[,] resultMatrix)
		{
			resultMatrix = null;
			if (pseudobfProgram.Length >= MaxProgramLength)
				return InterpretatorEndState.TooBigProgramFail;

			var compiled = CompileSource(pseudobfProgram);
			var state = new Interpretator2State();

			while (state.IterationsCount < 10000)
			{
				if (state.ProgramPosition >= compiled.Count)
				{
					resultMatrix = state.Matrix;
					return InterpretatorEndState.Success;
				}

				if (compiled[state.ProgramPosition] == null)
				{
					if (state.Matrix[state.X, state.Y])
					{
						resultMatrix = state.Matrix;
						return InterpretatorEndState.Success;
					}

					state.DoNothing();
					continue;
				}

				compiled[state.ProgramPosition](state);
			}

			return InterpretatorEndState.TooMuchTimeFail;
		}
        public static InterpretatorEndState Iterpretate(string pseudobfProgram, out bool[,] resultMatrix)
        {
            resultMatrix = null;
            if (pseudobfProgram.Length >= MaxProgramLength)
            {
                return(InterpretatorEndState.TooBigProgramFail);
            }

            var compiled = CompileSource(pseudobfProgram);
            var state    = new Interpretator2State();

            while (state.IterationsCount < 10000)
            {
                if (state.ProgramPosition >= compiled.Count)
                {
                    resultMatrix = state.Matrix;
                    return(InterpretatorEndState.Success);
                }

                if (compiled[state.ProgramPosition] == null)
                {
                    if (state.Matrix[state.X, state.Y])
                    {
                        resultMatrix = state.Matrix;
                        return(InterpretatorEndState.Success);
                    }

                    state.DoNothing();
                    continue;
                }

                compiled[state.ProgramPosition](state);
            }

            return(InterpretatorEndState.TooMuchTimeFail);
        }