(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 39007, 996] NotebookOptionsPosition[ 34955, 869] NotebookOutlinePosition[ 36540, 919] CellTagsIndexPosition[ 36220, 907] WindowFrame->Normal ContainsDynamic->True *) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Self-Avoiding Random Walks", "DemoTitle", CellChangeTimes->{ 3.35696210375764*^9, {3.3648196814258*^9, 3.36481968745453*^9}}, CellID->700863240], Cell["", "InitializationSection"], Cell[CellGroupData[{ Cell["", "ManipulateSection"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{ RowBox[{"SeedRandom", "[", "seed", "]"}], ";", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"i", "=", "0"}], ",", RowBox[{"nmax", "=", "max"}], ",", RowBox[{"pts", "=", RowBox[{"{", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], "}"}]}], ",", RowBox[{"moves", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}]}]}], "}"}], ",", RowBox[{ RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{"i", "<", "nmax"}], "&&", RowBox[{"Not", "@", RowBox[{"(", RowBox[{"And", "@@", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"pts", ",", "#"}], "]"}], "&"}], "/@", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"pts", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}], "+", RowBox[{"moves", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "4"}], "}"}]}], "]"}]}], ")"}]}], ")"}]}]}], ",", RowBox[{ RowBox[{"i", "++"}], ";", RowBox[{"AppendTo", "[", RowBox[{"pts", ",", RowBox[{"RandomChoice", "[", RowBox[{"Select", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"pts", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}], "+", RowBox[{"moves", "[", RowBox[{"[", "i", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "4"}], "}"}]}], "]"}], ",", RowBox[{ RowBox[{"Not", "@", RowBox[{"MemberQ", "[", RowBox[{"pts", ",", "#"}], "]"}]}], "&"}]}], "]"}], "]"}]}], "]"}]}]}], "]"}], ";", RowBox[{"Style", "[", RowBox[{ RowBox[{"Column", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Length", "[", "pts", "]"}], "-", "1"}], "<", "nmax"}], ",", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", RowBox[{ RowBox[{"Length", "[", "pts", "]"}], "-", "1"}], "]"}], "<>", "\"\< moves!!\>\""}], ",", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "nmax", "]"}], "<>", "\"\< moves\>\""}]}], "]"}], ",", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"Line", "@", "pts"}], ",", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "Large", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{".6", ",", ".74", ",", ".36"}], "]"}], ",", RowBox[{"Point", "[", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{".9", ",", ".42", ",", ".17"}], "]"}], ",", RowBox[{"Point", "[", RowBox[{"Last", "@", "pts"}], "]"}], ",", RowBox[{"PointSize", "[", "Medium", "]"}], ",", "Black", ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Point", "[", RowBox[{"pts", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "2", ",", RowBox[{ RowBox[{"Length", "[", "pts", "]"}], "-", "1"}]}], "}"}]}], "]"}]}], "}"}]}], ",", RowBox[{"ImagePadding", "\[Rule]", "30"}], ",", RowBox[{"ImageSize", "\[Rule]", RowBox[{"{", RowBox[{"500", ",", "500"}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}]}], "]"}]}], "}"}], ",", "Center"}], "]"}], ",", "\"\\"", ",", "14"}], "]"}]}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"max", ",", "1", ",", "45", ",", "1", ",", RowBox[{"ControlType", "\[Rule]", "None"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"max", ",", "1", ",", "\"\\""}], "}"}], ",", "1", ",", "1000", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"seed", ",", "10", ",", "\"\\""}], "}"}], ",", "1", ",", "1000000000", ",", "1"}], "}"}], ",", RowBox[{"AutorunSequencing", "\[Rule]", RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "25"}], "}"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{ 3.35757176568782*^9, 3.36481969855059*^9, {3.36482019466892*^9, 3.36482027798956*^9}, 3.36482282152556*^9, {3.36482322307039*^9, 3.36482322754471*^9}, {3.36482326087134*^9, 3.36482326470361*^9}, { 3.3649119680301*^9, 3.3649119682007*^9}, {3.3717883693303986`*^9, 3.371788373506789*^9}, {3.3717884261835213`*^9, 3.371788457928104*^9}, { 3.372452665925866*^9, 3.3724526661163387`*^9}, {3.3724527269875317`*^9, 3.3724527513781137`*^9}, {3.3724528552761774`*^9, 3.3724528795965843`*^9}, {3.381510730472496*^9, 3.38151075344553*^9}, { 3.3815112998011503`*^9, 3.3815113001516542`*^9}, {3.3815124183592663`*^9, 3.3815124245831146`*^9}}, CellID->1496021318], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`max$$ = 1, $CellContext`seed$$ = 10, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold[$CellContext`max$$], 1, 45, 1}, {{ Hold[$CellContext`max$$], 1, "max steps"}, 1, 1000, 1}, {{ Hold[$CellContext`seed$$], 10, "new walk"}, 1, 1000000000, 1}}, Typeset`size$$ = {500., {256.5, 263.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`max$6312$$ = 0, $CellContext`seed$6313$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`max$$ = 1, $CellContext`seed$$ = 10}, "ControllerVariables" :> { Hold[$CellContext`max$$, $CellContext`max$6312$$, 0], Hold[$CellContext`seed$$, $CellContext`seed$6313$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> (SeedRandom[$CellContext`seed$$]; Module[{$CellContext`i = 0, $CellContext`nmax = $CellContext`max$$, $CellContext`pts = {{0, 0}}, $CellContext`moves = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}}, While[ And[$CellContext`i < $CellContext`nmax, Not[ Apply[And, Map[MemberQ[$CellContext`pts, #]& , Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}]]]]], Increment[$CellContext`i]; AppendTo[$CellContext`pts, RandomChoice[ Select[ Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}], Not[ MemberQ[$CellContext`pts, #]]& ]]]]; Style[ Column[{ If[Length[$CellContext`pts] - 1 < $CellContext`nmax, StringJoin["STUCK in ", ToString[Length[$CellContext`pts] - 1], " moves!!"], StringJoin["free after ", ToString[$CellContext`nmax], " moves"]], Graphics[ Line[$CellContext`pts], Epilog -> { PointSize[Large], RGBColor[0.6, 0.74, 0.36], Point[{0, 0}], RGBColor[0.9, 0.42, 0.17], Point[ Last[$CellContext`pts]], PointSize[Medium], Black, Table[ Point[ Part[$CellContext`pts, $CellContext`i]], {$CellContext`i, 2, Length[$CellContext`pts] - 1}]}, ImagePadding -> 30, ImageSize -> {500, 500}, PlotRange -> All]}, Center], "Label", 14]]), "Specifications" :> {{$CellContext`max$$, 1, 45, 1, ControlType -> None}, {{$CellContext`max$$, 1, "max steps"}, 1, 1000, 1}, {{$CellContext`seed$$, 10, "new walk"}, 1, 1000000000, 1}}, "Options" :> {AutorunSequencing -> {{1, 25}}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{546., {316., 321.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->627048526] }, {2}]] }, Open ]], Cell[CellGroupData[{ Cell["", "ManipulateCaptionSection"], Cell["\<\ Trace a path by moving at random from one lattice point to another while avoiding previously visited points. These so-called \"self-avoiding random \ walks\" are used in numerous physical models including polymer chains, \ protein folding and Brownian motion.\ \>", "ManipulateCaption", CellChangeTimes->{ 3.35696210375764*^9, {3.36481972659119*^9, 3.36481980372287*^9}, { 3.36481988968734*^9, 3.36481995309915*^9}, {3.3648234586542*^9, 3.36482345897522*^9}, 3.36491214973385*^9, {3.3717888003619986`*^9, 3.371788861421629*^9}}, CellID->1044312921] }, Open ]], Cell[CellGroupData[{ Cell["", "ThumbnailSection"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`max$$ = 363, $CellContext`seed$$ = 309523810, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`max$$], 363}, 1, 45, 1}, {{ Hold[$CellContext`max$$], 363, "max steps"}, 1, 1000, 1}, {{ Hold[$CellContext`seed$$], 309523810, "new walk"}, 1, 1000000000, 1}}, Typeset`size$$ = {500., {256.5, 263.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`max$6367$$ = 0, $CellContext`seed$6368$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`max$$ = 363, $CellContext`seed$$ = 309523810}, "ControllerVariables" :> { Hold[$CellContext`max$$, $CellContext`max$6367$$, 0], Hold[$CellContext`seed$$, $CellContext`seed$6368$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> (SeedRandom[$CellContext`seed$$]; Module[{$CellContext`i = 0, $CellContext`nmax = $CellContext`max$$, $CellContext`pts = {{0, 0}}, $CellContext`moves = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}}, While[ And[$CellContext`i < $CellContext`nmax, Not[ Apply[And, Map[MemberQ[$CellContext`pts, #]& , Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}]]]]], Increment[$CellContext`i]; AppendTo[$CellContext`pts, RandomChoice[ Select[ Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}], Not[ MemberQ[$CellContext`pts, #]]& ]]]]; Style[ Column[{ If[Length[$CellContext`pts] - 1 < $CellContext`nmax, StringJoin["STUCK in ", ToString[Length[$CellContext`pts] - 1], " moves!!"], StringJoin["free after ", ToString[$CellContext`nmax], " moves"]], Graphics[ Line[$CellContext`pts], Epilog -> { PointSize[Large], RGBColor[0.6, 0.74, 0.36], Point[{0, 0}], RGBColor[0.9, 0.42, 0.17], Point[ Last[$CellContext`pts]], PointSize[Medium], Black, Table[ Point[ Part[$CellContext`pts, $CellContext`i]], {$CellContext`i, 2, Length[$CellContext`pts] - 1}]}, ImagePadding -> 30, ImageSize -> {500, 500}, PlotRange -> All]}, Center], "Label", 14]]), "Specifications" :> {{{$CellContext`max$$, 363}, 1, 45, 1, ControlType -> None}, {{$CellContext`max$$, 363, "max steps"}, 1, 1000, 1}, {{$CellContext`seed$$, 309523810, "new walk"}, 1, 1000000000, 1}}, "Options" :> {AutorunSequencing -> {{1, 25}}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{546., {316., 321.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->604497954] }, Open ]], Cell[CellGroupData[{ Cell["", "SnapshotsSection"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`max$$ = 300, $CellContext`seed$$ = 854497355, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`max$$], 300}, 1, 45, 1}, {{ Hold[$CellContext`max$$], 300, "max steps"}, 1, 1000, 1}, {{ Hold[$CellContext`seed$$], 854497355, "new walk"}, 1, 1000000000, 1}}, Typeset`size$$ = {500., {256.5, 263.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`max$6422$$ = 0, $CellContext`seed$6423$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`max$$ = 300, $CellContext`seed$$ = 854497355}, "ControllerVariables" :> { Hold[$CellContext`max$$, $CellContext`max$6422$$, 0], Hold[$CellContext`seed$$, $CellContext`seed$6423$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> (SeedRandom[$CellContext`seed$$]; Module[{$CellContext`i = 0, $CellContext`nmax = $CellContext`max$$, $CellContext`pts = {{0, 0}}, $CellContext`moves = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}}, While[ And[$CellContext`i < $CellContext`nmax, Not[ Apply[And, Map[MemberQ[$CellContext`pts, #]& , Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}]]]]], Increment[$CellContext`i]; AppendTo[$CellContext`pts, RandomChoice[ Select[ Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}], Not[ MemberQ[$CellContext`pts, #]]& ]]]]; Style[ Column[{ If[Length[$CellContext`pts] - 1 < $CellContext`nmax, StringJoin["STUCK in ", ToString[Length[$CellContext`pts] - 1], " moves!!"], StringJoin["free after ", ToString[$CellContext`nmax], " moves"]], Graphics[ Line[$CellContext`pts], Epilog -> { PointSize[Large], RGBColor[0.6, 0.74, 0.36], Point[{0, 0}], RGBColor[0.9, 0.42, 0.17], Point[ Last[$CellContext`pts]], PointSize[Medium], Black, Table[ Point[ Part[$CellContext`pts, $CellContext`i]], {$CellContext`i, 2, Length[$CellContext`pts] - 1}]}, ImagePadding -> 30, ImageSize -> {500, 500}, PlotRange -> All]}, Center], "Label", 14]]), "Specifications" :> {{{$CellContext`max$$, 300}, 1, 45, 1, ControlType -> None}, {{$CellContext`max$$, 300, "max steps"}, 1, 1000, 1}, {{$CellContext`seed$$, 854497355, "new walk"}, 1, 1000000000, 1}}, "Options" :> {AutorunSequencing -> {{1, 25}}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{546., {316., 321.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->469306637], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`max$$ = 25, $CellContext`seed$$ = 441798942, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`max$$], 25}, 1, 45, 1}, {{ Hold[$CellContext`max$$], 25, "max steps"}, 1, 1000, 1}, {{ Hold[$CellContext`seed$$], 441798942, "new walk"}, 1, 1000000000, 1}}, Typeset`size$$ = {500., {256.5, 263.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`max$6477$$ = 0, $CellContext`seed$6478$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`max$$ = 25, $CellContext`seed$$ = 441798942}, "ControllerVariables" :> { Hold[$CellContext`max$$, $CellContext`max$6477$$, 0], Hold[$CellContext`seed$$, $CellContext`seed$6478$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> (SeedRandom[$CellContext`seed$$]; Module[{$CellContext`i = 0, $CellContext`nmax = $CellContext`max$$, $CellContext`pts = {{0, 0}}, $CellContext`moves = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}}, While[ And[$CellContext`i < $CellContext`nmax, Not[ Apply[And, Map[MemberQ[$CellContext`pts, #]& , Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}]]]]], Increment[$CellContext`i]; AppendTo[$CellContext`pts, RandomChoice[ Select[ Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}], Not[ MemberQ[$CellContext`pts, #]]& ]]]]; Style[ Column[{ If[Length[$CellContext`pts] - 1 < $CellContext`nmax, StringJoin["STUCK in ", ToString[Length[$CellContext`pts] - 1], " moves!!"], StringJoin["free after ", ToString[$CellContext`nmax], " moves"]], Graphics[ Line[$CellContext`pts], Epilog -> { PointSize[Large], RGBColor[0.6, 0.74, 0.36], Point[{0, 0}], RGBColor[0.9, 0.42, 0.17], Point[ Last[$CellContext`pts]], PointSize[Medium], Black, Table[ Point[ Part[$CellContext`pts, $CellContext`i]], {$CellContext`i, 2, Length[$CellContext`pts] - 1}]}, ImagePadding -> 30, ImageSize -> {500, 500}, PlotRange -> All]}, Center], "Label", 14]]), "Specifications" :> {{{$CellContext`max$$, 25}, 1, 45, 1, ControlType -> None}, {{$CellContext`max$$, 25, "max steps"}, 1, 1000, 1}, {{$CellContext`seed$$, 441798942, "new walk"}, 1, 1000000000, 1}}, "Options" :> {AutorunSequencing -> {{1, 25}}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{546., {316., 321.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->229264779], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`max$$ = 1000, $CellContext`seed$$ = 505291006, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`max$$], 363}, 1, 45, 1}, {{ Hold[$CellContext`max$$], 363, "max steps"}, 1, 1000, 1}, {{ Hold[$CellContext`seed$$], 309523810, "new walk"}, 1, 1000000000, 1}}, Typeset`size$$ = {500., {256.5, 263.5}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = True, $CellContext`max$6367$$ = 0, $CellContext`seed$6368$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`max$$ = 363, $CellContext`seed$$ = 309523810}, "ControllerVariables" :> { Hold[$CellContext`max$$, $CellContext`max$6367$$, 0], Hold[$CellContext`seed$$, $CellContext`seed$6368$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> (SeedRandom[$CellContext`seed$$]; Module[{$CellContext`i = 0, $CellContext`nmax = $CellContext`max$$, $CellContext`pts = {{0, 0}}, $CellContext`moves = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}}, While[ And[$CellContext`i < $CellContext`nmax, Not[ Apply[And, Map[MemberQ[$CellContext`pts, #]& , Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}]]]]], Increment[$CellContext`i]; AppendTo[$CellContext`pts, RandomChoice[ Select[ Table[ Part[$CellContext`pts, -1] + Part[$CellContext`moves, $CellContext`i], {$CellContext`i, 1, 4}], Not[ MemberQ[$CellContext`pts, #]]& ]]]]; Style[ Column[{ If[Length[$CellContext`pts] - 1 < $CellContext`nmax, StringJoin["STUCK in ", ToString[Length[$CellContext`pts] - 1], " moves!!"], StringJoin["free after ", ToString[$CellContext`nmax], " moves"]], Graphics[ Line[$CellContext`pts], Epilog -> { PointSize[Large], RGBColor[0.6, 0.74, 0.36], Point[{0, 0}], RGBColor[0.9, 0.42, 0.17], Point[ Last[$CellContext`pts]], PointSize[Medium], Black, Table[ Point[ Part[$CellContext`pts, $CellContext`i]], {$CellContext`i, 2, Length[$CellContext`pts] - 1}]}, ImagePadding -> 30, ImageSize -> {500, 500}, PlotRange -> All]}, Center], "Label", 14]]), "Specifications" :> {{{$CellContext`max$$, 363}, 1, 45, 1, ControlType -> None}, {{$CellContext`max$$, 363, "max steps"}, 1, 1000, 1}, {{$CellContext`seed$$, 309523810, "new walk"}, 1, 1000000000, 1}}, "Options" :> {AutorunSequencing -> {{1, 25}}}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{546., {316., 321.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->145466696] }, Open ]], Cell["", "DetailsSection"], Cell[CellGroupData[{ Cell["", "ControlSuggestionsSection"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[True], Cell[" Resize Images"]}], "\"Click inside an image to reveal its orange resize frame.\\nDrag any of \ the orange resize handles to resize the image.\"", ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"ResizeImages"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Rotate and Zoom in 3D"]}], RowBox[{ "\"Drag a 3D graphic to rotate it. Starting the drag near the center \ tumbles\\nthe graphic; starting near a corner turns it parallel to the plane \ of the screen.\\nHold down \"", FrameBox[ "Ctrl", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" (or \"", FrameBox[ "Cmd", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" on Mac) and drag up and down to zoom.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"RotateAndZoomIn3D"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Drag Locators"]}], RowBox[{"\"Drag any locator (\"", GraphicsBox[ LocatorBox[ Scaled[{0.5, 0.5}]], ImageSize -> 20], "\", etc.) to move it around.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"DragLocators"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Create and Delete Locators"]}], RowBox[{"\"Insert a new locator in the graphic by holding down the \"", FrameBox[ "Alt", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" key\\nand clicking where you want it to be. Delete a locator by \ clicking it\\nwhile holding down the \"", FrameBox[ "Alt", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" key.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"CreateAndDeleteLocators"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[True], Cell[" Slider Zoom"]}], RowBox[{"\"Hold down the \"", FrameBox[ "Alt", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" key while moving a slider to make fine adjustments in the slider \ value.\\nHold \"", FrameBox[ "Ctrl", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" and/or \"", FrameBox[ "Shift", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" at the same time as \"", FrameBox[ "Alt", Background -> GrayLevel[0.9], FrameMargins -> 2, FrameStyle -> GrayLevel[0.9]], "\" to make ever finer adjustments.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"SliderZoom"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Gamepad Controls"]}], "\"Control this Demonstration with a gamepad or other\\nhuman interface \ device connected to your computer.\"", ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"GamepadControls"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Automatic Animation"]}], RowBox[{"\"Animate a slider in this Demonstration by clicking the\"", AdjustmentBox[ Cell[ GraphicsData[ "CompressedBitmap", "eJzzTSzJSM1NLMlMTlRwL0osyMhMLlZwyy8CCjEzMjAwcIKwAgOI/R/IhBKc\n\ /4EAyGAG0f+nTZsGwgysIJIRKsWKLAXGIHFmEpUgLADxWUAkI24jZs+eTaEt\n\ IG+wQKRmzJgBlYf5lhEA30OqWA=="], "Graphics", ImageSize -> {9, 9}, ImageMargins -> 0], BoxBaselineShift -> 0.1839080459770115, BoxMargins -> {{0., 0.}, {-0.1839080459770115, 0.1839080459770115}}], "\"button\\nnext to the slider, and then clicking the play button that \ appears.\\nAnimate all controls by selecting \"", StyleBox["Autorun", FontWeight -> "Bold"], "\" from the\"", AdjustmentBox[ Cell[ GraphicsData[ "CompressedBitmap", "eJyNULENwyAQfEySIlMwTVJlCGRFsosokeNtqBmDBagoaZjAI1C8/8GUUUC6\n\ 57h7cQ8PvU7Pl17nUav7oj/TPH7V7b2QJAUAXBkKmCPRowxICy64bRvGGNF7\n\ X8CctGoDSN4xhIDGGDhzFXwUh3/ClBKrDQPmnGXtI6u0OOd+tZBVUqy1xSaH\n\ UqiK6pPe4XdEdAz6563tx/gejuORGMxJaz8mdpJn7hc="], "Graphics", ImageSize -> {10, 10}, ImageMargins -> 0], BoxBaselineShift -> 0.1839080459770115, BoxMargins -> {{0., 0.}, {-0.1839080459770115, 0.1839080459770115}}], "\"menu.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"AutomaticAnimation"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[" Bookmark Animation"]}], RowBox[{ "\"See a prepared animation of this Demonstration by selecting\\n\"", StyleBox["Animate Bookmarks", FontWeight -> "Bold"], "\" from the\"", AdjustmentBox[ Cell[ GraphicsData[ "CompressedBitmap", "eJyNULENwyAQfEySIlMwTVJlCGRFsosokeNtqBmDBagoaZjAI1C8/8GUUUC6\n\ 57h7cQ8PvU7Pl17nUav7oj/TPH7V7b2QJAUAXBkKmCPRowxICy64bRvGGNF7\n\ X8CctGoDSN4xhIDGGDhzFXwUh3/ClBKrDQPmnGXtI6u0OOd+tZBVUqy1xSaH\n\ UqiK6pPe4XdEdAz6563tx/gejuORGMxJaz8mdpJn7hc="], "Graphics", ImageSize -> {10, 10}, ImageMargins -> 0], BoxBaselineShift -> 0.1839080459770115, BoxMargins -> {{0., 0.}, {-0.1839080459770115, 0.1839080459770115}}], "\"menu.\""}], ActionDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags->"BookmarkAnimation"] }, Open ]], Cell[CellGroupData[{ Cell["", "SearchTermsSection"], Cell["random", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.3735903917260528`*^9, 3.373590393587764*^9}}, CellID->118878636], Cell["walks", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.3735903941582885`*^9, 3.373590395549567*^9}}, CellID->46794863], Cell["self-avoiding", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.3735903959199076`*^9, 3.373590398842594*^9}}, CellID->56607625], Cell["lattice", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.3735904161885376`*^9, 3.37359041702931*^9}, { 3.373590469807822*^9, 3.373590469807822*^9}}, CellID->326341592], Cell["protein", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.3735904703283005`*^9, 3.373590473611318*^9}}, CellID->51330301], Cell["Brownian", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.373590474161824*^9, 3.373590476153655*^9}}, CellID->129180214] }, Open ]], Cell[CellGroupData[{ Cell["", "RelatedLinksSection"], Cell[TextData[ButtonBox["Self-Avoiding Walk", BaseStyle->"Hyperlink", ButtonData->{ URL["http://mathworld.wolfram.com/Self-AvoidingWalk.html"], None}]], "RelatedLinks", CellChangeTimes->{ 3.35696210375764*^9, {3.371788336491522*^9, 3.371788354502205*^9}}, CellID->166950258], Cell[TextData[ButtonBox["Self-Avoiding Walk Connective Constant", BaseStyle->"Hyperlink", ButtonData->{ URL["http://mathworld.wolfram.com/Self-AvoidingWalkConnectiveConstant.\ html"], None}]], "RelatedLinks", CellChangeTimes->{ 3.35696210375764*^9, {3.418765315765625*^9, 3.41876533328125*^9}}, CellID->34552782] }, Open ]], Cell[CellGroupData[{ Cell["", "AuthorSection"], Cell[TextData[{ "Contributed by: ", ButtonBox["Rob Morris", BaseStyle->"Hyperlink", ButtonData->{ URL["http://demonstrations.wolfram.com/author.html?author=Rob+Morris"], None}, ButtonNote-> "http://demonstrations.wolfram.com/author.html?author=Rob+Morris"] }], "Author", CellChangeTimes->{ 3.35696210375764*^9, {3.36481997805529*^9, 3.36481998171058*^9}, 3.36941100485575*^9}, CellID->7907054] }, Open ]] }, Open ]] }, WindowSize->{790, 824}, WindowMargins->{{40, Automatic}, {Automatic, 6}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (January 24, 2008)", StyleDefinitions->FrontEnd`FileName[{"Wolfram"}, "Demonstration.nb", CharacterEncoding -> "WindowsANSI"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "ResizeImages"->{ Cell[27354, 641, 310, 8, 22, "ControlSuggestions", CellTags->"ResizeImages"]}, "RotateAndZoomIn3D"->{ Cell[27667, 651, 677, 16, 22, "ControlSuggestions", CellTags->"RotateAndZoomIn3D"]}, "DragLocators"->{ Cell[28347, 669, 339, 11, 22, "ControlSuggestions", CellTags->"DragLocators"]}, "CreateAndDeleteLocators"->{ Cell[28689, 682, 636, 15, 22, "ControlSuggestions", CellTags->"CreateAndDeleteLocators"]}, "SliderZoom"->{ Cell[29328, 699, 842, 21, 22, "ControlSuggestions", CellTags->"SliderZoom"]}, "GamepadControls"->{ Cell[30173, 722, 303, 8, 22, "ControlSuggestions", CellTags->"GamepadControls"]}, "AutomaticAnimation"->{ Cell[30479, 732, 1411, 31, 22, "ControlSuggestions", CellTags->"AutomaticAnimation"]}, "BookmarkAnimation"->{ Cell[31893, 765, 881, 21, 22, "ControlSuggestions", CellTags->"BookmarkAnimation"]} } *) (*CellTagsIndex CellTagsIndex->{ {"ResizeImages", 35329, 880}, {"RotateAndZoomIn3D", 35437, 883}, {"DragLocators", 35546, 886}, {"CreateAndDeleteLocators", 35661, 889}, {"SliderZoom", 35774, 892}, {"GamepadControls", 35879, 895}, {"AutomaticAnimation", 35991, 898}, {"BookmarkAnimation", 36107, 901} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 154, 3, 74, "DemoTitle", CellID->700863240], Cell[747, 28, 33, 0, 156, "InitializationSection"], Cell[CellGroupData[{ Cell[805, 32, 29, 0, 188, "ManipulateSection"], Cell[CellGroupData[{ Cell[859, 36, 6382, 157, 70, "Input", CellID->1496021318], Cell[7244, 195, 3797, 80, 649, "Output", CellID->627048526] }, {2}]] }, Open ]], Cell[CellGroupData[{ Cell[11087, 281, 36, 0, 136, "ManipulateCaptionSection"], Cell[11126, 283, 573, 11, 52, "ManipulateCaption", CellID->1044312921] }, Open ]], Cell[CellGroupData[{ Cell[11736, 299, 28, 0, 168, "ThumbnailSection"], Cell[11767, 301, 3853, 80, 649, "Output", CellID->604497954] }, Open ]], Cell[CellGroupData[{ Cell[15657, 386, 28, 0, 138, "SnapshotsSection"], Cell[15688, 388, 3853, 80, 649, "Output", CellID->469306637], Cell[19544, 470, 3847, 80, 649, "Output", CellID->229264779], Cell[23394, 552, 3854, 80, 649, "Output", CellID->145466696] }, Open ]], Cell[27263, 635, 26, 0, 232, "DetailsSection"], Cell[CellGroupData[{ Cell[27314, 639, 37, 0, 108, "ControlSuggestionsSection"], Cell[27354, 641, 310, 8, 22, "ControlSuggestions", CellTags->"ResizeImages"], Cell[27667, 651, 677, 16, 22, "ControlSuggestions", CellTags->"RotateAndZoomIn3D"], Cell[28347, 669, 339, 11, 22, "ControlSuggestions", CellTags->"DragLocators"], Cell[28689, 682, 636, 15, 22, "ControlSuggestions", CellTags->"CreateAndDeleteLocators"], Cell[29328, 699, 842, 21, 22, "ControlSuggestions", CellTags->"SliderZoom"], Cell[30173, 722, 303, 8, 22, "ControlSuggestions", CellTags->"GamepadControls"], Cell[30479, 732, 1411, 31, 22, "ControlSuggestions", CellTags->"AutomaticAnimation"], Cell[31893, 765, 881, 21, 22, "ControlSuggestions", CellTags->"BookmarkAnimation"] }, Open ]], Cell[CellGroupData[{ Cell[32811, 791, 30, 0, 152, "SearchTermsSection"], Cell[32844, 793, 141, 3, 22, "SearchTerms", CellID->118878636], Cell[32988, 798, 139, 3, 22, "SearchTerms", CellID->46794863], Cell[33130, 803, 147, 3, 22, "SearchTerms", CellID->56607625], Cell[33280, 808, 191, 4, 22, "SearchTerms", CellID->326341592], Cell[33474, 814, 141, 3, 22, "SearchTerms", CellID->51330301], Cell[33618, 819, 141, 3, 22, "SearchTerms", CellID->129180214] }, Open ]], Cell[CellGroupData[{ Cell[33796, 827, 31, 0, 138, "RelatedLinksSection"], Cell[33830, 829, 287, 7, 22, "RelatedLinks", CellID->166950258], Cell[34120, 838, 321, 7, 22, "RelatedLinks", CellID->34552782] }, Open ]], Cell[CellGroupData[{ Cell[34478, 850, 25, 0, 136, "AuthorSection"], Cell[34506, 852, 421, 13, 22, "Author", CellID->7907054] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)