Ecosystem...

This is a discussion on Ecosystem... within the Game Programming forums, part of the General Programming Boards category; I want to program an artificial ecosystem of sorts... starting small, just a 20x40 grid with 3 species. I have ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    75

    Ecosystem...

    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...
    MSVC++~

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    75
    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 is...how do I get it to go to the nearest water hole?
    MSVC++~

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

    I'd set up a "memory" struct.
    Code:
    enum LOC_ID {LID_WATER,LID_FRUIT,LID_HOUSE,LID_'landmark'};
    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.
    c++->visualc++->directx->opengl->c++;
    (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
    Posts
    75
    Ah yes, I was thinking something along the same lines, but sometimes I just need someone to say it...

    <<has trouble with brainfreezes~

    thanks~

  5. #5
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    That's a cool idea for learning AI. I think I may try it some times.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21