maze

How do you make a simple 3x3 maze on python using lists?

懵懂的女人 提交于 2019-12-02 23:54:36
问题 I have this project wherein I have to make a basic text-based maze/adventure game. This is my code so far but it's weird. I want it to be able to quit anytime and for it to display 'Please choose an available direction' when the input is not among the choices. I know my code is wrong but I don't know what to do about it. Can someone help me out? Thanks! btw, I used this link as a guide http://programarcadegames.com/index.php?chapter=lab_adventure maze_list = [] maze = ['Available Directions:

490. The Maze

匿名 (未验证) 提交于 2019-12-02 22:59:29
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/BigFatSheep/article/details/84196153 ####问题描述 There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won’t stop rolling until hitting a wall. When the ball stops, it could choose the next direction. Given the ball’s start position, the destination and the maze, determine whether the ball could stop at the destination. The maze is represented by a binary 2D array. 1 means the wall and 0 means the empty space. You may assume that the borders of the maze are all walls.

水管工游戏

匿名 (未验证) 提交于 2019-12-02 21:53:52
原创 import java.util.*; public class 水管工游戏 { static int count=0; static int flag=0; static int n; static int m; static int maze[][]; static int book[][]; static ArrayList listx=new ArrayList(); static ArrayList listy=new ArrayList(); static void dfs(int x,int y,char way) { //way代表入水口 if(x==n-1 && y==m) { //成功判断 flag=1; return; } if(x<0 || x>n-1 || y<0 || y>m-1) { //越界判断 return; } if(maze[x][y]==0 || book[x][y]==1) { //树木与访问判断 return; } book[x][y]=1; listx.add(x); listy.add(y); count++; if(maze[x][y]==5 || maze[x][y]==6) { //直管 if(way=='l') { //左 dfs(x,y+1,'l'); } if(way=='r') { //右 dfs(x,y-1,'r

How to solve a basic maze using functions in python?

我怕爱的太早我们不能终老 提交于 2019-12-02 19:49:20
问题 I am trying to write a code that solves a basic maze made up of a list of lists with '#' symbolizing walls, '.' are free spaces, S is the start and E is the end. My algorithm consists of first checking to see if the space to the right is free, if not it then checks the space up, then down, and finally to the left. I also realize that this creates a problem if there is a dead end but I'll worry about that later. So far I have code that prints the list and finds the index value of the start

Why does my maze solver not work?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 16:06:12
问题 I'm trying to write a program that solves a specific inputted maze recursively and outputs it's position in the maze after each move. Whenever I try and run my code, it immediately crashes and I get a "maze.exe has stopped working" error. Why isn't my code working? #include <iostream> #include <stdio.h> using namespace std; const int MazeHeight = 12; const int MazeWidth = 16; char Maze[MazeHeight][MazeWidth + 1] = { {'S','.','.','.','.','#','.','.','.','#','.','.','.','.','.','.'}, {'#','#','

Recursive brute force maze solver Java

二次信任 提交于 2019-12-02 15:58:11
问题 In an attempt to write a brute force maze solving C program, I've written this java program first to test an idea. I'm very new to C and intend to convert it after getting this right in java. As a result, I'm trying stick away from arraylists, fancy libraries, and such to make it easier to convert to C. The program needs to generate a single width path of shortest steps to solve a maze. I think my problem may be in fragmenting a path-storing array passed through each recursion. Thanks for

How do you make a simple 3x3 maze on python using lists?

独自空忆成欢 提交于 2019-12-02 14:21:08
I have this project wherein I have to make a basic text-based maze/adventure game. This is my code so far but it's weird. I want it to be able to quit anytime and for it to display 'Please choose an available direction' when the input is not among the choices. I know my code is wrong but I don't know what to do about it. Can someone help me out? Thanks! btw, I used this link as a guide http://programarcadegames.com/index.php?chapter=lab_adventure maze_list = [] maze = ['Available Directions: East', None, 1, None, None] maze_list.append(maze) maze = ['Available Directions: East, South', None, 2

Variable change unexpectedly on recursion?

江枫思渺然 提交于 2019-12-02 13:48:13
问题 Context I'm currently attempting Reddit's /r/dailyprogrammer challenge. The idea is to find a solution to an ASCII maze. Unfortunately the recursion is working differently than I expected. The program checks if there is space to move to the right, left, below or above the current space. If there is then the space is moved to and the function is entered again with new co-ordinaries. This continues until the end is found. When the end is found the program exits. If a dead end is found then the

malloc error when trying to read a maze text file in C [closed]

烈酒焚心 提交于 2019-12-02 13:38:58
I'm trying to get my code to read from a text file that's contents involve: (text file is called maze1.txt) 5 5 %%%%% S % % % % % % E %%%%% However whenever I attempt to run the program I receive a segmentation fault which I think has something to do with how I'm using malloc. I know that I have use the first numbers in order to set boundaries for my array, but I'm unsure on how to do that. provided is my code: #include <stdio.h> #include <stdlib.h> #include "maze.h" maze_t * createMaze(char * fileName) { typedef struct Maze{ int cols, rows; char **charRow; }MAZE; struct Maze maze; FILE *pf;

How to solve a basic maze using functions in python?

☆樱花仙子☆ 提交于 2019-12-02 10:01:13
I am trying to write a code that solves a basic maze made up of a list of lists with '#' symbolizing walls, '.' are free spaces, S is the start and E is the end. My algorithm consists of first checking to see if the space to the right is free, if not it then checks the space up, then down, and finally to the left. I also realize that this creates a problem if there is a dead end but I'll worry about that later. So far I have code that prints the list and finds the index value of the start point which is (2,0). Basically what I am trying to do is take that starting value as the argument for my