Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  A-star 101  (Read 4278 times)
0 Members and 1 Guest are viewing this topic.
Offline jonask84

Senior Newbie




Can't make it? Simulate it!


« Posted 2005-03-29 11:19:17 »

Hey,
Im all new to this site, and to java, but i've been doing VB and C for many years.
anyways, im not that smart on OOP yet, and now i've convertet my VB a* algorthym to Java.
The thing is, i KNOW it's not very optimized, but i thought i'd share it. It's implemented in a sample here,

click space to find a path

all comments and corrections are welcome.
in fact, i hope someone can help me optimize it
ftp://http://www.stud.ntnu.no/~jonasas/astar.zip
Offline digitprop

Junior Member





« Reply #1 - Posted 2005-03-29 15:11:45 »

Thanks for the algorithm. I doubt that many will be willing to download the ZIP, open all java files and go through the complete algorithm (I certainly wasn't - sorry).

Maybe you could post a short section of your code where you expect potential for further optimization.

From a quick glance I had the impression that the code was a fairly straightforward implementation of the A* algorithm. One (rather formal) hint: Convention has it that method names begin with a lower case character.

M. Fischer . www.digitprop.com
Offline jonask84

Senior Newbie




Can't make it? Simulate it!


« Reply #2 - Posted 2005-03-31 09:24:07 »

oh, yeah, I see what youre saying...
Its alot of work to get into someones esles code.
But if there are any hard core nitpickers out there, bent on finding something to correct me on, they are still welcome to do so =)

Anyways, i'll keep that lovercase thing in mind, thanks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ralphdaugherty

Junior Newbie





« Reply #3 - Posted 2005-04-12 05:03:52 »


  Just curious. What do you mean you know it's not very optimized? How does it run compared to your VB code?

rd
Offline jonask84

Senior Newbie




Can't make it? Simulate it!


« Reply #4 - Posted 2005-04-12 19:06:52 »

I ment that I dont know much about java, and so Im sure people can improve on it. Thus optimizing it Smiley

BUT, one thing is peculiar. Yesterday i buildt an object oriented pathfinder, with a MUCH better algorythm. But it is 10 times slower than the VB-style code. i don't get it...
Offline ralphdaugherty

Junior Newbie





« Reply #5 - Posted 2005-04-12 20:56:43 »

  A different pathfinder algorithm than your first one? What is the difference between the two algorythms, as you call them?

rd
Offline jonask84

Senior Newbie




Can't make it? Simulate it!


« Reply #6 - Posted 2005-04-19 23:01:57 »

it's hard to explain, but ill try.
i made two algorythms. one is old, and not objectoriented. It is not a real astar and was originaly made for visual basic. i've convertet it to java.

The second is a full blooded A* (at least as far as i know) based on OPEN and CLOSED lists and whatnot. followed a tutorial to make it. it's short and sweet codewise.

BUT, for reasons unknows the old algorythm is about 10 times faster. now i know that you might think (after looking at the code) that the old algorythm just checks four direction while the new oo code cheks eight. but it should not make that much of a difference!

Controles for supplied app: 1,2 SPACE and ENTER

ftp://http://www.stud.ntnu.no/~jonasas/astar.zip
Offline victorf

Innocent Bystander




Java games rock!


« Reply #7 - Posted 2005-05-23 17:49:32 »

I cannot compile your code Sad
It gives me 29errors!
Offline Imxqm

Junior Newbie




Java games rock!


« Reply #8 - Posted 2005-05-30 15:24:54 »

public class Pathfinder2 {
   
   private ArrayList<Node2> board; //our nodes
   
I think it should be the C++ syntax but not java.
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #9 - Posted 2005-05-30 18:16:18 »

Quote
public class Pathfinder2 {
   
   private ArrayList<Node2> board; //our nodes
   
I think it should be the C++ syntax but not java.


That's Java 1.5, not C++

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Imxqm

Junior Newbie




Java games rock!


« Reply #10 - Posted 2005-05-31 12:33:14 »

Thx.
That's why I can't compile the codes. I'm using the 1.4 version. But the java 1.5 looks much like the C++.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (26 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (95 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42

Longarmx (39 views)
2014-09-07 01:12:14

Longarmx (45 views)
2014-09-07 01:11:22

Longarmx (41 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!