44 lines
988 B
C++
44 lines
988 B
C++
#include <iostream>
|
|
|
|
#include "turing.cpp"
|
|
#include "utils/print.cpp"
|
|
|
|
enum values {
|
|
yes = 1,
|
|
no = 0,
|
|
blank = 6,
|
|
};
|
|
|
|
int main() {
|
|
auto def = new Turing::Definition<char, values> {
|
|
.defaultState = 'a',
|
|
.defaultValue = values::blank,
|
|
.instructions = {
|
|
// multiply binary represented number by 2
|
|
Turing::Instruction('a', values::yes, 'a', values::yes, Turing::Movement::right),
|
|
Turing::Instruction('a', values::no, 'a', values::no, Turing::Movement::right),
|
|
Turing::Instruction('a', values::blank, 'b', values::no, Turing::Movement::right),
|
|
}
|
|
};
|
|
|
|
auto turing = new Turing::Machine(def);
|
|
|
|
turing->setTape({
|
|
values::no,
|
|
values::no,
|
|
values::yes,
|
|
values::no,
|
|
values::yes,
|
|
values::no,
|
|
values::yes,
|
|
values::no
|
|
});
|
|
|
|
print(turing);
|
|
std::cout << '\n';
|
|
|
|
while(turing->tick());
|
|
|
|
print(turing);
|
|
return 0;
|
|
}
|