Do someone want to explain me (in pseudocode too) how the pathfinding/a* algorithm can be implemented in Python? I searched all over the internet but I am not able to understand how to calculate H-cost or G-cost. I found some source code, but it is too difficult for me (I am still a newbie).
Let's think I have a map like this:
'''
S0000000000000000000000000100000000000
00000000000000000000100000001000000000
10000111110101000001100000001000000000
01111100010001000010100000010000000000
00000100001111100100100001110000110000
00001100000001011000000100000001000000
00000100000000101000000000011110000001
00000010000000000111111111100000000011
00000001000000000000000001100000111100
00000000110000000000000000010011000000
00000000010000000001100000001000000000
00000000010000000000110000000111111000
00000000010000000000010000000000000000
00000000011000111111111111111111111111
000000000100000110000010000000000000E0
00000000001100000100001000000000000000
00000000000100000011000000000000000000
00000000000010000000000000000000000000
'''
Where 1s are obstacles, 'S' is the starting point and 'E' is the end.
How can I implement that algorithm? It would be great also if you can link an internet page who explain it in a easy way.
Related
So I would like to make a game where you control the character using your head with Python.
But, all of the tutorials I have found so far doesn't seem to be 2D. I just like to know the position of the face and its angle. Is there any tutorial/modules that can do this without too much coding?
The short answer is no, there is no way to do a generic head pose estimation in general. This is a nice tutorial on the subject which explains some of the current limitations and constraints. The biggest problem you will have is in getting a robust, diverse, well-sampled dataset in a variety of conditions suitable to your use case.
I am novice in Gurobi Language. I am trying to solve some LPs and MIPs using GurobiPy, so the approach I thought I would take was to look at some examples how to add constraints and all. But in the examples provided by Gurobi website, the actual documentation on how to add mathematical constraints to the model was like finding a needle in haystack. From my fellow seniors I would like to know how can I approach to learn to add constraints actually. Thank you. I already found some understanding, but there are things like sum( * , 1) etc which I don't really understand.
These tutorials can be a starting point:
https://www.gurobi.com/resource/abremod-getting-started-intro/
To get more help here on StackOverflow, please consider phrasing your question less broad and try to ask a specific question.
So i found a certain procedural map generator in Python and I understand parts of it but i'm having a very hard time piecing it together to be able to modify it to suite my needs so I was wondering if it is possible for someone to explain step by step what exactly the generator does. Overall I understand the concept but the way it is written makes it very hard for me to follow the math involved.
The generator is here and some explanations would be welcomed and probably help anyone else trying to learn procedural generation as this example honestly yields beautiful results.
First you must understand how Perlin Noise works.
I recommend you write your own Perlin Noise code, something minimal, then play a bit with it and see the results.
Then move on to more advanced techniques and variants.
Here for example the user has some settings which more or less control the output:
basePerlinValue = (snoise2(float(x)*perlinScale, float(y)*perlinScale, octaves=8, persistence=0.5, lacunarity=2.0, repeatx=2048, repeaty=2048, base=perlinOffset) + 1)/2.0;
Play with them and see how they affect the result.
Octaves is standard Perlin Noise stuff.
I've already posted it on robotics.stackexchange but I had no relevant answer.
I'm currently developing a SLAM software on a robot, and I tried the Scan Matching algorithm to solve the odometry problem.
I read this article :
Metric-Based Iterative Closest Point Scan Matching
for Sensor Displacement Estimation
I found it really well explained, and I strictly followed the formulas given in the article to implement the algorithm.
You can see my implementation in python there :
ScanMatching.py
The problem I have is that, during my tests, the right rotation was found, but the translation was totally false. The values of translation are extremely high.
Do you have guys any idea of what can be the problem in my code ?
Otherwise, should I post my question on the Mathematics Stack Exchange ?
The ICP part should be correct, as I tested it many times, but the Least Square Minimization doesn't seem to give good results.
As you noticed, I used many bigfloat.BigFloat values, cause sometimes the max float was not big enough to contain some values.
don't know if you already solved this issue.
I didn't read the full article, but I noticed it is rather old.
IMHO (I'm not the expert here), I would try bunching specific algorithms, like feature detection and description to get a point cloud, descriptor matcher to relate points, bundle adjustement to get the rototraslation matrix.
I myself am going to try sba (http://users.ics.forth.gr/~lourakis/sba/), or more specifically cvsba (http://www.uco.es/investiga/grupos/ava/node/39/) because I'm on opencv.
If you have enough cpu/gpu power, give a chance to AKAZE feature detector and descriptor.
I have made an array in python that generates 20 random numbers 50-100. I want to know how to sort the numbers in my array. I am in 8th grade and this is for my computing class. Can this even be done? My teacher mentioned some kind of sorting algorithm, but told me not to use sort(). I am using python. Thanks
this is what i have so far
from random import*
array = range(20)
for i in range(20):
array[i] = randint(50, 100)
print array
Since it's an homework I won't give you the solution, but a starting point http://en.wikipedia.org/wiki/Sorting_algorithm where you can find an introduction to sorting algorithms!
Just choose one and try to implement it! Then if you do something wrong you can ask for help ;)
Everyone has posted excellent answers. I want to point you to this page, because it has a set of good animations for various different sorting algorithms.
Good luck!
For educational purposes, this should be a good place to start: http://en.wikipedia.org/wiki/Bubble_sort It's not a very good sorting algorithm, but once you understand the principles you can move on to more advanced sorting algorithms (which you will probably learn in class eventually).
Essentially, you compare every element to the next one, and swap them if they are out of order. Continue doing this until your array is sorted. Good luck!
This can be done and there are a number of ways to do it, you need to implement your own sorting algorithm, examples of which are very easy to come accross.
I will point you towards a python implementation of one of these algorithms with excellent explanation but i strongly suggest you read up on this sort of stuff as it is the foundation of computer science imho.
go here for a python quicksort program.. but please do the work around it.
Also i have to reccommend Introduction to Algorithms by thomas h cormen which is an awesome book and took me through a lot of stuff, and I still look at it to this day. A word of warning on this book.. it is not a light read.
If you find all this a bit heavy I found a youtube clip which goes through bubble sort.