Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

Foxes and Rabbits project - help

Thread view: 
gremlin_dude@hotmail.com - 03 Jan 2006 14:01 GMT
Hi.  before i start with my problem, let me state one thing...i am not
very good at java programming, in fact, i would say i am useless at it.
Anywho, my problem is as follows:

I have to do a project for uni, and for this project we have been
instructed to modify and build upon the Foxes and Rabbits
(Predator/Prey) project(a quick search of google should find it).  I
have run into an obstacle though.  At the moment, the fox hunts for
food in adjacent locations to itself and eats only one rabbit adjacent
to itself.  We are required to modify this so that the fox eats all
rabbits adjacent to itself.  I have gone over the code that my tutor
said would need to be modified, and i can't see a way to do it.  Here
is the code that i think may need to be changed:

/**
    * Generate an iterator over a shuffled list of locations adjacent
    * to the given one. The list will not include the location itself.
    * All locations will lie within the grid.
    * @param location The location from which to generate adjacencies.
    * @return An iterator over locations adjacent to that given.
    */
   public Iterator adjacentLocations(Location location)
   {
       int row = location.getRow();
       int col = location.getCol();
       LinkedList locations = new LinkedList();
       for(int roffset = -1; roffset <= 1; roffset++)
       {
           int nextRow = row + roffset;
           if(nextRow >= 0 && nextRow < depth)
           {
               for(int coffset = -1; coffset <= 1; coffset++)
               {
                   int nextCol = col + coffset;
                   // Exclude invalid locations and the original
location.
                   if(nextCol >= 0 && nextCol < width && (roffset != 0
|| coffset != 0))
                   {
                       locations.add(new Location(nextRow, nextCol));
                   }
               }
           }
       }
       Collections.shuffle(locations,rand);
       return locations.iterator();
   }

This comes from the class Field.

Sorry if it makes no sense, but i haven't got long to finish this and i
am pulling my hair out....and this is only the beginning of the
problems.  lol.

Thanks
=============
gremlin_dude
Mike - 03 Jan 2006 15:23 GMT
> Hi.  before i start with my problem, let me state one thing...i am not
> very good at java programming, in fact, i would say i am useless at it.

I guess one of the reasons you take classes is to become good at things
you previously don't know much about. But you should start putting
extra effort in it sooner.

>  Anywho, my problem is as follows:
>
> I have to do a project for uni, and for this project we have been
> instructed to modify and build upon the Foxes and Rabbits
> (Predator/Prey) project(a quick search of google should find it).

So you want whoever is to help you to make an extra-special effort to
locate what might be your assignment and to bone up on it?

Dude, I can't wait to see what responses you are going to get!
gremlin_dude@hotmail.com - 03 Jan 2006 16:07 GMT
I didn't ask for sarcastic responses.  If you don't have anything of
any importance to say, don't say it.  Anyways, forget it, i'll figure
out my own problems myself
Roedy Green - 03 Jan 2006 16:22 GMT
>I didn't ask for sarcastic responses.  If you don't have anything of
>any importance to say, don't say it.  Anyways, forget it, i'll figure
>out my own problems myself
see http://mindprod.com/jgloss/homework.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

really_puzzled - 03 Jan 2006 16:44 GMT
I've had to do this as well and from what i have been told you are looking in
the wrong class. You should be looking in the findFood method in the fox.

Happy New Year Gremlin dude !

>Hi.  before i start with my problem, let me state one thing...i am not
>very good at java programming, in fact, i would say i am useless at it.
[quoted text clipped - 53 lines]
>=============
>gremlin_dude
gremlin_dude@hotmail.com - 03 Jan 2006 16:56 GMT
Thanks for the suggestions guys, I shall have another go at the project
tonight after work.

Happy new year to you too really_puzzled, and everyone else

=======
gremlin_dude
really_puzzled - 03 Jan 2006 16:58 GMT
Rock on Portsmouth and good luck because it isn't an easy piece of course
work if you are on the same thing i am !

