Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Problem iterating linked/synchronised list on: 2004-05-05 15:02:40
Yes, this makes sense, I'm not getting the same error, anymore.

I'm getting a different error.

It's a out of bounds exception, which I'm working on, I'll come back if I have any other questions.

Thanks...
2  Game Development / Newbie & Debugging Questions / Re: Problem iterating linked/synchronised list on: 2004-05-05 13:35:24
None of the answers have helped me so far, I think this is as I haven't explained my problem fully. I'll explain my algorithim, hopefully this should clear up exactly what I'm trying to do.

I have 3 lists - a near, far and known list.
The goal node is in the known list. (it's 'travel time' is known.)
all other nodes in the far list.
1.I add the nodes surrounding the goal node into the near list, removing from far list.
2.I take the first node in the near list, add the surrounding nodes of that to the end of the near list, removing from far.
3.I perform maths on this node until it's travel time is known.
4.I add this node to the known list, removing from near.
5. I then go back to stage 2 until the near list is empty (far list will also be empty, known list will be full).

As you can see I'm trying to iterate through a near list who's size is constantly changing. What can I do?
3  Game Development / Newbie & Debugging Questions / Re: Problem iterating linked/synchronised list on: 2004-05-05 00:19:24
Hmm, okay, can you give me some example code of that? Using the code I've given - say iterate a near list while adding and removing things from it, if you know what I mean.
4  Game Development / Newbie & Debugging Questions / Problem iterating linked/synchronised list on: 2004-05-04 23:11:50
Hello, I'm working on a project to perform a fast march algorithm in Java (finds the optimum path through a map from any point on the map to a goal) and I'm having a terrible old time trying to get my lists to be iterated correctly. I believe this is to do with the fact that I am attempting to alter the size of the list while I iterate it. I therefore thought I would have to use synchronised lists, which I am attempting to use but which don't change my runtime errors at all. Some example code of my problem I have listed below, the line where I get a java.util.ConcurrentModificationException is in bold. If I get this working I'll share the Fast March algorithim code here, I don't know if it's of any use to anyone, but it's an interesting piece of AI, anyway.


Quote

   private java.util.List near;
   private java.util.List far;
   private java.util.List known;
   terrain curr;

       near = Collections.synchronizedList(new LinkedList());
       far = new LinkedList();
       known = new LinkedList();
       curr =new terrain();

       synchronized(near){
           ListIterator linear = near.listIterator(0);
           while ( linear.hasNext()) {
               curr = (terrain)linear.next();      // selects item within the list being iterated
               
             
               if(curr.pos.x != 0){
                   if(far.contains(map[curr.pos.x-1][curr.pos.y])){
                       near.add(map[curr.pos.x-1][curr.pos.y]);
                       far.remove(map[curr.pos.x-1][curr.pos.y]);
                   }
                   else if(known.contains(map[curr.pos.x-1][curr.pos.y])){
                       ux1= map[curr.pos.x-1][curr.pos.y];
                   }
               }
             
//Bunch of other checks would go here, and a whole bunch
// of maths, and finally the slowness of curr would be
//known, and we'd add it to the known list...

               known.add(curr);
           }
       }
   }

Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (51 views)
2014-04-15 18:08:23

BurntPizza (48 views)
2014-04-15 03:46:01

UprightPath (63 views)
2014-04-14 17:39:50

UprightPath (45 views)
2014-04-14 17:35:47

Porlus (62 views)
2014-04-14 15:48:38

tom_mai78101 (86 views)
2014-04-10 04:04:31

BurntPizza (146 views)
2014-04-08 23:06:04

tom_mai78101 (243 views)
2014-04-05 13:34:39

trollwarrior1 (202 views)
2014-04-04 12:06:45

CJLetsGame (209 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!