maze

I do not know why my nested for next loop is only going through one loop

孤者浪人 提交于 2019-12-13 03:41:57
问题 I am currently making a maze game on Visual Basic and I need to retrieve the colours for all of the pixels in the image. To do this I've made a nested for next loop - 1 for width and one for height, as the code iterates through both of the loops it will get the pixel colors of each pixel and place it inside a 2 dimensional array. The issue is it is only iterating through the length and not the width Here my code: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim

Python: solve “n-to-n” maze

人盡茶涼 提交于 2019-12-12 15:33:38
问题 I'm trying to write a script in python to solve a kind of maze with multiple starting points and multiple ending points. The correct path is obtained following straight lines from the starting point. For example a maze with 4 paths: At first I thought using the left-/right-hand rule but it does not make much sense due to the characteristics of the maze. I have tried making an algorithm to follow straight lines following 4 directions (up, down, left, right). What I have at the moment: from PIL

How to print the BFS path from a source to a target in a maze

房东的猫 提交于 2019-12-12 11:50:29
问题 I'm trying to implement the BFS in order to find the shortest path from a source to a target in a maze. The problem that I'm having is that I'm unable to print the path, it is printed with '*' in the maze, but how can I extract the path from the predecessors of the BFS without printing all the visited nodes? Here's my code for you to compile: #include <stdio.h> #include <stdlib.h> #include <string.h> struct coord{ //This is a struct I'll use to store coordinates int row; int col; }; //-------

Which Procedure we can use for Maze exploration BFS or DFS

孤者浪人 提交于 2019-12-12 08:55:56
问题 I know we can use DFS for maze exploration. But I think we can also use BFS for maze exploration. I'm little bit confused here because most of the books and articles that I've read had used DFS for this problem. What I think is that the Best Case time complexity of DFS will be better as compared to BFS. But Average and Worst Case time complexity will be same for both BFS & DFS and thats why we prefer DFS over BFS. Am I right or I'm having some misconception 回答1: They have similar running time

Maze collision detection with tiles AS3

天大地大妈咪最大 提交于 2019-12-12 01:12:23
问题 Hey guys so I created a maze with this code and I want to hitTest the walls but when i try something along the lines of if (mc.hitTestObject(tile)) it doesn't do anything. And I'm not sure why, here's the code : package { import flash.display.MovieClip; import flash.events.KeyboardEvent; import flash.events.Event; import flash.display.DisplayObject; public class Main extends MovieClip { private var mc:hero = new hero; private var tile:tile1 = new tile1; private var mcSpeed:uint = 5; private

A* pathfinding slow

浪子不回头ぞ 提交于 2019-12-11 20:05:38
问题 I am currently working on a A* search algorithm. The algorithm would just be solving text file mazes. I know that the A* algorithm is supposed to be very quick in finding the finish. Mine seems to take 6 seconds to find the path in a 20x20 maze with no walls. It does find the finish with the correct path it just takes forever to do so. If I knew which part of code was the problem I would just post that but I really have no idea what is going wrong. So here is the algorithm that I use... while

Maze shortest path using recursion

允我心安 提交于 2019-12-11 19:23:56
问题 First of all I want to note that I posted this same question before and did not found a right answer, so sorry for repeating question. Note that I am required to use recursion here. I am aware that shortest path is usually found using BFS, which is not recursive, but I need to know how can this be done recursively. I am working on a rouge game and one of my monsters behaves like this. In a maze, if monster can reach the player in 15 or less steps, it makes the most optimal move possible. In

Using the keyboard to move the character in a maze

拈花ヽ惹草 提交于 2019-12-11 17:30:15
问题 I have created a simple maze and I have no way to move the character to the objective. The maze is on a TKinter window so I don't know if that is stopping the code from running. I have tried using pynput, which has worked in a seperate program without a tkinter window running, so I dont get whats wrong at all. def level1(): x=1 startx = 1 objectivex = 10 y=1 starty=1 objectivey=10 val_in_row = [[0,1,2,3,4,5,6,7,8,9,10,11],[0,3,7,11],[0,1,5,7,8,9,11],[0,3,5,6,11],[0,2,4,7,9,10,11],[0,4,6,10,11

Prolog: Sort a list of tuples

二次信任 提交于 2019-12-11 13:21:10
问题 I'm having problems to sort a list consisting of tuples, imagine a maze with lines x columns, I get an initial position in the form of tuple: (top row, starting column) and also get a final position (end line, final column) and still get a list composed of elements that are tuples of the form: (direction, row, column), the direction can be, up down, the list is composed of the possible movements. and my predicate must return a list with the same elements that receives but ordered according to

Maze solver gets stuck in a loop at a dead-end

爷,独闯天下 提交于 2019-12-11 10:57:19
问题 I'm working in a Maze solver algorithm and everything is working fine until it hits a dead-end and gets stuck in a loop, like this. The problem seems to be that when it want to turn around there aint enough space for it so instead it makes another turn since it faces a wall in front and thus gets stuck in an endless loop. Here are the two codes I'm working with but the first one is the most relevant one. SimpleWindow is the main window where everything gets drawn etc, and the maze class is