artificial intelligence - Why does A* path finding sometimes go in straight lines and sometimes diagonals? (Java) -


I am in the process of developing a simple 2G grid based sim game, and in finding a fully functional path.

I used the answer given in my previous question as a basis for implementing A * path search. ().

To show you what I'm actually asking for, I need to show you this video screen capture which I have created. I was just testing to see how the person would move in one place and come back again, and the result was ...

Path on the basis of direction Different options, an unintended consequence, any thoughts?

If you are looking for a simple-eye solution, can I suggest a little bit Randomness?

What do I mean: In the code code code example, there are nested-to-loops that generate "successor state" (to use AI word). I refer to the point where the "current" state is loop over 3x3 square around the state, to consider it, add new place on the heap.

There is a relatively simple improvement (should be done :)) bit, and say, before the processing step, generate a link list of nodes. Then the container.shuffle (or is this generic.Suffel?) Which is in the linked list, and continues processing there. In fact, one has to say regularly, "CreateNewEnghbours (node)" which gives a linkedlist = {(node.x-1, node.y), (node.x, node.i1) ... } (Please Pidgin java, I'm trying (and always fail) to be summarized.

Once you create a list of links, however, you just "for (node ​​n : MyNewLinkedList) must be enabled for x

  (int x = -1; x & lt; 2; x ++) {for (int y = - 1; y & lt; 2; y ++) { 

and still use the right body code. Yes!

What this will happen, ideally, it is believed that the sequence of nodes is like "shake", and make paths closer to diagonals, but to change without modifications. Even the most effective will be, but usually closer to the diagonal.

Negative side, of course, if you can get a different way, a different way. If If it is unacceptable, then you may have to consider a more substantial amendment.

Hope That it helps! -Agore


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -