This site requires JavaScript, please enable it in your browser!
Greenfoot back
iWin4Poland
iWin4Poland wrote ...

2013/7/8

Need help with concept

iWin4Poland iWin4Poland

2013/7/8

#
Hey everyone I'm trying to do my own changed version of the ant-scenario. It contains multiple ant-types which are responsible for different tasks and such as an over and underground. What causes me trouble is the task part. First of all I want to store the informations of the task when it is assigned to an ant to the ant object (Dont think it is a real problem) but afterwards i want to assign a que of tasks to the ant once it has a task such as walk to foodstorage,pick-up food,go to the queen, feed her and then make the task solved. I couldnt come up with a real effective idea of how to solve it so ideas and suggestions are very welcome. Also one problem (which i will leave for later) is the intelligent pathfinding. I looked it up and found the A* - algorithm. I did understand the concept of it however i couldnt make it work for myself by any means. As for now i am fine with that the ants walk through certain blocks. TL;DR Need help in storing information from one object to another and then this other should fall into an efficient que of tasks Thanks a lot in advance
danpost danpost

2013/7/8

#
Probably the best way to handle this is to make use of the List class. By keeping a list in the ant class to hold actions to be performed (the queue), you can perform each task one by one until the list is empty. When the list is not empty, perform the action listed first in the list. When each step is complete, remove that action from the front of the list. You can alter the list as required by removing or adding extra actions wherever you wish within the list (if needed).
iWin4Poland iWin4Poland

2013/7/9

#
Thanks a lot ive made it work! Another thing that got me worried is that the sound is getting bugged. The sound plays only once and this thing appears: Exception in thread "SoundStream:file:/Users/mataschak/Desktop/ANTS/sounds/broodHungry.mp3" java.lang.ArrayIndexOutOfBoundsException: 580 at javazoom.jl.decoder.LayerIIIDecoder.huffman_decode(LayerIIIDecoder.java:795) at javazoom.jl.decoder.LayerIIIDecoder.decode(LayerIIIDecoder.java:278) at javazoom.jl.decoder.LayerIIIDecoder.decodeFrame(LayerIIIDecoder.java:219) at javazoom.jl.decoder.Decoder.decodeFrame(Decoder.java:147) at greenfoot.sound.Mp3AudioInputStream.read(Mp3AudioInputStream.java:230) at greenfoot.sound.SoundStream.run(SoundStream.java:302) at java.lang.Thread.run(Thread.java:680) whats the cause ? Thanks a lot again in advance ?
danpost danpost

2013/7/9

#
You probably have some tags within the sound file that the streamreader does not like. Try saving the sound file without any tag information.
You need to login to post a reply.