However, when i test your

The previous assignment shows below:
Turing machine pt 1
====
Implementing the tape and read head from a Turing machine
===
For this project, you will begin implementing a Turing machine. A Turing
machine, originally proposed by mathematician Alan Turing decades before
any actual computer had been built, is a relatively simple mathematical
abstraction that nonetheless can perform any calculation that any
computer can perform — albeit very slowly.
For our purposes, a Turing machine consists of the following components:
1) A strip of paper divided up into squares. Each square can have (or
not have) a mark in it. This strip of paper, which represents the
machine’s memory, is assumed to be infinite.
2) A “read head”, marking the machine’s current position on the tape.
The machine can perform the following actions;
* Check if a mark is present on the current square
* Mark the current square
* Erase the mark on the current square
* Move the read head one square left
* Move the read head one square right
clarification: Under the Turing machine definition that we’re using for this sequence of assignments, each square can contain either:
A mark
No mark
You can think of each square as being a bit — if there’s a mark, it’s a 1, if there’s no mark, it’s a 0. I
3) The machine also has a “state table.” The state table — which you
will implement in part two of this assignment — is used to program the
Turing machine.
Here is what you have to implement in this assignment.
A class called TuringMachine, declared in a file named TuringMachine.h
and defined in a file named TuringMachine.cpp.
This class must have some sort of instance variable that stores what
squares on the tape have marks on them. However, you must find a
relatively memory-efficient way to store the tape. If you simply store
the tape as (for example) an array or vector of bools, with each item in
the array or vector indicating one square, your program will definitely
fail many of the required tests. This is because you will very quickly
run out of available memory. Real-world computers, unlike Turing
machines, have finite amounts of memory.
NOTE: None of my tests will involve moving the read head more than
2147483647 spaces to the left or right of the initial square.
Your TuringMachine class should also contain an instance variable
indicating the currently selected square.
At this stage the class should contain public member functions with the
following signatures:
void TuringMachine::move_left(); // moves the read head 1 square left
void TuringMachine::move_right(); // moves the read head 1 square right
bool TuringMachine::read_square(); // returns true if there is a mark
// on the current square, false otherwise
void TuringMachine::make_mark(); // marks the current square, if it
// is not already marked
void TuringMachine::remove_mark(); // if there is a mark on the current
// square, remove it
std::string TuringMachine::get_tape(); // returns a string
// representation of the tape
NOTE: I am not dictating a format for the tape’s string representation for this assignment, but the required format for part 2 is as follows: a list, contained in brackets and separated by commas, of the indexes of all squares with a 1 in them. Something like this is ideal:
[-10, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3]
long TuringMachine::get_current_square(); // returns the location of
// the read head
I encourage you to write a main.cpp function that thoroughly tests your
Turing machine class to your satisfaction. However, when I test your
class, I will use my own main.cpp function.
The attached files are my code from the previous assignment, please do the assignment based on my two files, thanks!

CategoriesC#

Leave a Reply

Your email address will not be published. Required fields are marked *