Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Convert me! (base64)
- //aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1tTWZ4STNyX0x5QQ==
- import java.io.*;
- import java.util.*;
- public class BootlegAmalgamation {
- public Stack <moveController> stacksOnStacks = new Stack<>();
- public ArrayList <String> newMaze = new ArrayList<>();
- public ArrayList <moveController> ogMaze = new ArrayList();
- int wingle1;
- int wingle2;
- public BootlegAmalgamation() {
- try {
- Scanner scanSki = new Scanner ( new BufferedReader( new FileReader("maze.txt")));
- while (scanSki.hasNextLine()) {
- newMaze.add(scanSki.nextLine());
- }
- scanSki.close();
- }
- catch(Exception e){
- System.out.print(e.getMessage());
- e.printStackTrace();
- }
- for( int x = 0; x < newMaze.size(); x++) {
- for (int y = 0; y < newMaze.get(x).length(); y++) {
- if( newMaze.get(x).substring(y, y+1).equals("@")) {
- stacksOnStacks.push(new moveController(x,y)); //Finds the Start of the Maze and pushes the location onto the stack
- System.out.println("Sup Bih, heres where you start" + " " + x + " " + "," + " " + y);
- }
- }
- }
- if(stacksOnStacks.peek() == null){
- System.out.println("Kramer wtf, why does this maze not have a start point");
- }
- else {
- try {
- while(newMaze.get(stacksOnStacks.peek().getYCoordinate()).substring(stacksOnStacks.peek().getXCoordinate(), stacksOnStacks.peek().getXCoordinate() + 1) != "$") {
- goGoGadgetSolver();
- }
- } catch (Exception e) {
- System.out.print(e.getMessage());
- e.printStackTrace();
- }
- }
- }
- public static void main (String [] args) {
- new BootlegAmalgamation();
- }
- private boolean uberSexyBacktrack(int newX, int newY){ //not sure how to use this
- boolean dejaVu = false;
- for(int wingle = 0; wingle < ogMaze.size(); wingle++){
- if(ogMaze.get(wingle).equals(new moveController(newX, newY))) {
- dejaVu = true;
- }
- }
- if(!dejaVu){
- ogMaze.add(new moveController(wingle1, wingle2)); //artifact leftover from your stuff, check and modify pls
- stacksOnStacks.push(new moveController(newX,newY));
- return true;
- }
- return false;
- }
- /**
- * this ting goes through the 4 checks and also functions as the printer too.
- */
- public void goGoGadgetSolver(){
- int a;
- int b;
- a = stacksOnStacks.peek().getXCoordinate();
- b = stacksOnStacks.peek().getYCoordinate();
- stacksOnStacks.push(new moveController(a,b));
- System.out.print(a + " , " + b);
- up(a,b);
- down(a,b);
- left(a,b);
- right(a,b);
- }
- /**
- * checks for a possible path that can go upwards
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public boolean up(int x1, int y1)
- {
- boolean ye1 = false;
- if(y1 != 0){ //Checks if we can actually go up or not
- if (newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(y1+1,y1+2).equals(".") || newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(y1+1,y1+2).equals("$")) { //if it finds either a valid solution or the end
- if(uberSexyBacktrack(x1,y1+1)) {
- return true;
- } else {
- return false;
- }
- }
- }
- return ye1;
- }
- /**
- * Checks for a possible path that can go upwards
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public boolean down(int x2, int y2)
- {
- boolean ye2 = false;
- if(y2 < newMaze.size()){ //Checks if we can actually go down or not, idk what to put here, it used to be the xaxis but that shit aint here
- if (newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(y2-1,y2).equals(".") || newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(y2-1,y2).equals("$")){
- if(uberSexyBacktrack(x2, y2-1)) {
- ye2 = true;
- } else {
- ye2 = false;
- }
- }
- }
- return ye2;
- }
- /**
- * checks for a possible path that can go leftwards
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public boolean left(int x3, int y3)
- {
- boolean ye3 = false;
- if (newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(x3-1,x3).equals(".") || newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(x3-1,x3).equals("$")) {
- if(uberSexyBacktrack(x3-1, y3)) {
- ye3 = true;
- } else {
- ye3 = false;
- }
- }
- return ye3;
- }
- /**
- * checks for a possible path that can go rightwards
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public boolean right(int x4, int y4)
- {
- boolean ye4 = false;
- if (newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(x4+1, x4+2).equals(".") || newMaze.get(stacksOnStacks.peek().getXCoordinate()).substring(x4+1, x4+2).equals("$")) {
- if(uberSexyBacktrack(x4+1, y4)) {
- ye4 = true;
- } else {
- ye4 = false;
- }
- }
- return ye4;
- }
- public class moveController{
- public int xLocation;
- public int yLocation;
- public moveController(int xPosition, int yPosition) {
- xLocation = xPosition;
- yLocation = yPosition;
- }
- public int getYCoordinate(){
- return yLocation;
- }
- public int getXCoordinate(){
- return xLocation;
- }
- @Override
- public boolean equals(Object obj){
- if(obj == this){
- return true;
- }
- if(obj instanceof moveController){
- moveController location = (moveController) obj;
- return (xLocation == moveController.getXCoordinate()) && (yLocation == moveController.getYCoordinate());
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement