Results 1 to 8 of 8
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Check a cell reference (97-->)

    I am writing an application that recreates Cellular Automaton. As you can see from the link it uses a grid concept and therefore I thought Excel would be a good structure to start on. My solution is an inverted version of the one you see in the link and utilises a function that uses two parameters, the "cell" to the left and the "cell" to the right (the parents), by comparing there values I can produce the desired result and place it in the cell directly below them

    Feeling happy that I had created this model I decided to progress the mathematics behind it and added a new rule, the rule of mutation. My idea was to say that if the parent, grand parent and great grand parent of a given cell were the same in either direction then the cell would "mutate" and create a different value. Getting stuck I created a function that uses 6 parameters, a bit cumbersome, but again worked and I got the desired result.

    Now to my question (phew)

    I would like to streamline this function so that it only uses two parameters ( the parents) and use the function to calculate the other 4 cells, I tried to use offset.value but got a circular reference, any ideas?
    Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check a cell reference (97-->)

    If you use SomeCell.Offset without arguments, you refer to SomeCell itself. Its "parents" are SomeCell.Offset(0, -1) and SomeCell.Offset(0, 1). Apart from that, it's impossible to comment without knowing more about the code.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Check a cell reference (97-->)

    Thanks Hans

    Better if I send you the files.

    automaton (version 1).xls is for your reference and uses two parameters in autom(Tleft,TRight) function

    automaton (version 2).xls uses six parameters in Autom(TLeft, TLeft1, Tleft2, TRight, TRight1, TRight2) function, this is the one I would like to clear up.


    There are various if statements set in the code which are the "Rules" the cells must react to. To change the cells you must only add values in nthe top row of the triangle "world" for version 1 they are X or O in the version 2 world you have X,O or M

    edited to add attachment
    Jerry

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Check a cell reference (97-->)

    A simple way would be to define the 2 references as ranges, then in the code define the variables. This preserves your current function as is.

    Function Autom(rLeft As Range, rRight As Range)
    TLeft = rLeft.Value
    TLeft1 = rLeft.Offset(-1, -1).Value
    Tleft2 = rLeft.Offset(-2, -2).Value
    TRight = rRight.Value
    TRight1 = rRight.Offset(-1, 1).Value
    TRight2 = rRight.Offset(-2, 2).Value

    'First step to create marriage between X and O
    'The rest of your code
    end function


    Steve

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Check a cell reference (97-->)

    Brilliant Steve

    I thought I was on the way with offset but hadn't thought about the range aspect of it. I'll try this at home tonight.

    Because of this my little mind is working ahead for another automaton, <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17> I know I have been called a geek lately but it can be quite enthralling when you create them <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check a cell reference (97-->)

    > I have been called a geek lately but it can be quite enthralling when you create them

    Do you mean that the Jezzaites are geeks already? <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Check a cell reference (97-->)

    Check out the Mr Excel page. It has in its "games and diversion section" a spreadsheet that does LIFE Simulation

    Steve

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Check a cell reference (97-->)

    Thanks Steve

    The Game of Life was my ultimate goal ands I was working towards doing it. I will have a look and adapt if necessary, it is always fun to change the rules, like I did in my version 2 automaton
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •