maze

Java: Trouble randomizing a DFS run to build a maze

こ雲淡風輕ζ 提交于 2019-12-25 01:36:40
问题 I'm having trouble randomizing the visit from a node to its neighbors, rarely is the whole graph (a MxN array, in this test 4x4) visited, I don't get what I'm doing wrong here. import java.util.ArrayList; class IJ { int i; int j; IJ (int i,int j){ i = this.i; j= this.j; } } class Graph { int M; int N; int adjacencyMatrix[][]; ArrayList <IJ> orderOfVisits; Graph(int M,int N){ this.M=M; this.N=N; adjacencyMatrix=new int[M][N]; for (int i=0; i<M; i++) for (int j=0;j<N;j++){ adjacencyMatrix[i][j]

Create an alternative form of questionnaire

本小妞迷上赌 提交于 2019-12-25 00:56:12
问题 I'm very new to programming in python so I'd appreciate any tips or hints as to where I can look: So what I basically planned on creating is a new form of questionnaire, where the respondent can express approval or disapproval to a question by dragging it from the center of the window into any part of a colored ring that surrounds the question, using the mouse. The ring is supposed to have two color gradients from green to red, and I want to be able to make my program (pygame?) track the

How to do collision detection with many walls (maze)?

ぃ、小莉子 提交于 2019-12-24 18:13:14
问题 In my game, the player navigates a maze. I can't figure out how to do proper collision detection with the walls. It is easy to do collision detection for staying in a certain area: if (x > rightWallX - playerWidth) x = rightWallX - playerWidth; if (x < leftWallX) x = leftWallX; //... But how would I do collision detection for many walls? I can do plain collision detection without correction (like if (intersecting) return true; ), but I can't correct this correctly. If I just store the old x

Why Wont Maze solver Code Work [duplicate]

随声附和 提交于 2019-12-24 15:23:58
问题 This question already has answers here : Why does my maze solver not work? (2 answers) Closed 3 years ago . Sorry for the bad formatting and large amount of code, I am only a beginner and do not know how to diagnose the error down to a smaller amount of code. Where am i going wrong it just returns "found empty at 0, 0" and exits. I have viewed other code under this nature and cannot understand the answers given and need more elaboration on this specific code. Please Help grid = [["T", " ", "

How do I have a picture act as a game character on top of a canvas?

人走茶凉 提交于 2019-12-24 09:38:36
问题 I have a maze game in JAVA I'm doing for a class, the maze is made on a canvas in an applet, I wanted to have another picture provided to me (of a statue like thing) act as a game character and be able to be moved around the maze by the arrow keys, so how do I place an object on a canvas that can move around and be controlled, etc.? At the moment, the only way I could get my statue on the maze was by just copying the pixels of the picture onto the maze, so it's just part of the background now

Simplest way to solve a maze without mutability

夙愿已清 提交于 2019-12-24 08:34:53
问题 After learning some Scala and the benefits of FP, I am reimplementing some of my previous CS assignments to better understand FP. However, I got to one assignment that seems impractical to implement with FP (or at least trivially translate). When solving a simple 2D maze it is necessary to remember which nodes have been visited. However, without shared state, how can each recursive call know what nodes the other recursive calls have examined? I could pass the maze as a parameter to each

solving a maze using the left hand rule

拈花ヽ惹草 提交于 2019-12-24 07:11:01
问题 i am trying to solve the maze using the left hand exit rule using the the below sudo code i have got it working mostly but i am having issues with making it choose a new direction when it hits a dead end and comes back(like in the case of a square whose top is true but left, bottom and right walls are false during the first phase my code correctly moves from say if entry was left to either of the 2 that is bottom or right but when it comes back it chooses the left direction and not the bottom

Breadth-first search on an 8x8 grid in Java

天大地大妈咪最大 提交于 2019-12-23 07:26:14
问题 What I'm trying to do is count how many moves it takes to get to the goal using the shortest path. It must be done using a breadth first search. I put the 8x8 grid into a 2d array which is filled with one of four chars, E for empty (can move into these spots), B for blocked (can't move here), R for robot (starting point), or G for goal. The algorithm had to check for movable spaces in the order up, left, right, then down, which I believe I've done correctly. After a node is checked it changes

Plotting an array in Python

夙愿已清 提交于 2019-12-22 18:28:47
问题 I'm trying to plot a generated array in Python. The array is generated from maze.txt as you can see below. The result is an array composed of only 0's and 1's where each 0 and 1 represents one grid square on the map. The 0's are boundaries, this can be black or any color for that matter, and the 1's are the path that has been navigated. Searching around I thought that matplotlib could accomplish what I'm trying to do but I'm not quite sure how to implement it. I'm very inexperienced with

Pathfinding in JavaFX

佐手、 提交于 2019-12-22 17:59:48
问题 I have created a maze game in JavaFX where a user can create their own maze and play it. The maze is built using buttons with CSS IDs depending on the 2-dimensional array the level is temporarily stored in. The problem arises with the next part of the project. I have created an algorithm which generates a random maze. In order for the level to be possible, I need to check if the maze is solvable (i.e. you can get from the start (0, 3) to the finish (6, 3)). I have created a separate project