Thread: Ecosystem...

  1. #1
    Registered User
    Join Date
    Jan 2002


    I want to program an artificial ecosystem of sorts...

    starting small, just a 20x40 grid with 3 species.

    I have not yet really begun on the programming, but I have forseen a problem, and was hoping someone could help me out, or at least direct me towards what I should think of doing...

    alright here is an example...

    0 0 0 0 0 0 0 2 0
    0 0 0 0 0 0 0 0 0
    1 1 0 0 0 0 0 0 3
    1 1 1 0 0 0 0 0 0
    1 1 0 0 0 0 0 0 0

    0 = grass
    1 = water
    2 = character
    3 = house

    Now lets say I program the '2' to look for '1'(water) through just an easy checking system...right? now lets say I want to program it to take some of '1' to '3'(house). How would I do that? I dont want him to check the whole map for what he should already know is his house, and I also dont want him after he has found his house to have to once again search for the water which he should already know where it is.

    I hope that makes sense...

  2. #2
    Registered User
    Join Date
    Jan 2002
    Hmmm I was thinking maybe I could have a true/false flaggin system...

    when the character finds water it turns on the 'water true/false' flag...and then it save the coords...

    then when the character needs to find water it would check the coords it is at and the coords of the water...and with a little subtraction/addition it should get there...

    now the one thing do I get it to go to the nearest water hole?

  3. #3
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Heres a few things I would do:

    I'd set up a "memory" struct.
    struct sMemory{
        LOC_ID type;
        int x, y;
    Then Id have an array of memory. When ever I find a new location that is significant I store it in the memory array.

    When i want to go get water, Id run through my memory array to find a water id and its location(you could return every instance of water ID's into a smaller array, then use a proximity function to see wich location is closest to yours).

    When a resource is used up (a small pond perhaps) you can remove the memory of that location from your array.

    I hope this helps.
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  4. #4
    Registered User
    Join Date
    Jan 2002
    Ah yes, I was thinking something along the same lines, but sometimes I just need someone to say it...

    <<has trouble with brainfreezes~


  5. #5
    That's a cool idea for learning AI. I think I may try it some times.

Popular pages Recent additions subscribe to a feed