>Thanks for the suggestions guys, I shall have another go at the project
>tonight after work.
[quoted text clipped - 3 lines]
>=======
>gremlin_dude
gremlin_dude@hotmail.com - 03 Jan 2006 17:03 GMT
I'm at portsmouth also, year 2 APADS...i'm guessing you're the same eh?
It Sucks!

lol

===========
gremlin_dude
gremlin_dude@hotmail.com - 03 Jan 2006 17:07 GMT
I have no idea also, actually, i saw your other post on the hunter
bit...you're further than me, i don't even know where to start on that.
I think i gonna have no luck with this unit this year

========
gremlin_dude
really_puzzled - 03 Jan 2006 17:14 GMT
It is really difficult....a great way to screw up Christmas !!

I now have to work out who gremlin dude really is !!!!!!

>I have no idea also, actually, i saw your other post on the hunter
>bit...you're further than me, i don't even know where to start on that.
> I think i gonna have no luck with this unit this year
>
>========
>gremlin_dude
gremlin_dude@hotmail.com - 03 Jan 2006 17:17 GMT
Work out who i am?  Muahahaha, big secret.  Maybe I shall reveal my
true identity when i get back online after work tonight....or maybe
not.  lol.

Have a good evening doing coursework, better than my evening.

===========
gremlin_dude
really_puzzled - 03 Jan 2006 17:02 GMT
Don't suppose you know how to add a hunter to the simulation ? This is where
I am completely snookered.

>Thanks for the suggestions guys, I shall have another go at the project
>tonight after work.
[quoted text clipped - 3 lines]
>=======
>gremlin_dude
gremlin_dude@hotmail.com - 04 Jan 2006 14:28 GMT
Hi really_puzzled,  I looked through the findFood method in fox, and i
cant see what would need changing, though i can perhaps see room for
change in the field class in public Iterator adjacentLocations(Location
location), tho maybe i am wrong.  How goes your progress with the
hunter bit?

============
gremlin_dude
really_puzzled - 04 Jan 2006 14:56 GMT
From what Topp told me it is defin the findFood method.

If you read the code carefully the findfood method returns the location after
each animal found(Eats 1 rabbit). But you need it to eat all rabbits so it is
this you need to change.

Given up trying on the hunter. Moved on to the saving/loading part now.

>Hi really_puzzled,  I looked through the findFood method in fox, and i
>cant see what would need changing, though i can perhaps see room for
[quoted text clipped - 4 lines]
>============
>gremlin_dude
gremlin_dude@hotmail.com - 04 Jan 2006 15:45 GMT
Ok, i'll re-check the method.  Thanks again.  I swear to god, after
this is over, i will NEVER look at java again.

If i come up with anything on the hunter, i'll let you know, but don't
hold your breath eh!  lol.

===========
gremlin_dude
Roedy Green - 04 Jan 2006 17:24 GMT
> I swear to god, after
>this is over, i will NEVER look at java again

What a great motivator for others to pour time into your education.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

