path-finding

Understanding A* heuristics for single goal maze

旧城冷巷雨未停 提交于 2020-01-02 04:04:42
问题 I have a maze like the following: |||||||||||||||||||||||||||||||||||| | P| | ||||||||||||||||||||||| |||||||| | | || | | ||||||| || | | || | | | | |||| ||||||||| || ||||| | || | | | | || || | | || | | | | | |||| ||| |||||| | | | | | | | || |||||||| | | || | | |||||||| || || ||||| | || | || ||||||||| || | | |||||| ||||||| || |||||| | |||||| | |||| || | | | |||||| ||||| | || || ||||| | |||||| | ||||| || | | |||||| ||||||||||| || || | |||||||||| |||||| | |+ |||||||||||||||| | ||||||||||||||||||

Haskell - Calculating the shortest path using trees

旧街凉风 提交于 2020-01-01 07:11:09
问题 i am trying to write a code in haskell, that goes from point A, to point F, on a board game, that is essentially a Matrix, following the shortest path. This is the board: AAAA ACCB ADEF * 0 0 N The robot enters on the letter A, on the bottom (where it is the * ), and must reach F, on the bottom of the board are the coordinates, x=0, y=0, and pointing towards North. F coordinate is (3,0) The trick is, it can't jump more than one letter, it can go from A to B, B to C, etc. and it can walk

How can I can I detect the shortest path from point A to point B without going through the obstacles?

折月煮酒 提交于 2020-01-01 06:42:06
问题 I've been trying to create a jQuery code that would scan a div with the id map and .map everything within it, and find the shortest path from #A to #B while trying to avoid crossing/touching the #blockings , but I'm clueless on how to do the latter. Any help is profusely appreciated. Illustration: Here's my code : computeTrack('#a','#b', '#map'); function computeTrack(A, B, MAP){ var bag = []; var obstacle = []; bag = getDistance(A, B); obstacle = scanning(A, B, MAP); moveAtoB(A, B, MAP,

Java object movement

做~自己de王妃 提交于 2019-12-29 09:35:31
问题 I am trying to get a circle to move through the input of a keyboard. I am not able to move the object at all. Can someone help me figure out what is wrong? Here is my code: import java.awt.Color; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JPanel; public class AlienInvader extends JPanel implements KeyListener{ Constants constant = new Constants(); public void update() { constant.x += constant.xvel; addKeyListener(this); }

Have trouble with obstacle avoidance in matplotlib

感情迁移 提交于 2019-12-25 05:02:04
问题 I am trying to produce an algorithm where multiple agents (blue) work together as a team to capture a slightly faster enemy agent (red) by preforming surrounding and circling tactics in a 2D grid (so there is no graph or nodes and implement algorithms like A*). So I am trying to make a robust multi-agent algorithm that would allow multi-agents would capture an intelligent and faster enemy agent However, the enemy agent (red) would just head towards the exit and run into the agents (blue)

How to calculate the highest score when taking a path through a grid?

时间秒杀一切 提交于 2019-12-24 04:49:19
问题 We have a 3x3 grid with the following values: 1 3 4 7 2 1 4 1 8 A person starts on the leftmost column and can then move either northeast, east or southeast. Now I have to find the optimal path through this grid. The starting point can be anywhere on the leftmost column. In this case the answer was 17 because the optimal path was 7->2->8. I would like to know how to compute this optimal path and how to compute it for larger grids. Thanks! 回答1: You can solve this problem with a bottom-up

GameplayKit > Scene Editor Navigation Graph > How to use it for pathfinding?

对着背影说爱祢 提交于 2019-12-23 19:25:15
问题 Not long ago, Apple introduced GameplayKit elements to Xcode's Scene Editor, which is great. However, I seem to have issues with the Navigation Graph element: What I try to achieve is to draw a GKGraph from the Scene Editor, retrieve it in code, and use it as a base for pathfinding. So I draw a GKGraph first: Then I retrieve it in GameScene.swift like this: graph = self.graphs.values.first where graphs is a predefined array by Apple to store the GKGraphs from the Scene Editor. So far so good.

Pathfinding code produces unexpected results

不羁的心 提交于 2019-12-23 16:12:06
问题 First of all, excuse the bad title, but I don't know how to describe this in just one sentence... Given a grid with 3 kinds of fields, empty fields, walls and exits, I wrote a program that checks for every empty field, whether that field is "safe". A person walks through that grid, but can only walk non-diagonally and can't go through walls. The person, starting at one field, chooses one direction at random and starts walking that way. Once it hits a wall, it chooses a direction at random

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

How do I get the shortest route in a labyrinth?

好久不见. 提交于 2019-12-22 08:25:12
问题 I want to make a code giving the shortest route when given a labyrinth as a matrix. In this case, the matrix representation of this labyrinth is as follows. ## [,1] [,2] [,3] [,4] ## [1,] 2 0 0 0 ## [2,] 1 1 0 1 ## [3,] 0 1 0 0 ## [4,] 1 1 1 3 , where 0 denotes inaccessible points, 1 denotes accessible points. 2 denotes the starting point, and 3 denotes the destination. And, the desired result is this : c(4,1,4,4,1,1) , where 1 denotes East, 2 denotes North, 3 denotes West, and 4 denotes