HALP.

...
Last edited on
That the program worked properly?

What?

Why would you want to place a class named Machine into a program that already has a struct named machine? Seems to be a good source of confusion to me. Besides I don't see where you're actually trying to use that class anyway.

But if you really want to add that badly named class then you would place that code somewhere before you try to use that class.

You also need to be more consistent on your indentation.
...
Last edited on
It's universal turing machine and my aim is to make it parallel with few input files. One of the ideas was to add a running flag.

So? You need to stop using the same variable names for multiple uses. You keep trying to use the name "machine" for so many things it's just confusing you.

Please, help to make it working.

So what exactly is wrong with your program? What exactly are you trying to "fix"?

You have some fragments of code and you don't know where to copy-paste?

I'm not sure whether you have progressed since the last time you did post about that homework in: http://www.cplusplus.com/forum/beginner/243014/

Copy-pasting won't get you anywhere as long as you have no proper understanding of what you are dealing with.


What does "make parallel" mean?
...
Last edited on
You see, parallel could mean that you have N Turing machines, one for each tape and they execute independent of each other. This is easy to achieve. You have a program that processes one tape. You can start multiple copies of that program, one for each tape.

That is apparently not what you mean.

One could have a "sequential" machine that executes one tape at a time:
FOR EACH tape
  PROCESS tape


What you did describe is equally sequential:
1
2
3
WHILE tapes have instructions
  FOR EACH tape
    PROCESS one instruction from tape

That is quite confusing, because consecutive instructions are in different tapes.
One cannot look at one tape and know what the machine will do.

One could of course preprocess/merge the tapes into single one, which is then fed into the machine.



Perhaps you have a valid idea, but you must describe its rationale.
...
Last edited on
N machines after all.

The first loop is quite easy:
1
2
3
4
5
6
7
8
9
vector<string> filenames;
// fill filenames

vector<machine> machines;
machines.reserve( filenames.size() );
for ( auto file : filenames )
{
  machines.emplace_back( file );
}

The only thing you need is a constructor for your machine that takes filename as a std::string parameter and does the load during construction.

The rest is no more difficult.


You do realize that if the machines do output, then the output will be interleaved?
Topic archived. No new replies allowed.