I have attempted at treating an implementation of To The Top Right Corner, a not implemented Esolang using a 5x5 grid. Read this article to understand how it should work.
Note that I have changed the grid in my version and it is very different.
Repl
The issue is that if you use the tokens (as shown in the article) they are not moving in the section in the right position, nor is the starting position correct. I have no previous experience with grids and have no idea how to fix this. I believe it may be due to the grid automatically starting at a different position and the X and y being different.
My version uses a different grid…
grid:
1:2:3:4:5
5: a b c d e
4: f g h i j
3: k l m n o
2: p q r s t
1: u v w x z
You can use .
to print the selected letter to console.
Code
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
// grid:
// 1:2:3:4:5
// 5: a b c d e
// 4: f g h i j
// 3: k l m n o
// 2: p q r s t
// 1: u v w x z
int main() {
int x = 1;
int y = 1;
int loop = 1;
string input, out;
char grid[5][5] = {{'a','b','c','d','e'},
{'f','g','h','i','j'},
{'k','l','m','n','o'},
{'p','q','r','s','t'},
{'u','v','w','x','y'}};
out=grid[x][y];
while (loop == 1) {
cin >> input;
if (input == ">") {
if(x<5){
x = x+1;
}
} else if(input=="<"){
if(x<-1){
x = x-1;
}
} else if(input=="^"){
if(y<6){
y = y+1;
}
} else if(input=="v"){
if(y>1){
y = y-1;
}
} else if(input=="+"){
if(y<6){
y = y+1;
}
if(x<6){
x = x+1;
}
} else if(input=="-"){
if(y>1){
y = y-1;
}
if(x<6){
x = x+1;
}
} else if(input=="*"){
if(y>1){
y = y-1;
}
if(x<-1){
x = x-1;
}
} else if(input=="+"){
if(y<6){
y = y+1;
}
if(x<-1){
x = x-1;
}
} else if (input == ".") {
cout<<out;
}
out=grid[x][y];
// auto out = string(1,out)+grid[x][y];
}
}