Last active
June 10, 2022 06:06
-
-
Save masalt0/5aa33f29a62d7999049a651f873d42c5 to your computer and use it in GitHub Desktop.
The official Path interpreter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# └┐┌┘├┴─┬┤│┼█×÷± # | |
import random as r | |
out='' | |
file=open(input('.path: ')+'.path','r').readlines();import time;import os;cls=lambda:os.system('cls'if os.name in ('nt','dos')else'clear') | |
row=0 | |
column=0 | |
loopstartrow=0 | |
loopstartcolumn=0 | |
pointer='' | |
directions=['up','down','left','right'] | |
direction='right' | |
datatype='lit' | |
stroutput='' | |
intoutput='' | |
strsymbol='' | |
file2='' | |
stack=[0] | |
def move(d): | |
global row, column | |
if d=='up':row-=1 | |
if d=='down':row+=1 | |
if d=='left':column-=1 | |
if d=='right':column+=1 | |
cls() | |
while not pointer=='@': | |
if column+1>len(file[row]): | |
print("Error: Where did the line go?? (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
pointer=file[row][column] | |
if pointer=='─' and (direction=='up' or direction=='down'): | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column+1)+")");time.sleep(1.3);exit() | |
if pointer=='│' and (direction=='left' or direction=='right'): | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column+1)+")");time.sleep(1.3);exit() | |
if pointer=='┐': | |
if direction=='left' or direction=='down': | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column+1)+")");time.sleep(1.3);exit() | |
if direction=='up': | |
direction='left' | |
if direction=='right': | |
direction='down' | |
if pointer=='┘': | |
if direction=='down': | |
direction='left' | |
elif direction=='right': | |
direction='up' | |
else: | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column+1)+")");time.sleep(1.3);exit() | |
if pointer=='┌': | |
if direction=='up': | |
direction='right' | |
elif direction=='left': | |
direction='down' | |
else: | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='└': | |
if direction=='down': | |
direction='right' | |
elif direction=='left': | |
direction='up' | |
else: | |
print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='┴': | |
if not direction=='up': | |
direction='up' | |
else: print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='┬': | |
if not direction=='down': | |
direction='down' | |
else: print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='┤': | |
if not direction=='left': | |
direction='left' | |
else: print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='├': | |
if not direction=='right': | |
direction='right' | |
else: print("Error: That's not how lines work. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='█': | |
if direction=='down': | |
direction='u' | |
if direction=='up': | |
direction='down' | |
if direction=='u': | |
direction='up' | |
if direction=='right': | |
direction='l' | |
if direction=='left': | |
direction='right' | |
if direction=='l': | |
direction='left' | |
if pointer=='&': | |
stack+=[0] | |
if pointer=='+': | |
stack[-1]+=1 | |
if pointer=='-': | |
stack[-1]-=1 | |
if pointer==',': | |
out+=chr(stack[-1]) | |
stack.pop() | |
if pointer=='.': | |
out+=str(stack[-1]) | |
stack.pop() | |
if pointer==':': | |
stack+=[stack[-1]] | |
if pointer=='$': | |
stack.pop() | |
if pointer=='~': | |
stack+=[ord(input('" ')[0])] | |
if pointer=='#': | |
stack+=[int(input('# '))] | |
if pointer=='j': | |
stack+=[int(str(stack[-1])+str(stack[-2]))] | |
stack.pop(-2) | |
stack.pop(-2) | |
if pointer=='J': | |
stack+=[int(str(stack[-2])+str(stack[-1]))] | |
stack.pop(-2) | |
stack.pop(-2) | |
if pointer in '^v<>' and stack[-1]>stack[-2]: | |
if pointer=='^': | |
direction='up' | |
if pointer=='v': | |
direction='down' | |
if pointer=='<': | |
direction='left' | |
if pointer=='>': | |
direction='right' | |
if pointer in '0123456789': | |
stack+=[int(pointer)] | |
if pointer=='×': | |
stack+=[stack[-1]*stack[-2]] | |
stack.pop(-2) | |
stack.pop(-2) | |
if pointer=='÷': | |
stack+=[round(stack[-1]/stack[-2])] | |
stack.pop(-2) | |
stack.pop(-2) | |
if pointer=='=': | |
if stack[-1]==stack[-2]: | |
stack+=[1] | |
else: stack+=[0] | |
if pointer=='p': | |
print(out) | |
out='' | |
if pointer=='%': | |
stack+=[stack[-2]] | |
stack.insert(-3,stack[-2]) | |
stack.pop() | |
stack.pop() | |
if pointer=='g': | |
stack+=[stack[stack[-1]]] | |
stack.pop(-2) | |
if pointer=='r': | |
stack.pop(stack[-1]) | |
stack.insert(stack[-1],stack[-2]) | |
if pointer=='±': | |
move(direction) | |
pointer=file[row][column] | |
if pointer=='+': | |
stack+=[stack[-1]+stack[-2]] | |
elif pointer=='-': | |
stack+=[stack[-1]-stack[-2]] | |
else:print("Error: That's not how you proceed the '±' instruction. (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
if pointer=='w': | |
time.sleep(stack[-1]/10) | |
stack.pop() | |
if pointer=='q': | |
ln=stack[-1] | |
stack.pop() | |
if '\n' in file[ln]: | |
out+=file[ln][:-1] | |
else: out+=file[ln] | |
if pointer == '?': | |
direction=directions[r.randrange(1,4)] | |
if not pointer in '?^v<>Jjqpgrw#~$:.,-+&└┐┌┘%├┴┬┤─│┼█@0123456789×÷±=': | |
print("Error: Where did the line go?? (Line "+str(row+1)+", Column "+str(column)+")");time.sleep(1.3);exit() | |
move(direction) | |
if '*' in file: | |
print(stack) | |
print(out) | |
time.sleep(.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment