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

    Langton's Ant (97-->)

    There was a recent interest in The Game of Life on the boards and a couple of us shared some of our work to show our ideas on the theory using Excel.

    One example of automata that I am interested in is Langtons Ant

    I have searched Google and have not found anything in Excel. Do any of you know or have heard of an Excel version of this model?
    Jerry

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

    Re: Langton's Ant (97-->)

    Here is a primitive version, without any bells and whistles.

    Set the fill color for cells to black or white in a pattern you like, then make the cell where the ant should start the active cell. Select Tools | Macro | Macros... and run LangtonsAnt. It will run until the ant bumps into an edge of the worksheet.

    Feel free to modify it any way you like.

  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: Langton's Ant (97-->)

    Hans

    Did you just write this? If you did, it is beatifully simple, thank you
    Jerry

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

    Re: Langton's Ant (97-->)

    I just wrote it in 20 minutes, that's why it's only a worksheet and code, without any interface.

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Langton's Ant (97-->)

    I see that Hans beat me as usual, but here is my version. The definition of this is incomplete. It does not specify which direction the ant starts in and what happens when the ant hits the side of the grid (my code stops). In the attached workbook, first select the cell you want to be the center of the grid and click on the button in the upper left corner.

    I slow my code down so you can see the ant move. If you want it to run fast, remove the Wait method from the end of the code.
    Legare Coleman

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Ankeny, Iowa, USA
    Posts
    298
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Langton's Ant (97-->)

    These are both very nice (Legare's and Hans' macros) Out of curiosity...

    When I hit Esc. during Legare's macro, the code speeds up. Does pressing the Esc. key cancel the wait in the code?

    Also, when I hit Esc a second time in Legare's macro, the macro ends, whereas if I press Esc during Hans' macro, it doesn't do anything. I'm curious as to why this is as well. Anyone have any ideas? Is it something in the code?

  7. #7
    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: Langton's Ant (97-->)

    Hi Legare

    It was worth the wait. A nice touch with the arrow to show direction. I shall be playing with this for a little while now <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

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

    Re: Langton's Ant (97-->)

    I don't know why, but apparently, pressing Esc in Legare's workbook cancels the wait period introduced by Application.Wait (Now() + (1 / 86400)).
    And in my code, the DoEvents strangely enough seems to disable the Esc key, although Ctrl+Break still works.
    Curious...

Posting Permissions

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