gremlin_dude@hotmail.com - 04 Jan 2006 22:17 GMT
> > I swear to god, after
> >this is over, i will NEVER look at java again
[quoted text clipped - 3 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.

Be quiet
Andrew Thompson - 05 Jan 2006 01:05 GMT
>>>I swear to god, after
>>>this is over, i will NEVER look at java again
>>
>>What a great motivator for others to pour time into your education.
...
> Be quiet

..Feel free to to take your homework 'collaboration' to email.
(Be quiet).

I, and many others here who are interested in learning Java
OTOH, would value input from Roedy.

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew

gremlin_dude@hotmail.com - 05 Jan 2006 01:32 GMT
> >>>I swear to god, after
> >>>this is over, i will NEVER look at java again
[quoted text clipped - 8 lines]
> I, and many others here who are interested in learning Java
> OTOH, would value input from Roedy.

Hi again

I do value input from people, i just don't like it when people take
what i say and turn it round to use against me.  I said i would never
look at java again cos i don't really enjoy the language, i'll try and
get through it for now for the sake of uni, but i don't really see
myself using it in the future.  Anyhow, I do appreciate input and
advice from people, god knows i need it.  Anyways, sorry if i p***ed
some people off with my comments

================
gremlin_dude
Kent Paul Dolan - 05 Jan 2006 09:08 GMT
> I do value input from people, i just don't like it
> when people take what i say and turn it round to
[quoted text clipped - 3 lines]
> uni, but i don't really see myself using it in the
> future.

Funny, and I found myself unemployable after the dot
com crash for five years until I'd learned enough
Java on my own to get a temp-to-hire job doing Java,
to see if I still have enough programming skills to
be useful. At USD$30/hour to start, because Java is
a "hot job skill", that's a pretty nice risk for my
employer to take, and so far, things are going a bit
better than "okay", as I grind out about 150 lines
of working code a day. I'd say I'll definitely "see
myself using [Java] in the future".

As to the "hunter" thingie, well, what's a hunter,
but just another fox, only one who likes two kinds of
prey, both foxes and rabbits, and, maybe, I can't
see your assignment from here, can cover a larger
grid extent per turn?

You can probably pretty much cut and paste the fox
code with a few changed names to make a hunter, but
after you've used Java and object oriented
programming a bit, you'd be more likely to
_subclass_ the fox class, to make a hunter class.

Then its just a matter of distributing three kinds
of monsters on your grid, instead of two, at the
start of the run, and turning them loose to commit
mayhem.

FWIW

xanthian.
gremlin_dude@hotmail.com - 05 Jan 2006 09:54 GMT
Thanks Kent Paul Dolan, kinda makes sense when you think about it (the
hunter bit).  I might have a go at it later if i can get past the fox
eating habits bit.

I see your point about java being useful, i just don't get on with it
at the moment.  It's probably down to the fact that i like to work at
my own pace when learning something like a programming language, and
uni doesn't really offer the chance to learn at your own pace, you
kinda have to learn it all in a short time, but hey, everyone learns at
their own pace i guess.  

Thanks again

===============
gremlin_dude
ge0rge - 05 Jan 2006 19:17 GMT
...
> I see your point about java being useful, i just don't get on with it
> at the moment.  

Truth is some people never get to grips with programming. That's a fact
- so don't feel bad. I have many clever colleagues who hate programming
but are fantastic sysadmins and network experts. They talk in dotted
quads and home in network and systems problems while I am scratching my
head thinking what the fsck's going on here.

It's probably down to the fact that i like to work at
> my own pace when learning something like a programming language, and
> uni doesn't really offer the chance to learn at your own pace, you
> kinda have to learn it all in a short time, but hey, everyone learns at
> their own pace i guess.  

true. Keep talking to your college friends (but not on ng! bad
netiquette). There is always one of you ahead of the pack in some aspect
of the project. Sharing knowledge is that way is not cheating anybody
from their own work. Come here with the specific problem which you don't
understand or even a formulation of what concept is foxing you. An
unclear request for help does not go down well in any newsgroup. People
don't know what you are after and only get irritated by such vagueness.

Signature

You may be infinitely smaller than some things, but you're infinitely
larger than others.

gremlin_dude@hotmail.com - 11 Jan 2006 11:39 GMT
Hi people, just an update in case anybody is interested.  I finally
managed to sort out the fox eating habits, luckily my aunt knew someone
who knows a bit of java.  I can now work on the hunter part of the
simulation....well, and every other part of the coursework really!

===========
gremlin_dude
gremlin_dude@hotmail.com - 13 Jan 2006 20:25 GMT
Hi really_puzzled

Sorry to try messaging you on here but i don't know who you are to
speak to you at uni, nor do i know your email address.  Anyhow, how did
you get on with the save/retrieve function of the coursework?  All the
specification says is "Currently there is no mechanism to save or
retrieve the state of the simulation to file. Add this capability."
What kind of file does it have to save to?  I'm not asking for the
answer, but more a pointer in the right direction so that i can look up
saving and retrieving in java on google or something.

Thanks

=================
gremlin_dude


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.