Started a binary adder
This commit is contained in:
parent
7e4fcbf35e
commit
9f3e859a46
10 changed files with 56 additions and 10 deletions
4
cards/1
4
cards/1
|
@ -1,6 +1,6 @@
|
|||
1
|
||||
0
|
||||
1
|
||||
2
|
||||
1
|
||||
0
|
||||
2
|
||||
0
|
||||
|
|
4
cards/2
4
cards/2
|
@ -1,6 +1,6 @@
|
|||
0
|
||||
1
|
||||
3
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
0
|
||||
|
|
6
cards/3
Normal file
6
cards/3
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
4
|
||||
1
|
||||
0
|
||||
2
|
6
cards/4
Normal file
6
cards/4
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
5
|
||||
1
|
||||
0
|
||||
3
|
6
cards/5
Normal file
6
cards/5
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
6
|
||||
1
|
||||
0
|
||||
4
|
6
cards/6
Normal file
6
cards/6
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
7
|
||||
1
|
||||
0
|
||||
5
|
6
cards/7
Normal file
6
cards/7
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
8
|
||||
1
|
||||
0
|
||||
6
|
6
cards/8
Normal file
6
cards/8
Normal file
|
@ -0,0 +1,6 @@
|
|||
0
|
||||
1
|
||||
9
|
||||
1
|
||||
0
|
||||
7
|
6
cards/9
Normal file
6
cards/9
Normal file
|
@ -0,0 +1,6 @@
|
|||
1
|
||||
1
|
||||
8
|
||||
1
|
||||
0
|
||||
8
|
16
machine.py
16
machine.py
|
@ -16,7 +16,7 @@ class Register:
|
|||
else:
|
||||
return p + str(self.positive[self.pos])
|
||||
|
||||
def read(self):
|
||||
def read(self):
|
||||
if self.pos == 0:
|
||||
return self.zero
|
||||
elif self.pos < 0:
|
||||
|
@ -51,12 +51,15 @@ class Card:
|
|||
with open("cards/" + str(self.number) ,'r') as f:
|
||||
for row in f:
|
||||
line.append(row[:-1])
|
||||
self.zero_write = bool(line[0])
|
||||
self.zero_move = bool(line[1])
|
||||
self.zero_write = bool(int(line[0]))
|
||||
self.zero_move = bool(int(line[1]))
|
||||
self.zero_next = int(line[2])
|
||||
self.one_write = bool(line[3])
|
||||
self.one_move = bool(line[4])
|
||||
self.one_write = bool(int(line[3]))
|
||||
self.one_move = bool(int(line[4]))
|
||||
self.one_next = int(line[5])
|
||||
def __str__(self):
|
||||
return "Card number: " + str(self.number) + "\nIf 1 :\nMove: " + str(self.one_move) + "\nWrite: " + str(self.one_write) + "\nNext card: " + str(self.one_next) + "\nIf 0 :\nMove: " + str(self.zero_move) + "\nWrite: " + str(self.zero_write) + "\nNext card: " + str(self.zero_next) + '\n'
|
||||
|
||||
|
||||
class Machine:
|
||||
def __init__(self):
|
||||
|
@ -93,4 +96,5 @@ class Machine:
|
|||
turing = Machine()
|
||||
run = True
|
||||
while run:
|
||||
run = turing.evolve()
|
||||
# print (turing.card)
|
||||
run = turing.evolve()
|
||||
|
|
Loading…
Add table
Reference in a new issue