Re: Hash Table for self avoiding random walks

• To: mathgroup at smc.vnet.net
• Subject: [mg88460] Re: [mg88453] Hash Table for self avoiding random walks
• From: "W_Craig Carter" <ccarter at mit.edu>
• Date: Tue, 6 May 2008 06:37:35 -0400 (EDT)
• References: <200805051017.GAA08668@smc.vnet.net>

```Hello JM,

I may be misunderstanding your question completely, so I am sorry if
this suggestion is off target:

atrail := Module[{trail}, NestWhile[takeStep, {{{0, 0, 0}}, trail},
(Length[availableSteps[#]] > 0) &]]

Table[atrail,{4}]

>  As an aside, although there is no documentation for HashTable, doing

There is something, but not much, in the doc for Dispatch.  I am not
sure, but I don't think you will need to get to the guts of HashTable.

>  Can I make a bunch of things that work like hash tables without
>  polluting the global scope?
:
:
>  My primary complaint with this technique is that it seems to require
>  giving your hash table a name with global scope.  What if I want to
>  make 100 different walks?  Do I have to give them all separate names?
>  I guess I could do something like h[10][1,1] = True;, but then I
>  always have to keep track of which walk I'm working on.  I'd rather
>  just be able to let them all be anonymous and stick them in a list.
>
>  Any ideas?  Here's my current best effort:
>
>  neighborhood[n_] :=
>   With[{seed = ReplacePart[ConstantArray[0, n], 1 -> 1]},
>   Join[Permutations[seed], Permutations[-seed]]]
>
>  availableSteps[{points_, visitedFunction_}] :=
>   With[{steps = (Last[points] + #) & /@
>      neighborhood[Dimensions[points][[2]]]},
>   Select[steps, visitedFunction[#] =!= True &]]
>
>  takeStep[{points_, visitedFunction_}] :=
>   With[{newStep =
>     RandomChoice[availableSteps[{points, visitedFunction}]]},
>   visitedFunction[Last[points]] = True;
>   {Append[points, newStep], visitedFunction}]
>
>  Clear[trail];
>  {points, trail} =
>   NestWhile[
>    takeStep, {{{0, 0, 0}}, trail}, (Length[availableSteps[#]] > 0) &];
>
>  The part that I really don't like is the Clear[trail] part.
>

--
W. Craig Carter

```

• Prev by Date: Request for Collective Wisdom...
• Next by Date: Re: Re: Getting the size of the bounding box of a Graphics3D[]
• Previous by thread: Re: Hash Table for self avoiding random walks
• Next by thread: Re: Hash Table for self avoiding random walks