(* 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[ 418246, 8233] NotebookOptionsPosition[ 411247, 8095] NotebookOutlinePosition[ 413308, 8145] CellTagsIndexPosition[ 412972, 8133] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Sheep herding: A Real-Time Agent-Based Simulation", "DemoTitle", CellChangeTimes->{ 3.35696210375764*^9, {3.4130503574375*^9, 3.413050368390625*^9}, { 3.413051474703125*^9, 3.413051476765625*^9}, {3.413060574765625*^9, 3.413060578875*^9}, {3.7168870251341414`*^9, 3.7168870296185565`*^9}},ExpressionUUID->"44b6f269-55f1-4f10-a061-\ 3ce1be9d2d5c"], Cell[CellGroupData[{ Cell["", "InitializationSection",ExpressionUUID->"7b277819-e4c5-4e67-9f78-96c37a666050"], Cell[BoxData[{ RowBox[{ RowBox[{"AreaSize", " ", "=", " ", "150."}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"NumberOfSheep", "=", "46"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Shepherd", "=", "2."}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Sheep", "=", "1."}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Barn", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dummyPoint", "=", RowBox[{"{", RowBox[{ RowBox[{"-", "1."}], ",", RowBox[{"-", "1."}]}], "}"}]}], ";"}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.403283674203125*^9, 3.403283698984375*^9}, { 3.413062283015625*^9, 3.413062284125*^9}, {3.4130623660625*^9, 3.413062376828125*^9}, {3.4131001863125*^9, 3.413100190609375*^9}, { 3.413221055828125*^9, 3.413221057203125*^9}, {3.413222851015625*^9, 3.4132228525*^9}, {3.413223074015625*^9, 3.413223081828125*^9}, { 3.413223315171875*^9, 3.41322331828125*^9}, {3.716618413733998*^9, 3.7166184308864064`*^9}, {3.716618476923396*^9, 3.7166185957066164`*^9}, { 3.716618800366891*^9, 3.716618813421359*^9}, {3.7166998836695642`*^9, 3.716699893740735*^9}, {3.7167003562585983`*^9, 3.7167003577866874`*^9}, { 3.716705114155347*^9, 3.7167051313616104`*^9}, {3.716870997463032*^9, 3.716870998197385*^9}, {3.716882655137442*^9, 3.716882665110222*^9}, { 3.7168853509568987`*^9, 3.7168853544294004`*^9}, {3.7168853927274303`*^9, 3.7168854001794186`*^9}}, Magnification->1., CellID->12186613,ExpressionUUID->"b8020fbe-e5ad-4a98-9769-c018cf03144b"], Cell[BoxData[ RowBox[{"initialAgents", ":=", RowBox[{"Developer`ToPackedArray", "[", "\[IndentingNewLine]", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{"Join", "[", RowBox[{ RowBox[{"{", "Shepherd", "}"}], ",", " ", RowBox[{"(*", " ", "type", " ", "*)"}], "\[IndentingNewLine]", "Barn", ",", RowBox[{"(*", " ", "Location", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"AngleVector", "[", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "Pi"}], ",", "Pi"}], "}"}], "]"}], "]"}]}], " ", RowBox[{"(*", " ", "heading", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"{", "speed", "}"}], " ", "*)"}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Join", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", "Sheep", "}"}], ",", StyleBox["\[IndentingNewLine]", FontColor->GrayLevel[0]], RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"AreaSize", "/", "2."}], ",", "AreaSize"}], "}"}], ",", "2"}], "]"}], ",", RowBox[{"(*", " ", "Location", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"AngleVector", "[", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "Pi"}], ",", "Pi"}], "}"}], "]"}], "]"}]}], " ", RowBox[{"(*", " ", "heading", " ", "*)"}], "\[IndentingNewLine]", "]"}]}], "]"}], StyleBox[",", FontColor->GrayLevel[0]], StyleBox["\[IndentingNewLine]", FontColor->GrayLevel[0]], StyleBox[ RowBox[{"{", RowBox[{"i", ",", "0", ",", "NumberOfSheep"}], "}"}], FontColor->GrayLevel[0]]}], StyleBox["\[IndentingNewLine]", FontColor->GrayLevel[0]], "]"}], "\[IndentingNewLine]", "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.403283674203125*^9, 3.403283698984375*^9}, { 3.413062283015625*^9, 3.413062284125*^9}, {3.4130623660625*^9, 3.413062369828125*^9}, {3.413099385046875*^9, 3.413099400484375*^9}, { 3.413099431953125*^9, 3.413099435640625*^9}, {3.413221069765625*^9, 3.413221103875*^9}, {3.4132212468125*^9, 3.41322126115625*^9}, { 3.413222073734375*^9, 3.413222074203125*^9}, 3.413227762890625*^9, { 3.716615570587678*^9, 3.7166156046382117`*^9}, {3.7166156976467247`*^9, 3.716615785417512*^9}, {3.716615820886012*^9, 3.7166158628964043`*^9}, { 3.7166186047419662`*^9, 3.7166186624301963`*^9}, {3.716618700797364*^9, 3.716618769704587*^9}, {3.7166191083082795`*^9, 3.7166191392260413`*^9}, { 3.7166999069552984`*^9, 3.7166999132896824`*^9}, {3.716700300228281*^9, 3.7167003279807496`*^9}, {3.7167003644336843`*^9, 3.7167003678482027`*^9}, {3.7167020295166225`*^9, 3.7167020566723976`*^9}, {3.716708486632894*^9, 3.716708515130821*^9}, { 3.7168671689779253`*^9, 3.716867208959014*^9}, {3.7168676382868185`*^9, 3.716867649234378*^9}, {3.7168676815239105`*^9, 3.7168676835234404`*^9}, { 3.716867813956307*^9, 3.716867917932681*^9}, {3.7168679491713123`*^9, 3.7168679934854116`*^9}, {3.716871528513726*^9, 3.7168715473435616`*^9}, { 3.716876748129599*^9, 3.716876748426512*^9}, {3.7168767966754665`*^9, 3.7168767975504756`*^9}, {3.716884965107292*^9, 3.7168849689979553`*^9}, { 3.716885330131634*^9, 3.7168853372693076`*^9}, {3.716885372606339*^9, 3.716885379497065*^9}}, Magnification->1., CellID->179304614,ExpressionUUID->"1e27b3b2-a4ba-420b-9092-d643646fa5e6"], Cell[BoxData[ RowBox[{ RowBox[{"visualize", "[", RowBox[{"agents_", ",", "ra_", ",", "Pd_", ",", "Pc_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"shepherdsP", "=", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "Shepherd"}], ")"}], "&"}]}], "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"sheepP", "=", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"GCM", "=", RowBox[{"Mean", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"N", "=", RowBox[{"Length", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"furthestSheep", "=", RowBox[{ RowBox[{"SortBy", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], ",", " ", RowBox[{ RowBox[{"-", RowBox[{"Norm", "[", RowBox[{"#", "-", RowBox[{"Mean", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], "]"}]}], " ", "&"}]}], "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}], ",", "\[IndentingNewLine]", RowBox[{"dummyListP", "=", RowBox[{"{", "dummyPoint", "}"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Show", "[", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "barn"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"EdgeForm", "[", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"RGBColor", "[", RowBox[{"0.5", ",", "0.86", ",", "0.5"}], "]"}]}], "}"}], "]"}], ",", "White", ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"Barn", "-", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], ",", RowBox[{"Barn", "+", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "sheep"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"AbsolutePointSize", "[", "10", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{".9", ",", ".42", ",", ".17"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Point", "@", RowBox[{"If", "[", RowBox[{ RowBox[{"shepherdsP", "\[Equal]", RowBox[{"{", "}"}]}], ",", "dummyListP", ",", "shepherdsP"}], "]"}]}]}], "\[IndentingNewLine]", "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "shepherds"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"AbsolutePointSize", "[", "10", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{".48", ",", ".11", ",", ".56"}], "]"}], ",", RowBox[{"Opacity", "[", ".5", "]"}], ",", "\[IndentingNewLine]", RowBox[{"Point", "@", RowBox[{"If", "[", RowBox[{ RowBox[{"sheepP", "\[Equal]", RowBox[{"{", "}"}]}], ",", "dummyListP", ",", "sheepP"}], "]"}]}]}], "\[IndentingNewLine]", "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "GCM"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Locator", "[", "GCM", "]"}], "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "furthest", " ", "sheep"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"EdgeForm", "[", RowBox[{"{", RowBox[{"Thin", ",", "Dashed"}], "}"}], "]"}], ",", RowBox[{"FaceForm", "[", "]"}], ",", RowBox[{"Disk", "[", RowBox[{"GCM", ",", RowBox[{"ra", " ", SuperscriptBox["N", RowBox[{"2", "/", "3"}]]}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "driving", " ", "position"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{"furthestSheep", "-", "GCM"}], "]"}], "<", RowBox[{"ra", " ", SuperscriptBox["N", RowBox[{"2", "/", "3"}]]}]}], ",", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"EdgeForm", "[", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"RGBColor", "[", RowBox[{"0.91", ",", "0.5", ",", "0.13"}], "]"}]}], "}"}], "]"}], ",", "White", ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"GCM", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"GCM", "-", "Barn"}], "]"}], "Pd"}], "-", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], ",", RowBox[{"GCM", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"GCM", "-", "Barn"}], "]"}], "Pd"}], "+", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plotting", " ", "collecting", " ", "position"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"AbsolutePointSize", "[", "10", "]"}], ",", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0.14", ",", "0.15"}], "]"}], ",", RowBox[{"Point", "@", "furthestSheep"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"EdgeForm", "[", RowBox[{"{", RowBox[{"Thick", ",", RowBox[{"RGBColor", "[", RowBox[{"1", ",", "0.14", ",", "0.15"}], "]"}]}], "}"}], "]"}], ",", RowBox[{"FaceForm", "[", "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"furthestSheep", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"furthestSheep", "-", "GCM"}], "]"}], "Pc"}], "-", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], ",", RowBox[{"furthestSheep", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"furthestSheep", "-", "GCM"}], "]"}], "Pc"}], "+", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}]}], "]"}]}], "}"}]}], "]"}]}], "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"ImageSize", "\[Rule]", RowBox[{"{", RowBox[{"375", ",", "375"}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"AspectRatio", "\[Rule]", "Automatic"}], ",", "\[IndentingNewLine]", RowBox[{"Frame", "\[Rule]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"Axes", "\[Rule]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", ".5"}], " ", "AreaSize"}], ",", RowBox[{"1.5", " ", "AreaSize"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", ".5"}], " ", "AreaSize"}], ",", RowBox[{"1.5", "AreaSize"}]}], "}"}]}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.40328370721875*^9, 3.4032837329375*^9}, { 3.40353796284375*^9, 3.40353801059375*^9}, {3.40353804496875*^9, 3.403538066390625*^9}, {3.4130644830625*^9, 3.413064552640625*^9}, { 3.4130999793125*^9, 3.41309998003125*^9}, {3.4131000239375*^9, 3.413100025046875*^9}, {3.413118589519039*^9, 3.4131186158157454`*^9}, { 3.413221163671875*^9, 3.413221202890625*^9}, {3.4132212821875*^9, 3.4132213226875*^9}, {3.41322135325*^9, 3.413221386125*^9}, { 3.413221483109375*^9, 3.41322148471875*^9}, {3.413223089171875*^9, 3.413223090890625*^9}, 3.413227759421875*^9, {3.413228403471799*^9, 3.4132284198001328`*^9}, {3.413228467503868*^9, 3.4132284798790264`*^9}, { 3.7166187794654427`*^9, 3.7166187925174556`*^9}, {3.7166189896874533`*^9, 3.716619092840068*^9}, {3.7166999163532286`*^9, 3.7166999250092287`*^9}, { 3.7167002686432343`*^9, 3.716700293897396*^9}, {3.7167003745757275`*^9, 3.7167003927085447`*^9}, {3.7167008161627007`*^9, 3.7167009553993545`*^9}, {3.716877683614176*^9, 3.7168776888505273`*^9}, { 3.716881373098091*^9, 3.7168813788168955`*^9}, {3.7168814285975666`*^9, 3.7168814307538366`*^9}, {3.716881825536027*^9, 3.7168818279110518`*^9}, { 3.7168821598834653`*^9, 3.7168821755716915`*^9}, {3.716882265605967*^9, 3.7168823527644963`*^9}, {3.7168827269931135`*^9, 3.7168827317118716`*^9}, {3.7168829585979896`*^9, 3.7168830719295645`*^9}, {3.7168831133208113`*^9, 3.7168831225240235`*^9}, {3.7168831579899793`*^9, 3.716883196042617*^9}, { 3.7168833304648094`*^9, 3.7168833521213255`*^9}, {3.7168834208364253`*^9, 3.716883480673769*^9}, {3.7168835629823523`*^9, 3.7168836881275654`*^9}, { 3.7168837266980867`*^9, 3.716883727010599*^9}, {3.7168837919792447`*^9, 3.7168838068846974`*^9}, 3.7168838669750533`*^9, {3.7168838978502846`*^9, 3.7168840797702994`*^9}, {3.7168842139595428`*^9, 3.716884280064247*^9}, { 3.7168843534981585`*^9, 3.716884379785063*^9}, {3.716884415115986*^9, 3.716884416735182*^9}, {3.7168844520106654`*^9, 3.716884476925865*^9}, { 3.7168845512132387`*^9, 3.7168845728280373`*^9}, {3.7168846202972965`*^9, 3.7168846259536033`*^9}, {3.7168847025038505`*^9, 3.7168847472076225`*^9}}, CellID->581179032,ExpressionUUID->"59792d06-c410-4b43-8870-b43da934ab42"], Cell[BoxData[ RowBox[{ RowBox[{"updateAgents", "[", RowBox[{ "agents_", ",", "n_", ",", "rs_", ",", " ", "ra_", ",", "\[Rho]a_", ",", "c_", ",", " ", "\[Rho]s_", ",", " ", "h_", ",", " ", "e_", ",", " ", "\[Delta]_", ",", " ", "p_", ",", "\[Delta]s_", ",", "Pd_", ",", "Pc_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"N", "=", RowBox[{"Length", "[", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"nearestSheep", "=", RowBox[{"Nearest", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"nearestShepherd", "=", RowBox[{"Nearest", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Shepherd"}], ")"}], "&"}]}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"GCM", "=", RowBox[{"Mean", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"furthestSheep", "=", RowBox[{ RowBox[{"SortBy", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], ",", " ", RowBox[{ RowBox[{"-", RowBox[{"Norm", "[", RowBox[{"#", "-", RowBox[{"Mean", "[", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ")"}], "&"}]}], "]"}]}], "]"}]}], "]"}]}], " ", "&"}]}], "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}], ",", "\[IndentingNewLine]", "i", ",", "Ai", ",", "Hi", ",", "\[Delta]i", ",", "\[Epsilon]i", ",", "Ria", ",", "Ris", ",", "Ci", ",", "metricNeighbours", ",", "topologicNeighbours", ",", "\[Xi]", ",", "LCMi", ",", "Di", ",", "Ain", ",", "Hin"}], "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Developer`ToPackedArray", "[", "\[IndentingNewLine]", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Ai", "=", RowBox[{"agents", "\[LeftDoubleBracket]", RowBox[{"i", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "\[RightDoubleBracket]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Hi", "=", RowBox[{"agents", "\[LeftDoubleBracket]", RowBox[{"i", ",", RowBox[{"{", RowBox[{"4", ",", "5"}], "}"}]}], "\[RightDoubleBracket]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Hin", "=", "Hi"}], ";", "\[IndentingNewLine]", RowBox[{"Ain", "=", "Ai"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{"GCM", "-", "Barn"}], "]"}], ">", "2"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"task", " ", "not", " ", "completed"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"agents", "\[LeftDoubleBracket]", RowBox[{"i", ",", "1"}], "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"sheep", "'"}], "s", " ", "behavior"}], " ", "*)"}], " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Epsilon]i", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ria", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ris", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ci", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Delta]i", "=", "\[Delta]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"metricNeighbours", "=", RowBox[{ RowBox[{ RowBox[{"Take", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"2", ",", "3"}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Select", "[", RowBox[{"agents", ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[Equal]", "Sheep"}], " ", "&"}], " ", RowBox[{"Norm", "[", RowBox[{"Ai", "-", RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}], "]"}]}], "<", "ra"}], " ", ")"}], "&"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "@", "metricNeighbours"}], ">", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"Ria", "=", RowBox[{"Normalize", "[", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ "metricNeighbours", "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}], "-", "Ai"}], ")"}], "/", RowBox[{"Norm", "[", RowBox[{ RowBox[{ "metricNeighbours", "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}], "-", "Ai"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"Length", "@", "metricNeighbours"}]}], "}"}]}], "]"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{ RowBox[{"nearestShepherd", "[", "Ai", "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "-", "Ai"}], "]"}], ">", "rs"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"random", " ", "grazing"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"RandomReal", "[", "]"}], "<", "p"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Xi]", "=", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "Pi"}], ",", " ", "Pi"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Epsilon]i", "=", RowBox[{"AngleVector", "[", "\[Xi]", "]"}]}], ";"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Delta]i", "=", "0"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"nearestShepherd", " ", "<", " ", "rs"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Ris", "=", RowBox[{"Normalize", "[", RowBox[{"Ai", "-", RowBox[{ RowBox[{"nearestShepherd", "[", "Ai", "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"topologicNeighbours", "=", RowBox[{"nearestSheep", "[", RowBox[{"Ai", ",", "n"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "@", "topologicNeighbours"}], ">", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"LCMi", "=", RowBox[{"Mean", "[", "topologicNeighbours", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ci", "=", RowBox[{"Normalize", "[", RowBox[{"LCMi", "-", "Ai"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Hin", "=", RowBox[{"Normalize", "[", RowBox[{ RowBox[{"h", " ", "Hi"}], "+", RowBox[{"c", " ", "Ci"}], "+", RowBox[{"\[Rho]a", " ", "Ria"}], "+", RowBox[{"\[Rho]s", " ", "Ris"}], "+", RowBox[{"e", " ", "\[Epsilon]i"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ain", "=", RowBox[{"Ai", "+", RowBox[{"\[Delta]i", " ", "Hin"}]}]}], ";"}], ",", "\[IndentingNewLine]", " ", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"shepherds", "'"}], " ", "behavior"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Ci", "=", "Hi"}], ";", RowBox[{"(*", " ", RowBox[{"heading", " ", "for", " ", "collecting"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Di", "=", "Hi"}], ";", RowBox[{"(*", " ", RowBox[{"heading", " ", "for", " ", "driving"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"\[Epsilon]i", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Delta]i", "=", "\[Delta]s"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "random", " ", "noise", " ", "to", " ", "match", " ", "sheep", " ", "random", " ", "noise"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"RandomReal", "[", "]"}], "<", "p"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Xi]", "=", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "Pi"}], ",", " ", "Pi"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Epsilon]i", "=", RowBox[{"AngleVector", "[", "\[Xi]", "]"}]}], ";"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{ RowBox[{"nearestSheep", "[", "Ai", "]"}], "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "-", "Ai"}], "]"}], "<", RowBox[{"3", "ra"}]}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"too", " ", "close", " ", "to", " ", "anyone"}], ",", " ", "stop"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Delta]i", "=", "0"}], ";"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"sheep", " ", "packed"}], ",", " ", RowBox[{"drive", " ", "them"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{"furthestSheep", "-", "GCM"}], "]"}], "<", RowBox[{"ra", " ", SuperscriptBox["N", RowBox[{"2", "/", "3"}]]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"Di", "=", RowBox[{ RowBox[{"(", RowBox[{"GCM", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"GCM", "-", "Barn"}], "]"}], "Pd"}]}], ")"}], "-", "Ai"}]}], ";"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"sheep", " ", "dispersed"}], ",", " ", RowBox[{"collect", " ", "them"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Ci", "=", RowBox[{ RowBox[{"(", RowBox[{"furthestSheep", "+", RowBox[{ RowBox[{"Normalize", "[", RowBox[{"furthestSheep", "-", "GCM"}], "]"}], "Pc"}]}], ")"}], "-", "Ai"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Hin", "=", RowBox[{"Normalize", "[", RowBox[{ RowBox[{"h", " ", "Hi"}], "+", "Ci", "+", "Di", "+", RowBox[{"e", " ", "\[Epsilon]i"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Ain", "=", RowBox[{"Ai", "+", RowBox[{"\[Delta]i", " ", "Hin"}]}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Join", "[", RowBox[{ RowBox[{"{", RowBox[{"agents", "\[LeftDoubleBracket]", RowBox[{"i", ",", "1"}], "\[RightDoubleBracket]"}], "}"}], ",", "Ain", " ", ",", "Hin"}], "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "agents", "]"}]}], "}"}]}], "\[IndentingNewLine]", "]"}], "]"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.403283750546875*^9, 3.403283802375*^9}, { 3.41306236253125*^9, 3.413062402359375*^9}, {3.41306255884375*^9, 3.41306255965625*^9}, {3.41306268046875*^9, 3.413062707390625*^9}, { 3.41306273803125*^9, 3.413062805484375*^9}, {3.41306293971875*^9, 3.413062963265625*^9}, {3.413099488609375*^9, 3.413099542859375*^9}, { 3.413099590421875*^9, 3.413099700265625*^9}, {3.41310020765625*^9, 3.413100225046875*^9}, {3.413100415375*^9, 3.41310044275*^9}, { 3.41322154271875*^9, 3.41322158865625*^9}, {3.413221657125*^9, 3.413221662265625*^9}, {3.4132216996875*^9, 3.413221888265625*^9}, { 3.413221924609375*^9, 3.413222011984375*^9}, {3.4132221054375*^9, 3.413222121390625*^9}, {3.4132225985625*^9, 3.413222603375*^9}, { 3.413222665109375*^9, 3.413222835875*^9}, {3.41322293215625*^9, 3.413222952546875*^9}, {3.41322301365625*^9, 3.413223068125*^9}, { 3.413223235265625*^9, 3.413223235640625*^9}, {3.413224105453125*^9, 3.413224137109375*^9}, {3.41322416878125*^9, 3.413224274625*^9}, { 3.413224376765625*^9, 3.413224500703125*^9}, {3.413224658015625*^9, 3.413224735515625*^9}, {3.413226205375*^9, 3.413226239234375*^9}, 3.41322775375*^9, 3.41322783728125*^9, {3.716700960465357*^9, 3.7167010939900684`*^9}, {3.716701130017996*^9, 3.7167011456174774`*^9}, { 3.716701182507177*^9, 3.716701238358827*^9}, {3.716701326012717*^9, 3.7167014649629693`*^9}, {3.71670150839554*^9, 3.716701527138402*^9}, { 3.7167015837514114`*^9, 3.716701595537878*^9}, {3.716701686003957*^9, 3.7167017030626793`*^9}, {3.716701741718155*^9, 3.7167019615953465`*^9}, { 3.7167020088811193`*^9, 3.7167020156249895`*^9}, {3.716702066461585*^9, 3.7167020975294285`*^9}, {3.7167021281724663`*^9, 3.716702345181368*^9}, { 3.7167023980330205`*^9, 3.716702468815649*^9}, {3.716702528731804*^9, 3.716702580082772*^9}, {3.7167030884372067`*^9, 3.716703132446207*^9}, 3.7167032403053627`*^9, {3.7167035252574787`*^9, 3.7167035482616444`*^9}, { 3.716705201376278*^9, 3.716705274124168*^9}, {3.7167053464628935`*^9, 3.716705482421386*^9}, {3.7167055165909777`*^9, 3.716705538084305*^9}, { 3.716705594456683*^9, 3.716705676580614*^9}, {3.7167057138527184`*^9, 3.716705760704093*^9}, {3.7167058612498045`*^9, 3.716705919506912*^9}, { 3.7167059521690493`*^9, 3.7167059784225216`*^9}, {3.716708469507387*^9, 3.7167084807131166`*^9}, {3.716708530403558*^9, 3.716708540311926*^9}, { 3.716708573803877*^9, 3.7167085805543566`*^9}, {3.716708708288989*^9, 3.7167087716661544`*^9}, {3.7167088129101543`*^9, 3.7167088926868906`*^9}, {3.716709031220501*^9, 3.7167090442403493`*^9}, { 3.7167091836795025`*^9, 3.7167093294069905`*^9}, {3.716711948399163*^9, 3.71671207947799*^9}, {3.7167122388078184`*^9, 3.7167126925749083`*^9}, { 3.7167128042327943`*^9, 3.716712952740783*^9}, 3.7168223312315607`*^9, { 3.716822493716209*^9, 3.7168225319811435`*^9}, {3.71682256827948*^9, 3.7168228489606266`*^9}, {3.7168229075556784`*^9, 3.716823005976004*^9}, { 3.7168231407356963`*^9, 3.716823268414632*^9}, {3.7168233224806066`*^9, 3.7168233728092594`*^9}, {3.716823404334647*^9, 3.716823600638485*^9}, { 3.716823633548622*^9, 3.716823810109604*^9}, {3.7168239825009193`*^9, 3.716823984438436*^9}, {3.716867261983756*^9, 3.7168674516970043`*^9}, { 3.7168685816236744`*^9, 3.7168685827643104`*^9}, {3.71686887918666*^9, 3.7168689059818707`*^9}, {3.716869157111848*^9, 3.716869186428335*^9}, { 3.7168692927050114`*^9, 3.716869316617463*^9}, {3.716869546193698*^9, 3.7168695831835117`*^9}, {3.7168696540445957`*^9, 3.716869656269455*^9}, { 3.716871919351917*^9, 3.71687196318447*^9}, {3.716872080610403*^9, 3.7168720843447485`*^9}, {3.7168724991741543`*^9, 3.7168726229896593`*^9}, {3.7168730424504585`*^9, 3.7168730861353683`*^9}, 3.7168733587651606`*^9, {3.716873407940853*^9, 3.716873421845606*^9}, { 3.7168735768000803`*^9, 3.7168736332407064`*^9}, {3.7168736677886553`*^9, 3.716873703854418*^9}, {3.7168737360849447`*^9, 3.716873980875256*^9}, { 3.716874325592292*^9, 3.7168744203693447`*^9}, {3.716874452250554*^9, 3.716874486384274*^9}, {3.7168746014754925`*^9, 3.7168746118949447`*^9}, { 3.7168746492660923`*^9, 3.71687467585332*^9}, {3.716874770124713*^9, 3.716874800283029*^9}, {3.7168748631893325`*^9, 3.7168748840107574`*^9}, { 3.716874916987217*^9, 3.716874934250338*^9}, {3.7168749850768595`*^9, 3.7168750259453936`*^9}, {3.7168750715373373`*^9, 3.7168750884593625`*^9}, {3.716875134821539*^9, 3.7168751853699245`*^9}, { 3.716875222417639*^9, 3.716875637821155*^9}, {3.716875694840063*^9, 3.716875752339054*^9}, {3.7168758029088535`*^9, 3.7168758162463837`*^9}, { 3.7168758834810867`*^9, 3.7168759260922327`*^9}, {3.716875958169088*^9, 3.716876137116181*^9}, {3.716876211158702*^9, 3.7168762142990885`*^9}, { 3.7168762607562284`*^9, 3.716876263381257*^9}, {3.71687662759048*^9, 3.716876654586501*^9}, {3.7168767272190895`*^9, 3.7168767296565876`*^9}, { 3.716876810769285*^9, 3.7168768240645924`*^9}, {3.716876910591792*^9, 3.7168769123647842`*^9}, {3.716877131276189*^9, 3.7168772201221495`*^9}, { 3.7168772505770645`*^9, 3.716877275896135*^9}, {3.7168773060538635`*^9, 3.7168773135476465`*^9}, {3.716877392892824*^9, 3.716877397736657*^9}, { 3.7168774280111027`*^9, 3.716877431816963*^9}, {3.716877482583009*^9, 3.7168775235383897`*^9}, {3.71687771062191*^9, 3.7168777117468843`*^9}, { 3.716880963671009*^9, 3.7168809646866465`*^9}, {3.7168810496434336`*^9, 3.71688105181535*^9}, {3.716881134028832*^9, 3.7168812249217434`*^9}, { 3.7168812897177505`*^9, 3.7168813349199076`*^9}, {3.716881783901332*^9, 3.716881784307585*^9}, {3.716881847566958*^9, 3.7168818526451297`*^9}, { 3.716881909162103*^9, 3.7168820285202737`*^9}, {3.7168821030694685`*^9, 3.716882112959983*^9}, 3.716882640371127*^9, {3.7168826944971*^9, 3.7168827079972277`*^9}, {3.7168848082979927`*^9, 3.7168848723145285`*^9}, {3.716884926010625*^9, 3.7168849324922714`*^9}, { 3.7168852716455193`*^9, 3.7168853153759766`*^9}, {3.7168856007052383`*^9, 3.716885604033396*^9}}, CellID->323996531,ExpressionUUID->"b971fab5-430b-42e3-8b90-5246e14a7616"] }, Closed]], Cell[CellGroupData[{ Cell["", "ManipulateSection",ExpressionUUID->"39389196-09c6-4cc9-a84b-941538f14d23"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Refresh", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{"moving", ",", RowBox[{"ag", "=", RowBox[{"updateAgents", "[", RowBox[{ "ag", ",", "n", ",", "rs", ",", " ", "ra", ",", "\[Rho]a", ",", "c", ",", " ", "\[Rho]s", ",", " ", "h", ",", " ", "e", ",", " ", "\[Delta]", ",", " ", "p", ",", "\[Delta]s", ",", RowBox[{"ra", " ", RowBox[{"\[Sqrt]", "NumberOfSheep"}]}], ",", "ra"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"visualize", "[", RowBox[{"ag", ",", "ra", ",", RowBox[{"ra", " ", RowBox[{"\[Sqrt]", "NumberOfSheep"}]}], ",", "ra"}], "]"}]}], "\[IndentingNewLine]", ",", RowBox[{"UpdateInterval", "\[Rule]", RowBox[{"If", "[", RowBox[{"moving", ",", "0", ",", "Infinity"}], "]"}]}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ",", "\"\\"", "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "n", ",", "NumberOfSheep", ",", "\"\\""}], "}"}], ",", "0", ",", "NumberOfSheep", ",", "1", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"rs", ",", "65", ",", "\"\\""}], "}"}], ",", "1", ",", "AreaSize", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "ra", ",", "2", ",", "\"\\""}], "}"}], ",", "0", ",", "AreaSize", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "\[Rho]a", ",", "2", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "c", ",", "1.05", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "\[Rho]s", ",", "1", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "h", ",", "0.5", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "e", ",", "0.3", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\[Delta]", ",", "1", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "p", ",", "0.05", ",", "\"\\""}], "}"}], ",", "0", ",", "1", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", "\"\\"", "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\[Delta]s", ",", "1.5", ",", "\"\\""}], "}"}], ",", "0", ",", "10", ",", RowBox[{"ImageSize", "\[Rule]", "Tiny"}]}], "}"}], "\[IndentingNewLine]", ",", "\"\< \>\"", "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"moving", ",", "False", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{"True", ",", " ", "False"}], "}"}]}], "}"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"ag", ",", "initialAgents"}], "}"}], ",", RowBox[{"ControlType", "\[Rule]", "None"}]}], "}"}], "\[IndentingNewLine]", ",", "\"\< \>\"", "\[IndentingNewLine]", ",", RowBox[{"Button", "[", RowBox[{"\"\\"", ",", RowBox[{ RowBox[{"moving", "=", "False"}], ";", RowBox[{"ag", "=", RowBox[{"updateAgents", "[", RowBox[{ "ag", ",", "n", ",", "rs", ",", " ", "ra", ",", "\[Rho]a", ",", "c", ",", " ", "\[Rho]s", ",", " ", "h", ",", " ", "e", ",", " ", "\[Delta]", ",", " ", "p", ",", "\[Delta]s", ",", RowBox[{"ra", " ", RowBox[{"\[Sqrt]", "N"}]}], ",", "ra"}], "]"}]}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Medium"}]}], "]"}], "\[IndentingNewLine]", ",", RowBox[{"Button", "[", RowBox[{"\"\\"", ",", RowBox[{ RowBox[{"moving", "=", "False"}], ";", RowBox[{"ag", "=", "initialAgents"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Medium"}]}], "]"}], "\[IndentingNewLine]", ",", RowBox[{"SaveDefinitions", "\[Rule]", "True"}], ",", RowBox[{"AutorunSequencing", "\[Rule]", RowBox[{"{", "6", "}"}]}], ",", RowBox[{"TrackedSymbols", "\[RuleDelayed]", RowBox[{"{", RowBox[{"moving", ",", "ag"}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"SynchronousUpdating", "\[Rule]", "True"}], ",", RowBox[{"ControlPlacement", "\[Rule]", "Left"}]}], "\[IndentingNewLine]", "]"}]], "Input", CellChangeTimes->{{3.716887924693386*^9, 3.7168880149166203`*^9}, { 3.7168880500825415`*^9, 3.716888054361703*^9}, {3.7168881447072287`*^9, 3.716888156597992*^9}, {3.716888286043083*^9, 3.7168882870430675`*^9}}, CellID->376062353,ExpressionUUID->"ee18878f-c5e0-41a8-aaa6-c2107146a4f5"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = {{ 2., 0, 0, -0.9847649604079107, -0.1738906919671265}, {1., 119.50880700824553`, 120.66552021323827`, -0.4882485653136912, 0.8727046112340201}, {1., 129.22644762760922`, 135.24366698914852`, 0.8605609888450578, 0.5093474103968884}, {1., 121.55288797544448`, 94.38554746901538, -0.8704255565429283, 0.4923000614634672}, {1., 98.93428322898417, 138.32153248902054`, -0.986362146796306, 0.1645895360203151}, {1., 112.50400091907645`, 82.09636035157146, 0.8825458286931231, 0.4702263925561479}, {1., 124.12330272830656`, 128.18022284284123`, -0.9076118319139169, -0.4198103888303191}, {1., 123.20343145938098`, 95.57703712458029, 0.831076822160808, 0.5561576356277891}, {1., 80.2111107672971, 92.70653504143777, -0.919405256089765, 0.39331154963274806`}, {1., 88.35854272844784, 80.74641751467196, -0.13380576508641812`, -0.9910075767771094}, {1., 134.39528125090294`, 125.29766897729343`, 0.5973958145671453, 0.801946532343433}, {1., 130.55611847226027`, 141.4613228966256, 0.31647722799734335`, -0.9486001076107453}, {1., 142.32253690618148`, 140.91104785490998`, -0.5176414287081532, -0.8555976573629581}, {1., 142.64636638650427`, 91.3969318658641, -0.983309935362184, 0.18193837148336087`}, {1., 125.28952731966052`, 84.93917146743719, 0.7850417329382289, 0.6194428767411427}, {1., 139.45141755434824`, 111.34105922138589`, 0.8491248842380469, 0.5281921345189868}, {1., 110.15567634457354`, 102.26922773343844`, 0.5393390229765218, 0.842088723529018}, {1., 120.76017175616883`, 79.23964747039193, -0.9144155369725245, -0.4047767603794091}, {1., 127.19773147576365`, 107.4200833665218, 0.5526097780961367, 0.8334401197161909}, {1., 129.13838639073833`, 131.58997426447362`, -0.6889388537539205, -0.7248194642724725}, {1., 98.22200814263606, 85.86986165282504, -0.8915679439636656, -0.4528869630453078}, {1., 149.09127989594785`, 75.04515967915623, 0.4213345012354416, -0.9069053082150759}, {1., 110.45924541866032`, 134.89010151430654`, -0.5701392848355104, 0.8215480484349365}, {1., 149.96825289090785`, 131.35249686016166`, 0.2047044850901087, 0.9788238216267489}, {1., 80.16501983128376, 133.64323983874783`, 0.9411777929376359, 0.33791176670995127`}, {1., 79.61702776591507, 118.50991793543845`, -0.15300421500397435`, -0.9882255360953883}, {1., 75.64364191172328, 78.39754192540686, -0.5128114386899851, -0.8585012686937088}, {1., 140.05841840591972`, 125.50493280901112`, -0.7899688198946058, 0.6131470162973346}, {1., 118.65057068268828`, 128.17615929322048`, 0.4020907231796173, -0.915599830893875}, {1., 89.18134118585628, 118.67426426570388`, 0.5339796092731042, -0.8454973547448525}, {1., 78.13140793671694, 103.00364000707485`, 0.1641009764807682, -0.9864435460370038}, {1., 107.86795497089061`, 117.83122195646676`, 0.9985484990109964, 0.05385995843747046}, {1., 116.18759710214923`, 137.4673606727077, 0.03607236141832474, -0.9993491805878993}, {1., 100.11943867457842`, 125.56170261293616`, -0.5538254394193086, 0.8326328018112243}, {1., 94.18760383147709, 87.0236793776132, 0.7484469772220791, 0.6631946337894575}, {1., 81.73736278855056, 109.78784145046833`, 0.1896772561951368, -0.9818464943575876}, {1., 85.74208021954591, 115.22548070398742`, -0.4738929165319325, 0.8805824797603339}, {1., 95.81438029973958, 126.35746917854416`, 0.9989304488090711, -0.04623806269847192}, {1., 109.73271297127519`, 80.37317571851267, 0.9906270365288262, -0.13659456247638688`}, {1., 92.37780249672207, 89.52142777814133, 0.9966687009982388, 0.08155673148479661}, {1., 78.74761022428197, 126.50835918335072`, -0.9792352633567243, 0.20272715407336725`}, {1., 117.7100977395989, 112.15744339318007`, 0.8999648633533962, 0.4359624349979054}, {1., 81.14335473464348, 92.63577416805087, -0.1879816047748653, 0.9821725491308878}, {1., 114.14945090105314`, 94.986744199469, -0.2822212375007142, 0.9593493488315742}, {1., 89.42046896534214, 128.9759373309794, 0.782328459963266, 0.6228661017678715}, {1., 75.41344008943801, 76.46138993690533, 0.3504220339445974, 0.9365919058619562}, {1., 147.77017847036754`, 84.96384430010593, -0.9760629904856714, 0.21748801944973464`}}, $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 0, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], {{ 2., 0, 0, -0.9847649604079107, -0.1738906919671265}, {1., 119.50880700824553`, 120.66552021323827`, -0.4882485653136912, 0.8727046112340201}, {1., 129.22644762760922`, 135.24366698914852`, 0.8605609888450578, 0.5093474103968884}, {1., 121.55288797544448`, 94.38554746901538, -0.8704255565429283, 0.4923000614634672}, {1., 98.93428322898417, 138.32153248902054`, -0.986362146796306, 0.1645895360203151}, {1., 112.50400091907645`, 82.09636035157146, 0.8825458286931231, 0.4702263925561479}, {1., 124.12330272830656`, 128.18022284284123`, -0.9076118319139169, -0.4198103888303191}, {1., 123.20343145938098`, 95.57703712458029, 0.831076822160808, 0.5561576356277891}, {1., 80.2111107672971, 92.70653504143777, -0.919405256089765, 0.39331154963274806`}, {1., 88.35854272844784, 80.74641751467196, -0.13380576508641812`, -0.9910075767771094}, {1., 134.39528125090294`, 125.29766897729343`, 0.5973958145671453, 0.801946532343433}, {1., 130.55611847226027`, 141.4613228966256, 0.31647722799734335`, -0.9486001076107453}, {1., 142.32253690618148`, 140.91104785490998`, -0.5176414287081532, -0.8555976573629581}, {1., 142.64636638650427`, 91.3969318658641, -0.983309935362184, 0.18193837148336087`}, {1., 125.28952731966052`, 84.93917146743719, 0.7850417329382289, 0.6194428767411427}, {1., 139.45141755434824`, 111.34105922138589`, 0.8491248842380469, 0.5281921345189868}, {1., 110.15567634457354`, 102.26922773343844`, 0.5393390229765218, 0.842088723529018}, {1., 120.76017175616883`, 79.23964747039193, -0.9144155369725245, -0.4047767603794091}, {1., 127.19773147576365`, 107.4200833665218, 0.5526097780961367, 0.8334401197161909}, {1., 129.13838639073833`, 131.58997426447362`, -0.6889388537539205, -0.7248194642724725}, {1., 98.22200814263606, 85.86986165282504, -0.8915679439636656, -0.4528869630453078}, {1., 149.09127989594785`, 75.04515967915623, 0.4213345012354416, -0.9069053082150759}, {1., 110.45924541866032`, 134.89010151430654`, -0.5701392848355104, 0.8215480484349365}, {1., 149.96825289090785`, 131.35249686016166`, 0.2047044850901087, 0.9788238216267489}, {1., 80.16501983128376, 133.64323983874783`, 0.9411777929376359, 0.33791176670995127`}, {1., 79.61702776591507, 118.50991793543845`, -0.15300421500397435`, -0.9882255360953883}, {1., 75.64364191172328, 78.39754192540686, -0.5128114386899851, -0.8585012686937088}, {1., 140.05841840591972`, 125.50493280901112`, -0.7899688198946058, 0.6131470162973346}, {1., 118.65057068268828`, 128.17615929322048`, 0.4020907231796173, -0.915599830893875}, {1., 89.18134118585628, 118.67426426570388`, 0.5339796092731042, -0.8454973547448525}, {1., 78.13140793671694, 103.00364000707485`, 0.1641009764807682, -0.9864435460370038}, {1., 107.86795497089061`, 117.83122195646676`, 0.9985484990109964, 0.05385995843747046}, {1., 116.18759710214923`, 137.4673606727077, 0.03607236141832474, -0.9993491805878993}, {1., 100.11943867457842`, 125.56170261293616`, -0.5538254394193086, 0.8326328018112243}, {1., 94.18760383147709, 87.0236793776132, 0.7484469772220791, 0.6631946337894575}, {1., 81.73736278855056, 109.78784145046833`, 0.1896772561951368, -0.9818464943575876}, {1., 85.74208021954591, 115.22548070398742`, -0.4738929165319325, 0.8805824797603339}, {1., 95.81438029973958, 126.35746917854416`, 0.9989304488090711, -0.04623806269847192}, {1., 109.73271297127519`, 80.37317571851267, 0.9906270365288262, -0.13659456247638688`}, {1., 92.37780249672207, 89.52142777814133, 0.9966687009982388, 0.08155673148479661}, {1., 78.74761022428197, 126.50835918335072`, -0.9792352633567243, 0.20272715407336725`}, {1., 117.7100977395989, 112.15744339318007`, 0.8999648633533962, 0.4359624349979054}, {1., 81.14335473464348, 92.63577416805087, -0.1879816047748653, 0.9821725491308878}, {1., 114.14945090105314`, 94.986744199469, -0.2822212375007142, 0.9593493488315742}, {1., 89.42046896534214, 128.9759373309794, 0.782328459963266, 0.6228661017678715}, {1., 75.41344008943801, 76.46138993690533, 0.3504220339445974, 0.9365919058619562}, {1., 147.77017847036754`, 84.96384430010593, -0.9760629904856714, 0.21748801944973464`}}}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[N], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$17109$$ = 0, $CellContext`rs$17110$$ = 0, $CellContext`ra$17111$$ = 0, $CellContext`\[Rho]a$17112$$ = 0, $CellContext`c$17113$$ = 0, $CellContext`\[Rho]s$17114$$ = 0, $CellContext`h$17115$$ = 0, $CellContext`e$17116$$ = 0, $CellContext`\[Delta]$17117$$ = 0, $CellContext`p$17118$$ = 0, $CellContext`moving$17119$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = {{ 2., 0, 0, -0.9847649604079107, -0.1738906919671265}, {1., 119.50880700824553`, 120.66552021323827`, -0.4882485653136912, 0.8727046112340201}, {1., 129.22644762760922`, 135.24366698914852`, 0.8605609888450578, 0.5093474103968884}, {1., 121.55288797544448`, 94.38554746901538, -0.8704255565429283, 0.4923000614634672}, {1., 98.93428322898417, 138.32153248902054`, -0.986362146796306, 0.1645895360203151}, {1., 112.50400091907645`, 82.09636035157146, 0.8825458286931231, 0.4702263925561479}, {1., 124.12330272830656`, 128.18022284284123`, -0.9076118319139169, -0.4198103888303191}, {1., 123.20343145938098`, 95.57703712458029, 0.831076822160808, 0.5561576356277891}, {1., 80.2111107672971, 92.70653504143777, -0.919405256089765, 0.39331154963274806`}, {1., 88.35854272844784, 80.74641751467196, -0.13380576508641812`, -0.9910075767771094}, {1., 134.39528125090294`, 125.29766897729343`, 0.5973958145671453, 0.801946532343433}, {1., 130.55611847226027`, 141.4613228966256, 0.31647722799734335`, -0.9486001076107453}, {1., 142.32253690618148`, 140.91104785490998`, -0.5176414287081532, -0.8555976573629581}, {1., 142.64636638650427`, 91.3969318658641, -0.983309935362184, 0.18193837148336087`}, {1., 125.28952731966052`, 84.93917146743719, 0.7850417329382289, 0.6194428767411427}, {1., 139.45141755434824`, 111.34105922138589`, 0.8491248842380469, 0.5281921345189868}, {1., 110.15567634457354`, 102.26922773343844`, 0.5393390229765218, 0.842088723529018}, {1., 120.76017175616883`, 79.23964747039193, -0.9144155369725245, -0.4047767603794091}, {1., 127.19773147576365`, 107.4200833665218, 0.5526097780961367, 0.8334401197161909}, {1., 129.13838639073833`, 131.58997426447362`, -0.6889388537539205, -0.7248194642724725}, {1., 98.22200814263606, 85.86986165282504, -0.8915679439636656, -0.4528869630453078}, {1., 149.09127989594785`, 75.04515967915623, 0.4213345012354416, -0.9069053082150759}, {1., 110.45924541866032`, 134.89010151430654`, -0.5701392848355104, 0.8215480484349365}, {1., 149.96825289090785`, 131.35249686016166`, 0.2047044850901087, 0.9788238216267489}, {1., 80.16501983128376, 133.64323983874783`, 0.9411777929376359, 0.33791176670995127`}, {1., 79.61702776591507, 118.50991793543845`, -0.15300421500397435`, -0.9882255360953883}, { 1., 75.64364191172328, 78.39754192540686, -0.5128114386899851, -0.8585012686937088}, {1., 140.05841840591972`, 125.50493280901112`, -0.7899688198946058, 0.6131470162973346}, {1., 118.65057068268828`, 128.17615929322048`, 0.4020907231796173, -0.915599830893875}, {1., 89.18134118585628, 118.67426426570388`, 0.5339796092731042, -0.8454973547448525}, {1., 78.13140793671694, 103.00364000707485`, 0.1641009764807682, -0.9864435460370038}, {1., 107.86795497089061`, 117.83122195646676`, 0.9985484990109964, 0.05385995843747046}, {1., 116.18759710214923`, 137.4673606727077, 0.03607236141832474, -0.9993491805878993}, {1., 100.11943867457842`, 125.56170261293616`, -0.5538254394193086, 0.8326328018112243}, {1., 94.18760383147709, 87.0236793776132, 0.7484469772220791, 0.6631946337894575}, {1., 81.73736278855056, 109.78784145046833`, 0.1896772561951368, -0.9818464943575876}, {1., 85.74208021954591, 115.22548070398742`, -0.4738929165319325, 0.8805824797603339}, {1., 95.81438029973958, 126.35746917854416`, 0.9989304488090711, -0.04623806269847192}, {1., 109.73271297127519`, 80.37317571851267, 0.9906270365288262, -0.13659456247638688`}, {1., 92.37780249672207, 89.52142777814133, 0.9966687009982388, 0.08155673148479661}, {1., 78.74761022428197, 126.50835918335072`, -0.9792352633567243, 0.20272715407336725`}, { 1., 117.7100977395989, 112.15744339318007`, 0.8999648633533962, 0.4359624349979054}, {1., 81.14335473464348, 92.63577416805087, -0.1879816047748653, 0.9821725491308878}, {1., 114.14945090105314`, 94.986744199469, -0.2822212375007142, 0.9593493488315742}, {1., 89.42046896534214, 128.9759373309794, 0.782328459963266, 0.6228661017678715}, {1., 75.41344008943801, 76.46138993690533, 0.3504220339445974, 0.9365919058619562}, {1., 147.77017847036754`, 84.96384430010593, -0.9760629904856714, 0.21748801944973464`}}, $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$17109$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$17110$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$17111$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$17112$$, 0], Hold[$CellContext`c$$, $CellContext`c$17113$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$17114$$, 0], Hold[$CellContext`h$$, $CellContext`h$17115$$, 0], Hold[$CellContext`e$$, $CellContext`e$17116$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$17117$$, 0], Hold[$CellContext`p$$, $CellContext`p$17118$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$17119$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 0, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, {{ 2., 0, 0, -0.9847649604079107, -0.1738906919671265}, {1., 119.50880700824553`, 120.66552021323827`, -0.4882485653136912, 0.8727046112340201}, {1., 129.22644762760922`, 135.24366698914852`, 0.8605609888450578, 0.5093474103968884}, {1., 121.55288797544448`, 94.38554746901538, -0.8704255565429283, 0.4923000614634672}, {1., 98.93428322898417, 138.32153248902054`, -0.986362146796306, 0.1645895360203151}, {1., 112.50400091907645`, 82.09636035157146, 0.8825458286931231, 0.4702263925561479}, {1., 124.12330272830656`, 128.18022284284123`, -0.9076118319139169, -0.4198103888303191}, { 1., 123.20343145938098`, 95.57703712458029, 0.831076822160808, 0.5561576356277891}, {1., 80.2111107672971, 92.70653504143777, -0.919405256089765, 0.39331154963274806`}, {1., 88.35854272844784, 80.74641751467196, -0.13380576508641812`, -0.9910075767771094}, { 1., 134.39528125090294`, 125.29766897729343`, 0.5973958145671453, 0.801946532343433}, {1., 130.55611847226027`, 141.4613228966256, 0.31647722799734335`, -0.9486001076107453}, {1., 142.32253690618148`, 140.91104785490998`, -0.5176414287081532, -0.8555976573629581}, { 1., 142.64636638650427`, 91.3969318658641, -0.983309935362184, 0.18193837148336087`}, {1., 125.28952731966052`, 84.93917146743719, 0.7850417329382289, 0.6194428767411427}, {1., 139.45141755434824`, 111.34105922138589`, 0.8491248842380469, 0.5281921345189868}, {1., 110.15567634457354`, 102.26922773343844`, 0.5393390229765218, 0.842088723529018}, {1., 120.76017175616883`, 79.23964747039193, -0.9144155369725245, -0.4047767603794091}, {1., 127.19773147576365`, 107.4200833665218, 0.5526097780961367, 0.8334401197161909}, {1., 129.13838639073833`, 131.58997426447362`, -0.6889388537539205, -0.7248194642724725}, { 1., 98.22200814263606, 85.86986165282504, -0.8915679439636656, -0.4528869630453078}, {1., 149.09127989594785`, 75.04515967915623, 0.4213345012354416, -0.9069053082150759}, {1., 110.45924541866032`, 134.89010151430654`, -0.5701392848355104, 0.8215480484349365}, { 1., 149.96825289090785`, 131.35249686016166`, 0.2047044850901087, 0.9788238216267489}, {1., 80.16501983128376, 133.64323983874783`, 0.9411777929376359, 0.33791176670995127`}, {1., 79.61702776591507, 118.50991793543845`, -0.15300421500397435`, -0.9882255360953883}, { 1., 75.64364191172328, 78.39754192540686, -0.5128114386899851, -0.8585012686937088}, {1., 140.05841840591972`, 125.50493280901112`, -0.7899688198946058, 0.6131470162973346}, {1., 118.65057068268828`, 128.17615929322048`, 0.4020907231796173, -0.915599830893875}, {1., 89.18134118585628, 118.67426426570388`, 0.5339796092731042, -0.8454973547448525}, {1., 78.13140793671694, 103.00364000707485`, 0.1641009764807682, -0.9864435460370038}, {1., 107.86795497089061`, 117.83122195646676`, 0.9985484990109964, 0.05385995843747046}, { 1., 116.18759710214923`, 137.4673606727077, 0.03607236141832474, -0.9993491805878993}, {1., 100.11943867457842`, 125.56170261293616`, -0.5538254394193086, 0.8326328018112243}, {1., 94.18760383147709, 87.0236793776132, 0.7484469772220791, 0.6631946337894575}, {1., 81.73736278855056, 109.78784145046833`, 0.1896772561951368, -0.9818464943575876}, {1., 85.74208021954591, 115.22548070398742`, -0.4738929165319325, 0.8805824797603339}, {1., 95.81438029973958, 126.35746917854416`, 0.9989304488090711, -0.04623806269847192}, {1., 109.73271297127519`, 80.37317571851267, 0.9906270365288262, -0.13659456247638688`}, {1., 92.37780249672207, 89.52142777814133, 0.9966687009982388, 0.08155673148479661}, {1., 78.74761022428197, 126.50835918335072`, -0.9792352633567243, 0.20272715407336725`}, {1., 117.7100977395989, 112.15744339318007`, 0.8999648633533962, 0.4359624349979054}, {1., 81.14335473464348, 92.63577416805087, -0.1879816047748653, 0.9821725491308878}, {1., 114.14945090105314`, 94.986744199469, -0.2822212375007142, 0.9593493488315742}, {1., 89.42046896534214, 128.9759373309794, 0.782328459963266, 0.6228661017678715}, {1., 75.41344008943801, 76.46138993690533, 0.3504220339445974, 0.9365919058619562}, {1., 147.77017847036754`, 84.96384430010593, -0.9760629904856714, 0.21748801944973464`}}}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[N], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint]], \ $CellContext`i, $CellContext`nextLocation, $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx7dbdaIoZBAi3T 546oNwmONsl9kRflIge23Skb5DYg/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Wyk0XRyS3kZfh8f52kcU9tJBPTHgMQ2QybINhW7zSjeQqQ91C51/YP3QeZh izG6pAMYu+RQBZSpcCmk89NloXzE5+7IjdZp/Bwh1GtTDxoZILoh95Q6LxF8 DRUX08JH0CNJ/R9P5+L3ElW6RdLvcTR4HFCStNtxfX8NbBPK9x9CsjYoE5Wc 8LkU1G4pD1ZggFfq90EWiwpcyTYNg7AJNNVmW32/FT6Xm+csE+LSyLB7PvBa EX09bmT1zqkfXERYxT3QWOouFncwcnepcS4NhAze5X9dv7f/Lf78pDRhECmf 9z3rqYfXLSer8NJbbzKsvp3yHfudCKqb+MP9lrjIBY19Eem/p2GcHWfnEcsa AuSa/dR5PJgMbvKZ7FVXDhKjqVapN9uCcSdV6NrLUfawMM6+eeiJLVza0a/g p9GJelwc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyzglRoUhUhKvV qJUiy1JxyyiCiBBBi2LRglRAGVZG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cfz1OJcKMcev9pGVczL1vTfl+TcC1pFJAXaOQ Kl028GitBCu7FtYdpwXIM1rTsaJNjIr0g0/cDYTIqTaoOBFAIMihURO+l0LI TaWnHk8CRpVo8U/LeWh8+Zfy4Y9CuPdbSv8zJYSyJeRxyz0Fmr51pCJfC1CW k2Tft4qG2dW3rOQrFPo7lU6upiSmP0qOhi/gobO8+MTuSgpkZt+9n+by8aFh UWNPoRA2igzpoTISAz8S62LbZ72WwHSFIQ3t2+80Nq0kjlxZ3+6pS8GX1eJk VBOITKby4PlqEkz3elfen3xM6ty5RnAprBoeGA5r4uNJ1bJOrxAZtDGc0iSW Ai+H3BrMkiSQnHrHvMSU4b+W1EZ9by5+qSjwzEuXQbdhsl0eyMU/DPMty6xJ bPbZtbfbjw9NncaD2S9HdP5g0dkgGvkXCpr6i/gY3Md+lZMnwlm/ao/JDjG8 VHHk75YK5GSzm6UcAuNPVac3PKCwqWTny6XeBObH22ZEz6GQlLqlZyRbBNOK UyltaWJsjAlZf65Wjlq/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{{3.71688803356676*^9, 3.7168880775755053`*^9}, 3.7168881586136184`*^9, 3.7168882923399997`*^9, 3.7168883636913304`*^9}, CellID->244282151,ExpressionUUID->"bb4e58be-b4ea-46c8-a082-110f41eb0339"] }, {2}]] }, Open ]], Cell[CellGroupData[{ Cell["", "ManipulateCaptionSection",ExpressionUUID->"32e0037a-27f4-4198-b0f4-32638b25f267"], Cell["\<\ This Demonstration simulates the dynamics of sheep herding (shepherd in \ orange and sheep in purple). An individual of each species is simulated as a \ particle moving in with respect to the rules defined in the paper presented \ by Str\[ODoubleDot]mbom, et al. (2014), doi: 10.1098/rsif.2014.0719. The \ initial condition is such that there are 46 sheep randomly distributed in the \ upper left quadrant of the arena and the shepherd in the barn (bottom left \ corner of the arena). The shepherd's task is to herd the sheep into the barn \ (green rectangle). During this process it switches between collecting sheep \ (when these are overly dispersed, marked by the dashed circle) and driving \ them towards the barn. Depending on the parameter settings, the shepherd's \ task is more or less simple. Its success rate highly depends on the number of \ nearest neighbours individual sheep take into account when performing their \ decisions. You can stop and restart the real-time simulation using the \"run \ simulation\" checkbox.\ \>", "ManipulateCaption", CellChangeTimes->{ 3.35696210375764*^9, {3.413051635203125*^9, 3.41305166196875*^9}, { 3.413051729203125*^9, 3.41305188478125*^9}, {3.413051930765625*^9, 3.413051973890625*^9}, {3.4130520070625*^9, 3.413052056671875*^9}, { 3.41305229965625*^9, 3.413052340328125*^9}, {3.41305742590625*^9, 3.413057429765625*^9}, 3.41310111840625*^9, {3.4131018089375*^9, 3.413101832890625*^9}, {3.41310186775*^9, 3.413101904640625*^9}, { 3.413124865306138*^9, 3.4131248891033173`*^9}, {3.413223596109375*^9, 3.41322360009375*^9}, {3.413228505379353*^9, 3.413228506176238*^9}, { 3.413309711144929*^9, 3.413309758598054*^9}, {3.7168870805209856`*^9, 3.71688750052407*^9}}, CellID->330077632,ExpressionUUID->"766d285b-c20c-440b-90a9-a80a51347879"] }, Open ]], Cell[CellGroupData[{ Cell["", "ThumbnailSection",ExpressionUUID->"f0348689-0dba-42ac-9d53-926377e8709e"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = {{ 2., 0, 0, 0.9950399642338729, 0.09947597487560975}, {1., 101.17944708201343`, 83.25099003264178, 0.17498077196484313`, -0.9845718508278548}, {1., 80.92986537576647, 105.9922707904969, -0.11098344090152122`, -0.9938222556602657}, {1., 92.4545078135768, 85.60696967038642, 0.9683366588686624, -0.24964798234929877`}, {1., 87.7966496020237, 118.49771378260587`, -0.6811108979641963, 0.7321802678810773}, {1., 106.2950279651265, 92.60607751403305, -0.8735451903438206, 0.4867430538047546}, {1., 134.5575062525946, 119.82718055612422`, 0.7662130744442337, -0.6425865891463306}, {1., 137.62687537081092`, 101.96655970374658`, 0.9230151313786289, 0.38476365114975764`}, {1., 93.04884940276072, 141.71527583150484`, 0.29354822792136914`, 0.9559442650511712}, {1., 99.2520231642391, 99.27780098031916, -0.6230429832832968, -0.7821875996085911}, {1., 89.22320246445707, 93.13076695322638, -0.9153370719739162, 0.4026885206586075}, {1., 84.84537982474608, 106.33374468405358`, 0.19757413983556787`, 0.9802879471197407}, {1., 109.14652930766674`, 137.60937348056905`, 0.8395310642055362, 0.5433116897637301}, {1., 93.5317688218231, 129.27828619077943`, -0.5634947737100507, -0.8261196281419894}, {1., 95.12874307242299, 147.85389716962996`, 0.06455561547883547, -0.9979141107881724}, {1., 148.26030964914202`, 143.98818003059702`, -0.4616503552109485, -0.8870619761513877}, {1., 109.09419410760542`, 130.31471697717095`, -0.6149461899811809, 0.7885690733395707}, {1., 75.28094792675954, 134.71268032716355`, 0.5363649182570518, -0.8439861814408492}, {1., 146.13213556914948`, 105.6717677175598, -0.7036443032695336, 0.7105523868627369}, {1., 81.44250521300485, 144.10186434196575`, 0.43474838308648056`, 0.9005519659651466}, {1., 115.04644029506052`, 122.41120981383438`, -0.9154114960885383, -0.40251930739896685`}, {1., 110.56809288214622`, 128.0426191728563, 0.2988873535182504, 0.9542883997549464}, {1., 101.72172893988312`, 78.60731910007351, 0.988577507656636, -0.15071334166354958`}, {1., 136.4325109309222, 118.9878684348138, 0.9939156516395393, 0.11014389418369963`}, {1., 103.15185224392454`, 128.25777738925706`, 0.0527448347075302, -0.9986080224050252}, {1., 78.2704211235427, 139.40631004301207`, 0.7162031537713178, -0.6978918558974722}, {1., 146.89264034170216`, 119.52477568994665`, -0.07666584625856242, -0.9970568429219362}, {1., 136.61645733771385`, 123.08525372611284`, 0.9338705918357652, -0.3576111263709753}, {1., 108.36515373852961`, 149.16718903512873`, -0.7055368752170986, 0.7086732093912484}, {1., 115.03859720099581`, 133.42377757574513`, 0.05425984727277311, 0.9985268494006234}, {1., 114.43428822018525`, 123.7016918421111, -0.4695547046578449, 0.8829033805200227}, {1., 98.4751342352293, 86.32104816487036, -0.7627096262255353, 0.6467410811622408}, {1., 106.32879829232155`, 96.68478962693409, -0.3435573408865479, -0.9391317019049907}, {1., 89.10114221545358, 128.73535961849132`, -0.9976105975672283, -0.069087593832452}, {1., 144.06763774977574`, 113.52572360260987`, -0.8553851510754186, -0.5179925128027272}, {1., 116.50617226485763`, 89.37508918977312, 0.13512644270741994`, 0.9908283627759342}, {1., 96.06571264997208, 129.59796337914216`, -0.7520423006566466, 0.6591148443352326}, {1., 135.12948621672828`, 140.8103051089464, -0.06560722821237557, -0.9978455249217132}, {1., 98.04428417601915, 103.80930285648665`, -0.9962616413568978, -0.08638716317173498}, {1., 84.61829042994786, 75.33777148397068, -0.9720222660888188, 0.2348887273318101}, {1., 133.57079705663446`, 94.66892566665447, 0.937341185116139, -0.34841283369742887`}, {1., 128.43262009634088`, 146.7619824927731, 0.04610688062951141, 0.9989365122762387}, {1., 96.83003998158901, 84.6776292364314, 0.5878270340835674, -0.8089866364783268}, {1., 141.3496701138298, 80.51862282088518, -0.9065320580470174, 0.42213697745286305`}, {1., 97.15381892181357, 145.05492307709227`, -0.989389519157231, 0.14528723062204524`}, {1., 142.0227402517114, 146.14275533765309`, -0.48813096930321354`, -0.872770391802509}, {1., 114.32960148723546`, 95.26699235278225, -0.9462957399375963, 0.3233022928714815}}, $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], {{ 2., 0, 0, 0.9950399642338729, 0.09947597487560975}, {1., 101.17944708201343`, 83.25099003264178, 0.17498077196484313`, -0.9845718508278548}, {1., 80.92986537576647, 105.9922707904969, -0.11098344090152122`, -0.9938222556602657}, {1., 92.4545078135768, 85.60696967038642, 0.9683366588686624, -0.24964798234929877`}, {1., 87.7966496020237, 118.49771378260587`, -0.6811108979641963, 0.7321802678810773}, {1., 106.2950279651265, 92.60607751403305, -0.8735451903438206, 0.4867430538047546}, {1., 134.5575062525946, 119.82718055612422`, 0.7662130744442337, -0.6425865891463306}, {1., 137.62687537081092`, 101.96655970374658`, 0.9230151313786289, 0.38476365114975764`}, {1., 93.04884940276072, 141.71527583150484`, 0.29354822792136914`, 0.9559442650511712}, {1., 99.2520231642391, 99.27780098031916, -0.6230429832832968, -0.7821875996085911}, {1., 89.22320246445707, 93.13076695322638, -0.9153370719739162, 0.4026885206586075}, {1., 84.84537982474608, 106.33374468405358`, 0.19757413983556787`, 0.9802879471197407}, {1., 109.14652930766674`, 137.60937348056905`, 0.8395310642055362, 0.5433116897637301}, {1., 93.5317688218231, 129.27828619077943`, -0.5634947737100507, -0.8261196281419894}, {1., 95.12874307242299, 147.85389716962996`, 0.06455561547883547, -0.9979141107881724}, {1., 148.26030964914202`, 143.98818003059702`, -0.4616503552109485, -0.8870619761513877}, {1., 109.09419410760542`, 130.31471697717095`, -0.6149461899811809, 0.7885690733395707}, {1., 75.28094792675954, 134.71268032716355`, 0.5363649182570518, -0.8439861814408492}, {1., 146.13213556914948`, 105.6717677175598, -0.7036443032695336, 0.7105523868627369}, {1., 81.44250521300485, 144.10186434196575`, 0.43474838308648056`, 0.9005519659651466}, {1., 115.04644029506052`, 122.41120981383438`, -0.9154114960885383, -0.40251930739896685`}, {1., 110.56809288214622`, 128.0426191728563, 0.2988873535182504, 0.9542883997549464}, {1., 101.72172893988312`, 78.60731910007351, 0.988577507656636, -0.15071334166354958`}, {1., 136.4325109309222, 118.9878684348138, 0.9939156516395393, 0.11014389418369963`}, {1., 103.15185224392454`, 128.25777738925706`, 0.0527448347075302, -0.9986080224050252}, {1., 78.2704211235427, 139.40631004301207`, 0.7162031537713178, -0.6978918558974722}, {1., 146.89264034170216`, 119.52477568994665`, -0.07666584625856242, -0.9970568429219362}, {1., 136.61645733771385`, 123.08525372611284`, 0.9338705918357652, -0.3576111263709753}, {1., 108.36515373852961`, 149.16718903512873`, -0.7055368752170986, 0.7086732093912484}, {1., 115.03859720099581`, 133.42377757574513`, 0.05425984727277311, 0.9985268494006234}, {1., 114.43428822018525`, 123.7016918421111, -0.4695547046578449, 0.8829033805200227}, {1., 98.4751342352293, 86.32104816487036, -0.7627096262255353, 0.6467410811622408}, {1., 106.32879829232155`, 96.68478962693409, -0.3435573408865479, -0.9391317019049907}, {1., 89.10114221545358, 128.73535961849132`, -0.9976105975672283, -0.069087593832452}, {1., 144.06763774977574`, 113.52572360260987`, -0.8553851510754186, -0.5179925128027272}, {1., 116.50617226485763`, 89.37508918977312, 0.13512644270741994`, 0.9908283627759342}, {1., 96.06571264997208, 129.59796337914216`, -0.7520423006566466, 0.6591148443352326}, {1., 135.12948621672828`, 140.8103051089464, -0.06560722821237557, -0.9978455249217132}, {1., 98.04428417601915, 103.80930285648665`, -0.9962616413568978, -0.08638716317173498}, {1., 84.61829042994786, 75.33777148397068, -0.9720222660888188, 0.2348887273318101}, {1., 133.57079705663446`, 94.66892566665447, 0.937341185116139, -0.34841283369742887`}, {1., 128.43262009634088`, 146.7619824927731, 0.04610688062951141, 0.9989365122762387}, {1., 96.83003998158901, 84.6776292364314, 0.5878270340835674, -0.8089866364783268}, {1., 141.3496701138298, 80.51862282088518, -0.9065320580470174, 0.42213697745286305`}, {1., 97.15381892181357, 145.05492307709227`, -0.989389519157231, 0.14528723062204524`}, {1., 142.0227402517114, 146.14275533765309`, -0.48813096930321354`, -0.872770391802509}, {1., 114.32960148723546`, 95.26699235278225, -0.9462957399375963, 0.3233022928714815}}}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$22854$$ = 0, $CellContext`rs$22855$$ = 0, $CellContext`ra$22856$$ = 0, $CellContext`\[Rho]a$22857$$ = 0, $CellContext`c$22858$$ = 0, $CellContext`\[Rho]s$22859$$ = 0, $CellContext`h$22860$$ = 0, $CellContext`e$22861$$ = 0, $CellContext`\[Delta]$22862$$ = 0, $CellContext`p$22863$$ = 0, $CellContext`moving$22864$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = {{ 2., 0, 0, 0.9950399642338729, 0.09947597487560975}, {1., 101.17944708201343`, 83.25099003264178, 0.17498077196484313`, -0.9845718508278548}, {1., 80.92986537576647, 105.9922707904969, -0.11098344090152122`, -0.9938222556602657}, {1., 92.4545078135768, 85.60696967038642, 0.9683366588686624, -0.24964798234929877`}, {1., 87.7966496020237, 118.49771378260587`, -0.6811108979641963, 0.7321802678810773}, {1., 106.2950279651265, 92.60607751403305, -0.8735451903438206, 0.4867430538047546}, {1., 134.5575062525946, 119.82718055612422`, 0.7662130744442337, -0.6425865891463306}, {1., 137.62687537081092`, 101.96655970374658`, 0.9230151313786289, 0.38476365114975764`}, {1., 93.04884940276072, 141.71527583150484`, 0.29354822792136914`, 0.9559442650511712}, {1., 99.2520231642391, 99.27780098031916, -0.6230429832832968, -0.7821875996085911}, {1., 89.22320246445707, 93.13076695322638, -0.9153370719739162, 0.4026885206586075}, {1., 84.84537982474608, 106.33374468405358`, 0.19757413983556787`, 0.9802879471197407}, {1., 109.14652930766674`, 137.60937348056905`, 0.8395310642055362, 0.5433116897637301}, {1., 93.5317688218231, 129.27828619077943`, -0.5634947737100507, -0.8261196281419894}, {1., 95.12874307242299, 147.85389716962996`, 0.06455561547883547, -0.9979141107881724}, {1., 148.26030964914202`, 143.98818003059702`, -0.4616503552109485, -0.8870619761513877}, { 1., 109.09419410760542`, 130.31471697717095`, -0.6149461899811809, 0.7885690733395707}, {1., 75.28094792675954, 134.71268032716355`, 0.5363649182570518, -0.8439861814408492}, {1., 146.13213556914948`, 105.6717677175598, -0.7036443032695336, 0.7105523868627369}, {1., 81.44250521300485, 144.10186434196575`, 0.43474838308648056`, 0.9005519659651466}, {1., 115.04644029506052`, 122.41120981383438`, -0.9154114960885383, -0.40251930739896685`}, { 1., 110.56809288214622`, 128.0426191728563, 0.2988873535182504, 0.9542883997549464}, {1., 101.72172893988312`, 78.60731910007351, 0.988577507656636, -0.15071334166354958`}, {1., 136.4325109309222, 118.9878684348138, 0.9939156516395393, 0.11014389418369963`}, {1., 103.15185224392454`, 128.25777738925706`, 0.0527448347075302, -0.9986080224050252}, {1., 78.2704211235427, 139.40631004301207`, 0.7162031537713178, -0.6978918558974722}, {1., 146.89264034170216`, 119.52477568994665`, -0.07666584625856242, -0.9970568429219362}, { 1., 136.61645733771385`, 123.08525372611284`, 0.9338705918357652, -0.3576111263709753}, {1., 108.36515373852961`, 149.16718903512873`, -0.7055368752170986, 0.7086732093912484}, {1., 115.03859720099581`, 133.42377757574513`, 0.05425984727277311, 0.9985268494006234}, {1., 114.43428822018525`, 123.7016918421111, -0.4695547046578449, 0.8829033805200227}, {1., 98.4751342352293, 86.32104816487036, -0.7627096262255353, 0.6467410811622408}, {1., 106.32879829232155`, 96.68478962693409, -0.3435573408865479, -0.9391317019049907}, {1., 89.10114221545358, 128.73535961849132`, -0.9976105975672283, -0.069087593832452}, {1., 144.06763774977574`, 113.52572360260987`, -0.8553851510754186, -0.5179925128027272}, {1., 116.50617226485763`, 89.37508918977312, 0.13512644270741994`, 0.9908283627759342}, {1., 96.06571264997208, 129.59796337914216`, -0.7520423006566466, 0.6591148443352326}, {1., 135.12948621672828`, 140.8103051089464, -0.06560722821237557, -0.9978455249217132}, {1., 98.04428417601915, 103.80930285648665`, -0.9962616413568978, -0.08638716317173498}, { 1., 84.61829042994786, 75.33777148397068, -0.9720222660888188, 0.2348887273318101}, {1., 133.57079705663446`, 94.66892566665447, 0.937341185116139, -0.34841283369742887`}, {1., 128.43262009634088`, 146.7619824927731, 0.04610688062951141, 0.9989365122762387}, {1., 96.83003998158901, 84.6776292364314, 0.5878270340835674, -0.8089866364783268}, {1., 141.3496701138298, 80.51862282088518, -0.9065320580470174, 0.42213697745286305`}, {1., 97.15381892181357, 145.05492307709227`, -0.989389519157231, 0.14528723062204524`}, {1., 142.0227402517114, 146.14275533765309`, -0.48813096930321354`, -0.872770391802509}, { 1., 114.32960148723546`, 95.26699235278225, -0.9462957399375963, 0.3233022928714815}}, $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$22854$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$22855$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$22856$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$22857$$, 0], Hold[$CellContext`c$$, $CellContext`c$22858$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$22859$$, 0], Hold[$CellContext`h$$, $CellContext`h$22860$$, 0], Hold[$CellContext`e$$, $CellContext`e$22861$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$22862$$, 0], Hold[$CellContext`p$$, $CellContext`p$22863$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$22864$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, {{ 2., 0, 0, 0.9950399642338729, 0.09947597487560975}, {1., 101.17944708201343`, 83.25099003264178, 0.17498077196484313`, -0.9845718508278548}, {1., 80.92986537576647, 105.9922707904969, -0.11098344090152122`, -0.9938222556602657}, { 1., 92.4545078135768, 85.60696967038642, 0.9683366588686624, -0.24964798234929877`}, {1., 87.7966496020237, 118.49771378260587`, -0.6811108979641963, 0.7321802678810773}, {1., 106.2950279651265, 92.60607751403305, -0.8735451903438206, 0.4867430538047546}, {1., 134.5575062525946, 119.82718055612422`, 0.7662130744442337, -0.6425865891463306}, {1., 137.62687537081092`, 101.96655970374658`, 0.9230151313786289, 0.38476365114975764`}, { 1., 93.04884940276072, 141.71527583150484`, 0.29354822792136914`, 0.9559442650511712}, {1., 99.2520231642391, 99.27780098031916, -0.6230429832832968, -0.7821875996085911}, {1., 89.22320246445707, 93.13076695322638, -0.9153370719739162, 0.4026885206586075}, {1., 84.84537982474608, 106.33374468405358`, 0.19757413983556787`, 0.9802879471197407}, {1., 109.14652930766674`, 137.60937348056905`, 0.8395310642055362, 0.5433116897637301}, {1., 93.5317688218231, 129.27828619077943`, -0.5634947737100507, -0.8261196281419894}, { 1., 95.12874307242299, 147.85389716962996`, 0.06455561547883547, -0.9979141107881724}, {1., 148.26030964914202`, 143.98818003059702`, -0.4616503552109485, -0.8870619761513877}, { 1., 109.09419410760542`, 130.31471697717095`, -0.6149461899811809, 0.7885690733395707}, {1., 75.28094792675954, 134.71268032716355`, 0.5363649182570518, -0.8439861814408492}, {1., 146.13213556914948`, 105.6717677175598, -0.7036443032695336, 0.7105523868627369}, {1., 81.44250521300485, 144.10186434196575`, 0.43474838308648056`, 0.9005519659651466}, {1., 115.04644029506052`, 122.41120981383438`, -0.9154114960885383, -0.40251930739896685`}, { 1., 110.56809288214622`, 128.0426191728563, 0.2988873535182504, 0.9542883997549464}, {1., 101.72172893988312`, 78.60731910007351, 0.988577507656636, -0.15071334166354958`}, {1., 136.4325109309222, 118.9878684348138, 0.9939156516395393, 0.11014389418369963`}, {1., 103.15185224392454`, 128.25777738925706`, 0.0527448347075302, -0.9986080224050252}, {1., 78.2704211235427, 139.40631004301207`, 0.7162031537713178, -0.6978918558974722}, {1., 146.89264034170216`, 119.52477568994665`, -0.07666584625856242, -0.9970568429219362}, { 1., 136.61645733771385`, 123.08525372611284`, 0.9338705918357652, -0.3576111263709753}, {1., 108.36515373852961`, 149.16718903512873`, -0.7055368752170986, 0.7086732093912484}, { 1., 115.03859720099581`, 133.42377757574513`, 0.05425984727277311, 0.9985268494006234}, {1., 114.43428822018525`, 123.7016918421111, -0.4695547046578449, 0.8829033805200227}, {1., 98.4751342352293, 86.32104816487036, -0.7627096262255353, 0.6467410811622408}, {1., 106.32879829232155`, 96.68478962693409, -0.3435573408865479, -0.9391317019049907}, {1., 89.10114221545358, 128.73535961849132`, -0.9976105975672283, -0.069087593832452}, {1., 144.06763774977574`, 113.52572360260987`, -0.8553851510754186, -0.5179925128027272}, { 1., 116.50617226485763`, 89.37508918977312, 0.13512644270741994`, 0.9908283627759342}, {1., 96.06571264997208, 129.59796337914216`, -0.7520423006566466, 0.6591148443352326}, {1., 135.12948621672828`, 140.8103051089464, -0.06560722821237557, -0.9978455249217132}, {1., 98.04428417601915, 103.80930285648665`, -0.9962616413568978, -0.08638716317173498}, { 1., 84.61829042994786, 75.33777148397068, -0.9720222660888188, 0.2348887273318101}, {1., 133.57079705663446`, 94.66892566665447, 0.937341185116139, -0.34841283369742887`}, {1., 128.43262009634088`, 146.7619824927731, 0.04610688062951141, 0.9989365122762387}, {1., 96.83003998158901, 84.6776292364314, 0.5878270340835674, -0.8089866364783268}, {1., 141.3496701138298, 80.51862282088518, -0.9065320580470174, 0.42213697745286305`}, {1., 97.15381892181357, 145.05492307709227`, -0.989389519157231, 0.14528723062204524`}, {1., 142.0227402517114, 146.14275533765309`, -0.48813096930321354`, -0.872770391802509}, { 1., 114.32960148723546`, 95.26699235278225, -0.9462957399375963, 0.3233022928714815}}}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint]], \ $CellContext`i, $CellContext`nextLocation, $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx7dbdaIoZBAi3T 546oNwmONsl9kRflIge23Skb5DYg/+eidRQW498zwXmr1tVxQVsw+S5OSNzP Rp4VjwjkOfZhHHOZJRqX5QBx0bkHBVxswKV7LjJYpx+pYBu7vOROYVz//TuH +NLs4JClqQh1CxOigpyLj19kIy4RMZVBtF4sv/KPipc1ohjA2uwy+uGEPfzK E1uU/GkEtR2MTlO6MIbpefPQKvlROvwzci9p62EmnJCTkbmQWImUsTJkHz/k Ynrkx46DrtfI0PfsXof0BA1umR9OE6wbQeYSBO5HeoxhXBzBva4vlQ4UEWHf LYUMUD19LDHoFRfxTL0SuUm2HOOuDZX0nKQQoDs8eVDZ0h4E+fp33m7gIDr2 O7h8Vs1YfteFLg8/30OE7xquVzxYZDDY9jz5JnxGZ/i+MA/v5WLcztz2Rm1r OuzNOrud/6wNmFDMt+etcZG0z6JmnIGrWFwtjbDH8+9twWCWWSiCUsD8pjHr oTAXDTLuiuUINGJ6PeTYbymt1nD5Cv/rjdlUEJbirXg0WIvU3ZONyXPEv0vG mVRBJR0y2PX+ebo3lAjpDzbrR77hIlX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/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyzglRoUhUhKvV qJUiy1JxyyiCiBBBi2LRglRAGVZGEVAQLioYWZbtI8gVLvfH97x/v/fPa6vY HbhdT0dHRzm7/3OYKG5ZopbixgtjpzhXAbbal8f9kUdggcEnj3qeU/jMRvnx QKAEoXllj1TeIlxnOD/nHKJxNzgsfN+kGJNOq+vNm3l4fDB8TUcAD0LLwo2N O2gcsU5i1xZTkK1vueGv5sE56tR8i20E6j7EZB0IkMBEdiyS85GCT2/dSZvt IiR8mt3PcCDgVqtsjjSiYH62Ta8rhY/3bM4ah3NiGBn/qV1kSWAoMWx89Jwc VjY7FnMIGY6eYXdx8iUIu2fdvXeTCPviHjQ3Jwvh0nKXm5srgCR1tXVoAA0d L0lWMZOCjrmhdaEPDeephmm73ymwfLK/nDM9+z/jm2/S7vFxbcCtZq0zDdoX jjkFJEjzRZf3OnKhjl7KcPIgwTWv5UZtUiDpbkdEdwKN4RfzAgzzhRDNE6w8 c1iCkc0SubxejquapnqNrxCH6N5yRoQAIbobjF/Z8nG9b2qMUSnHDxZxyU0D MvisY5QXnuZBnVGZkHxbhuKS0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q/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.716888664842993*^9}, CellID->28375960,ExpressionUUID->"95d5bb40-c80f-47a9-9f3c-70f72bf90b1e"] }, Open ]], Cell[CellGroupData[{ Cell["", "SnapshotsSection",ExpressionUUID->"5ce7ae5f-f55c-4fce-b841-441b88eafbca"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = CompressedData[" 1:eJxFlHk0lHsYx+2ihYxbydRNKKnsxW17n6RIq2UMxizvRAlXStKVslYqdKdJ m5AbCdfNab1X6mcZaaIsxdgbyTaNmSj7xHXOPfed3znv+f3zOZ/v8/zO8z4G 7COufkoKCgrmM5+qAnGg0PCEYrAigMzURc3801YwnTYqVPfqxoosac3Zjb3Y f9hXLGlXsKHYyQ0CdOYeHfajgGrC51J9XhvSPqdfI0wRo/85hd1wQ/ceDTjV yw2+FvpAzTFrel5LN2JLK8fVWL0Eh0IjF4SnegBv8J2t3T1PUCo8Fa36XoLx LHVFzhZ1RO7U8M2Gbwuo8KD1mGPoAm8QtO+8GJsoxaxzw5Y2B1QQnJKF77Es iTfsJMsEi4Su8K2TzB3h9KPq20WF9M1dBLfOMtv5xB0WtN7WbJcIqNDZccDC cJUYJcgkf+7z6yC4scwRfD3NC8hxiUl2XQwwsHnv/FjYhpldeX0nL1neb4ol f+EaJx8YKpSFrSJ5Qkrf8jFl8w/Y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Ud7NK3suxco6TGkosoSor5iKo3EjHNLvJSeV F+Og0mS/S7uzDxtpw1NIyz4TvsTTy6zf5bpDp3jtfZMOHGavGrs5VSpCXTvU 0yWJ8nmZUrdS1uBTQIN3K0NTlw3aQTrF3gskWHjyddaJqgYid2Rv55yxVBzI EY1aYZcZENQa+c+g0wCKRk7OodXNhG+HCelzI+DA5B7krvdnQfSaN/QJLzFG CiwcPF/QTnC3YyN9BTP773J+xoG6ISp07E/UqXAcQNwV0aWVdXLfNMfQXudn BoSTR8+QntOgInNjsEVCAza+19rt+HL53pgg1btHHWaBhdD+Pt2BAQexuN5y bynmO3+OnulVPsFdIOH2EfWuUGFDRo9jWHArTi8L29iAWXiEmCy0kPsOhzx8 Fs/3BGk410VyHAcz4/hQu08daNHJ7lxddTHBUcYzVmflM8A+ITXCQMgCWV/B dF9tB7bPel+BYLZ83+8f1no9F2MDaWBwh6U7C9TMaQkxNClKiza7m36Wj/4F yBgnQg== "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], CompressedData[" 1:eJxFlHk0lHsYx+2ihYxbydRNKKnsxW17n6RIq2UMxizvRAlXStKVslYqdKdJ m5AbCdfNab1X6mcZaaIsxdgbyTaNmSj7xHXOPfed3znv+f3zOZ/v8/zO8z4G 7COufkoKCgrmM5+qAnGg0PCEYrAigMzURc3801YwnTYqVPfqxoosac3Zjb3Y f9hXLGlXsKHYyQ0CdOYeHfajgGrC51J9XhvSPqdfI0wRo/85hd1wQ/ceDTjV yw2+FvpAzTFrel5LN2JLK8fVWL0Eh0IjF4SnegBv8J2t3T1PUCo8Fa36XoLx LHVFzhZ1RO7U8M2Gbwuo8KD1mGPoAm8QtO+8GJsoxaxzw5Y2B1QQnJKF77Es iTfsJMsEi4Su8K2TzB3h9KPq20WF9M1dBLfOMtv5xB0WtN7WbJcIqNDZccDC cJUYJcgkf+7z6yC4scwRfD3NC8hxiUl2XQwwsHnv/FjYhpldeX0nL1neb4ol f+EaJx8YKpSFrSJ5Qkrf8jFl8w/Yj58mdb7TJQQ36r9OvKjTDVqCF0fEajFA tN6qtX3DB2SX1bV3kibn9Bu3301rc4MNkW/2F7exoLJiVmGTYR/WbZTPuKrY TdQne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 0yWJ8nmZUrdS1uBTQIN3K0NTlw3aQTrF3gskWHjyddaJqgYid2Rv55yxVBzI EY1aYZcZENQa+c+g0wCKRk7OodXNhG+HCelzI+DA5B7krvdnQfSaN/QJLzFG CiwcPF/QTnC3YyN9BTP773J+xoG6ISp07E/UqXAcQNwV0aWVdXLfNMfQXudn BoSTR8+QntOgInNjsEVCAza+19rt+HL53pgg1btHHWaBhdD+Pt2BAQexuN5y bynmO3+OnulVPsFdIOH2EfWuUGFDRo9jWHArTi8L29iAWXiEmCy0kPsOhzx8 Fs/3BGk410VyHAcz4/hQu08daNHJ7lxddTHBUcYzVmflM8A+ITXCQMgCWV/B dF9tB7bPel+BYLZ83+8f1no9F2MDaWBwh6U7C9TMaQkxNClKiza7m36Wj/4F yBgnQg== "]}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$23260$$ = 0, $CellContext`rs$23261$$ = 0, $CellContext`ra$23262$$ = 0, $CellContext`\[Rho]a$23263$$ = 0, $CellContext`c$23264$$ = 0, $CellContext`\[Rho]s$23265$$ = 0, $CellContext`h$23266$$ = 0, $CellContext`e$23267$$ = 0, $CellContext`\[Delta]$23268$$ = 0, $CellContext`p$23269$$ = 0, $CellContext`moving$23270$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = CompressedData[" 1:eJxFlHk0lHsYx+2ihYxbydRNKKnsxW17n6RIq2UMxizvRAlXStKVslYqdKdJ m5AbCdfNab1X6mcZaaIsxdgbyTaNmSj7xHXOPfed3znv+f3zOZ/v8/zO8z4G 7COufkoKCgrmM5+qAnGg0PCEYrAigMzURc3801YwnTYqVPfqxoosac3Zjb3Y f9hXLGlXsKHYyQ0CdOYeHfajgGrC51J9XhvSPqdfI0wRo/85hd1wQ/ceDTjV yw2+FvpAzTFrel5LN2JLK8fVWL0Eh0IjF4SnegBv8J2t3T1PUCo8Fa36XoLx LHVFzhZ1RO7U8M2Gbwuo8KD1mGPoAm8QtO+8GJsoxaxzw5Y2B1QQnJKF77Es iTfsJMsEi4Su8K2TzB3h9KPq20WF9M1dBLfOMtv5xB0WtN7WbJcIqNDZccDC cJUYJcgkf+7z6yC4scwRfD3NC8hxiUl2XQwwsHnv/FjYhpldeX0nL1neb4ol f+EaJx8YKpSFrSJ5Qkrf8jFl8w/Yj58mdb7TJQQ36r9OvKjTDVqCF0fEajFA tN6qtX3DB2SX1bV3kibn9Bu3301rc4MNkW/2F7exoLJiVmGTYR/WbZTPuKrY TdQneVY5d4MTDpeVr9i/16MD+5NN1amnA6ipREJqKRMQ3I1HpRdLOT4gM/ld K+gSDRx7DK26piSYBtWvWr+uhshVcgpyUPlOh/qS+N+UBTM39ePb+cXdqHrJ 0sTISPkcMPKP5J10oMPkh7TRUwMs+Oik07zaoQ7z166ibKmVEFxP8zbRTU8K CGL0eyRMT0gfkmx+USREIY2SWA/HLwR3NsfWe0sODtdM1SiiYByKJ/eEcfol SKfOf3LjpVqivkPGDedSa9xhWsXEZeSID9Q6F9sAg4fxfpVy069LCd9SVVUN 83kMyBilnPGNcoM4+5Ojh7OlWLptRHnyZBnhU8918mC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VmflM8A+ITXCQMgCWV/B dF9tB7bPel+BYLZ83+8f1no9F2MDaWBwh6U7C9TMaQkxNClKiza7m36Wj/4F yBgnQg== "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$23260$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$23261$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$23262$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$23263$$, 0], Hold[$CellContext`c$$, $CellContext`c$23264$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$23265$$, 0], Hold[$CellContext`h$$, $CellContext`h$23266$$, 0], Hold[$CellContext`e$$, $CellContext`e$23267$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$23268$$, 0], Hold[$CellContext`p$$, $CellContext`p$23269$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$23270$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, CompressedData[" 1:eJxFlHk0lHsYx+2ihYxbydRNKKnsxW17n6RIq2UMxizvRAlXStKVslYqdKdJ m5AbCdfNab1X6mcZaaIsxdgbyTaNmSj7xHXOPfed3znv+f3zOZ/v8/zO8z4G 7COufkoKCgrmM5+qAnGg0PCEYrAigMzURc3801YwnTYqVPfqxoosac3Zjb3Y f9hXLGlXsKHYyQ0CdOYeHfajgGrC51J9XhvSPqdfI0wRo/85hd1wQ/ceDTjV yw2+Fvp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4KZeBvaj Td6wzn/1Hdkpd5glKKL5zqlDS8wukBWb5HM/V6akbtvFgllF0qinHkyQVf4l msoToMDUQ5Obnw8Q9TVN1KWcv8cGm4vUfvMJHHb4c7Vc+FLEWdjSmX3+BeFT TXs5EHeDBQqnH7haCKlwclmZnYHd3yg4wAxtbZW/XwYvM0dh5v94zDh9Av3B hpJE+lLtmn6suSHwwaIv8nfRTeuljnxnQfC5ry1WM9xhjjo4anchseL2M9mP +glO9lCz0t4bh6oC8qvoMipEUd7NK3suxco6TGkosoSor5iKo3EjHNLvJSeV F+Og0mS/S7uzDxtpw1NIyz4TvsTTy6zf5bpDp3jtfZMOHGavGrs5VSpCXTvU 0yWJ8nmZUrdS1uBTQIN3K0NTlw3aQTrF3gskWHjyddaJqgYid2Rv55yxVBzI EY1aYZcZENQa+c+g0wCKRk7OodXNhG+HCelzI+DA5B7krvdnQfSaN/QJLzFG CiwcPF/QTnC3YyN9BTP773J+xoG6ISp07E/UqXAcQNwV0aWVdXLfNMfQXudn BoSTR8+QntOgInNjsEVCAza+19rt+HL53pgg1btHHWaBhdD+Pt2BAQexuN5y bynmO3+OnulVPsFdIOH2EfWuUGFDRo9jWHArTi8L29iAWXiEmCy0kPsOhzx8 Fs/3BGk410VyHAcz4/hQu08daNHJ7lxddTHBUcYzVmflM8A+ITXCQMgCWV/B dF9tB7bPel+BYLZ83+8f1no9F2MDaWBwh6U7C9TMaQkxNClKiza7m36Wj/4F yBgnQg== "]}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint] ], $CellContext`i, $CellContext`nextLocation, \ $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9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ylZOL/PD++DpbcUg89Pr fho594uCKQ1Cva5b8u8fQgZeCVH0Hk9g+bm8yi17TCaDeLBBWFwAEdLapzt9 CWyk0XRyS3kZfh8f52kcU9tJBPTHgMQ2QybINhW7zSjeQqQ91C51/YP3QeZh izG6pAMYu+RQBZSpcCmk89NloXzE5+7IjdZp/Bwh1GtTDxoZILoh95Q6LxF8 DRUX08JH0CNJ/R9P5+L3ElW6RdLvcTR4HFCStNtxfX8NbBPK9x9CsjYoE5Wc 8LkU1G4pD1ZggFfq90EWiwpcyTYNg7AJNNVmW32/FT6Xm+csE+LSyLB7PvBa EX09bmT1zqkfXERYxT3QWOouFncwcnepcS4NhAze5X9dv7f/Lf78pDRhECmf 9z3rqYfXLSer8NJbbzKsvp3yHfudCKqb+MP9lrjIBY19Eem/p2GcHWfnEcsa AuSa/dR5PJgMbvKZ7FVXDhKjqVapN9uCcSdV6NrLUfawMM6+eeiJLVza0a/g p9GJelwc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlG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33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.7168886822025347`*^9}, CellID->230431650,ExpressionUUID->"0b4894ef-9618-450b-a4d1-8e4fafb7eda5"], Cell[BoxData[ TagBox[ StyleBox[ Dynamic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ellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], CompressedData[" 1:eJxF1Hs0VHkcAPBJiR4ieqImKzXbVpPaiDP1+67KYWj1EDPGzNw7Hi0ldES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7n19iNNXRj4BLcW9lrshHCxHt36pBKVtD6IHb6jpOYWN/VTODMOg68t9D0z tvKAHR/CexHxCgkzbfoKkt9R8cYWdtuHH8GgqWGKveF9L2Dyo7YLU6WIZSnf l9ql3Y/srFN/63GFUNs4FrRnrwDi6/xnp7Yp0DWZ95TpuLYvXMItuSRbCCzH 9V3Bk3hQ5H4MVY51I4IT+l4Uqd3L4IHNMTseYIDTOpJbLDAIbR4OubLqLhEn ZpVteKW972Ze7rL6fs1eGInbQ5NEsK1iFnPRCEkIP9eJ8hNvUO63E3N9GNWa PedFLJowhQtZtQOWjmdk6Fl6ZcC2hdp7dNZHTu8QecOND8PlBmoRsH55cPfw 8zdEbt/pqzRcQbl076DSnR0YbB+3CsvpEEEM9iU1qrKN6LXINle4avvnkTdd 1K7EoVOtXuDx0RN2GdrOsZOqEFbEZOmrmyiXkGCa7XIJh5nCsnhRCw7rVppN +0Os2fNszIGZW0XNbXe/6ZorlR5A7+MRHCcRbGE+Or6yRoVaHAwaRRnaPVfm yNVv2BwIi/2ng9uu6Y/5pqALriSaOOMvRlPuU8plrPO4sJqPg96nnnpluAD0 Wd/3N2aQRFuOtPzJ0hoq76qQiZvTb+GwpYXxc1ciBh7Pmw8x56kQ93SSo+fD VsrRZxr2rmML4bN1gdKtzBuSM6sX9M2Qo6Hb0UdGArXzbYiPSrgVKIShUpsi UvNefGUdVxVREsTQufQ4pUbbv0O9nI84iQE3yt+5tYUPdwrodeYn5OhV9TGj 6Dn9VN4bs90uYXYcGAyVNgjScFi+9bjF5MUkOlm9PPdieCMVb8jf8miRlAuD Yn6MThkO8Z20Q7IGEn1cVptZ2FpFObOLZPFFzf8v5tTc14JaDN4ThhOX1pHo mZmtX5DkPpUXbRqaOTpNBE8mVY46TdbU2bUxlHzYS9gmRnPyvN4S/wKQIB8H "]}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$24051$$ = 0, $CellContext`rs$24052$$ = 0, $CellContext`ra$24053$$ = 0, $CellContext`\[Rho]a$24054$$ = 0, $CellContext`c$24055$$ = 0, $CellContext`\[Rho]s$24056$$ = 0, $CellContext`h$24057$$ = 0, $CellContext`e$24058$$ = 0, $CellContext`\[Delta]$24059$$ = 0, $CellContext`p$24060$$ = 0, $CellContext`moving$24061$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = CompressedData[" 1:eJxF1Hs0VHkcAPBJiR4ieqImKzXbVpPaiDP1+67KYWj1EDPGzNw7Hi0ldESy KRUqRWgJ2xZ6UIq8kuT2sCKjUHZiMhhmyqO5ilF62Tlnz9655/z++5zv9/v7 fn/fayEK3u6nQ6PRmJqjS6M+EDmFLzN+sQ3eegb43e3yAKbxsaXq3STyXm5+ cK9dHfEfG0JTfa4xL7ryId85X/ahzRtG/Q44DzT3I5qv8dyksG70v9O5OfOp ChOC7XVv3xN5ArDOdfi+S1eO9E0rVoWG9lOuhLYhfUmYAEpjDCfIG/lA52UW 91/vRz5Ju9oGCrXx9HfTC53jBKAYf+owNlsAzecO7w0xH0TVCbuamOdklJN0 ZjaXmWKwWJZYOHyUC23GVsU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ZcC2hdp7dNZHTu8QecOND8PlBmoRsH55cPfw 8zdEbt/pqzRcQbl076DSnR0YbB+3CsvpEEEM9iU1qrKN6LXINle4avvnkTdd 1K7EoVOtXuDx0RN2GdrOsZOqEFbEZOmrmyiXkGCa7XIJh5nCsnhRCw7rVppN +0Os2fNszIGZW0XNbXe/6ZorlR5A7+MRHCcRbGE+Or6yRoVaHAwaRRnaPVfm yNVv2BwIi/2ng9uu6Y/5pqALriSaOOMvRlPuU8plrPO4sJqPg96nnnpluAD0 Wd/3N2aQRFuOtPzJ0hoq76qQiZvTb+GwpYXxc1ciBh7Pmw8x56kQ93SSo+fD VsrRZxr2rmML4bN1gdKtzBuSM6sX9M2Qo6Hb0UdGArXzbYiPSrgVKIShUpsi UvNefGUdVxVREsTQufQ4pUbbv0O9nI84iQE3yt+5tYUPdwrodeYn5OhV9TGj 6Dn9VN4bs90uYXYcGAyVNgjScFi+9bjF5MUkOlm9PPdieCMVb8jf8miRlAuD Yn6MThkO8Z20Q7IGEn1cVptZ2FpFObOLZPFFzf8v5tTc14JaDN4ThhOX1pHo mZmtX5DkPpUXbRqaOTpNBE8mVY46TdbU2bUxlHzYS9gmRnPyvN4S/wKQIB8H "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$24051$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$24052$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$24053$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$24054$$, 0], Hold[$CellContext`c$$, $CellContext`c$24055$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$24056$$, 0], Hold[$CellContext`h$$, $CellContext`h$24057$$, 0], Hold[$CellContext`e$$, $CellContext`e$24058$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$24059$$, 0], Hold[$CellContext`p$$, $CellContext`p$24060$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$24061$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, CompressedData[" 1:eJxF1Hs0VHkcAPBJiR4ieqImKzXbVpPaiDP1+67KYWj1EDPGzNw7Hi0ldESy KRUqRWgJ2xZ6UIq8kuT2sCKjUHZiMhhmyqO5ilF62Tlnz9655/z++5zv9/v7 fn/fayEK3u6nQ6PRmJqjS6M+EDmFLzN+sQ3eegb43e3yAKbxsaXq3STyXm5+ cK9dHfEfG0JTfa4xL7ryId85X/ahzRtG/Q44DzT3I5qv8dyksG70v9O5OfOp ChOC7XVv3xN5ArDOdfi+S1eO9E0rVoWG9lOuhLYhfUmYAEpjDCfIG/lA52UW 91/vRz5Ju9oGCrXx9HfTC53jBKAYf+owNlsAzecO7w0xH0TVCbuamOdklJN0 ZjaXmWKwWJZYOHyUC23GVsUupnKkVPadZ/ho81oTJPt1DQYDEotAvbVcELg7 7593VobuD44yziwYpBy2PmLqfHMBZIyqAxc4COGr9carO76RaClbZRzCyKSc tPQa2ZIlhDVXKqQFCh7I2RfSHHW70YjbcWQyf4ByngcDuFnjXpB9ufmECxMD +4AdkUv2kYgsayAP33lCubklsFis4ECO79oS93Qc6pw8b9kEk0h3xdGGA2qt wyUs8cmpONhI4ryqzPgQtmQ8wr9cRQREzpbkf2qmnLP/9YMuXkJISJUmf+YL 4M9HDwwtdLqR1eVnI9PNtPWl2DldM5ivmduUr7qcNwKgM3ol/ntI9DJw+Yq1 q7TvoNR4JPH5ZAGocoeeiQU4pHTFbv+95iFK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M6sX9M2Qo6Hb0UdGArXzbYiPSrgVKIShUpsi UvNefGUdVxVREsTQufQ4pUbbv0O9nI84iQE3yt+5tYUPdwrodeYn5OhV9TGj 6Dn9VN4bs90uYXYcGAyVNgjScFi+9bjF5MUkOlm9PPdieCMVb8jf8miRlAuD Yn6MThkO8Z20Q7IGEn1cVptZ2FpFObOLZPFFzf8v5tTc14JaDN4ThhOX1pHo mZmtX5DkPpUXbRqaOTpNBE8mVY46TdbU2bUxlHzYS9gmRnPyvN4S/wKQIB8H "]}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint] ], $CellContext`i, $CellContext`nextLocation, \ $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx7dbdaIoZBAi3T 546oNwmONsl9kRflIge23Skb5DYg/+eidRQW498zwXmr1tVxQVsw+S5OSNzP Rp4VjwjkOfZhHHOZJRqX5QBx0bkHBVxswKV7LjJYpx+pYBu7vOROYVz//TuH +NLs4JClqQh1CxOigpyLj19kIy4RMZVBtF4sv/KPipc1ohjA2uwy+uGEPfzK E1uU/GkEtR2MTlO6MIbpefPQKvlROvwzci9p62EmnJCTkbmQWImUsTJkHz/k Ynrkx46DrtfI0PfsXof0BA1umR9OE6wbQeYSBO5HeoxhXBzBva4vlQ4UEWHf LYUMUD19LDHoFRfxTL0SuUm2HOOuDZX0nKQQoDs8eVDZ0h4E+fp33m7gIDr2 O7h8Vs1YfteFLg8/30OE7xquVzxYZDDY9jz5JnxGZ/i+MA/v5WLcztz2Rm1r OuzNOrud/6wNmFDMt+etcZG0z6JmnIGrWFw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wc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyzglRoUhUhKvV qJUiy1JxyyiCiBBBi2LRglRAGVZGEVAQLioYWZbtI8gVLvfH97x/v/fPa6vY HbhdT0dHRzm7/3OYKG5ZopbixgtjpzhXAbbal8f9kUdggcEnj3qeU/jMRvnx QKAEoXllj1TeIlxnOD/nHKJxNzgsfN+kGJNOq+vNm3l4fDB8TUcAD0LLwo2N O2gcsU5i1xZTkK1vueGv5sE56tR8i20E6j7EZB0IkMBEdiyS85GCT2/dSZvt IiR8mt3PcCDgVqtsjjSiYH62Ta8rhY/3bM4ah3NiGBn/qV1kSWAoMWx89Jwc VjY7FnMIGY6eYXdx8iUIu2fdvXeTCPviHjQ3Jwvh0nKXm5srgCR1tXVoAA0d L0lWMZOCjrmhdaEPDeephmm73ymwfLK/nDM9+z/jm2/S7vFxbcCtZq0zDdoX jjkFJEjzRZf3OnKhjl7KcPIgwTWv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P5g0dkgGvkXCpr6i/gY3Md+lZMnwlm/ao/JDjG8 VHHk75YK5GSzm6UcAuNPVac3PKCwqWTny6XeBObH22ZEz6GQlLqlZyRbBNOK UyltaWJsjAlZf65Wjlq/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.716888779905688*^9}, CellID->89335050,ExpressionUUID->"07dda37d-dc0b-46fb-b5cc-206b7cb1806f"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/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Nbc/p7OCCqubNUGpUj mB3gFVcxSnMLq9a51x7AEH+53oc8JNBbQiKeHG0RWC5utuB9pOeodaeuXPGQ A5JgyR89PC7ci90u/3efKdi5CcPUfvufczgsir1Kze+aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZpmsfnKEQzZ+SGPqyn/EhMl hRKZSMBwlwyI4mjOMnxk7swEDCHzPdt1ownsstmxYme/DGkyta2rGbQvCRlq uOswhjG9R+28swSypfk+R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DVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$24478$$ = 0, $CellContext`rs$24479$$ = 0, $CellContext`ra$24480$$ = 0, $CellContext`\[Rho]a$24481$$ = 0, $CellContext`c$24482$$ = 0, $CellContext`\[Rho]s$24483$$ = 0, $CellContext`h$24484$$ = 0, $CellContext`e$24485$$ = 0, $CellContext`\[Delta]$24486$$ = 0, $CellContext`p$24487$$ = 0, $CellContext`moving$24488$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZpmsfnKEQzZ+SGPqyn/EhMl hRKZSMBwlwyI4mjOMnxk7swEDCHzPdt1ownsstmxYme/DGkyta2rGbQvCRlq uOswhjG9R+28swSypfk+Rec7BVObLE015tB6wXkRiTHuGPZCt9OIHxfYNROF NxuFgjz9dWm7Z37nyy+8iskZGAxbh2w3fiVQ5jzDe3RILkj0EPuKGG+VnDBy 46fThzAwbHtdUsUEMo/VDp5zbEHswXII/dqv5LIidOr0KV8K3qydNTJKwLGk 0bB8qAPdG1SdUbmBrk8mDovmR2DIUpSpnoohYF5i8WTX42aBzsrXmZrf9S37 4RgjPgqDU9GrZ7xYAgYNxjEmVVJ0jM99yuqjfZltJzy3ZwxDZ4dJwnlDDrBW 87SX6mQhA4OPOrLPdF5Uo/azg5gc0JXrar/v4sKlNytD32j3I94O3e5tJa+V 3KaZ3gzLPAI2v+lWg5YH+GV2KRJGKtFTp95Hq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$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$24478$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$24479$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$24480$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$24481$$, 0], Hold[$CellContext`c$$, $CellContext`c$24482$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$24483$$, 0], Hold[$CellContext`h$$, $CellContext`h$24484$$, 0], Hold[$CellContext`e$$, $CellContext`e$24485$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$24486$$, 0], Hold[$CellContext`p$$, $CellContext`p$24487$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$24488$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3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gt5NjRLza12WPQWRVyLmoKAdcXaS9jeM/R l6nYjDeZ9sXebTwl3xADO64xSOtXLiSUzGcF7B9Afh2yyOs1tUouw75d7nUK Q+ZfLf3Mmn/zN9GRWtWAthTwr4uZtN6zluTbNhoE2gNbc/p7OCCqubNUGpUj mB3gFVcxSnMLq9a51x7AEH+53oc8JNBbQiKeHG0RWC5utuB9pOeodaeuXPGQ A5JgyR89PC7ci90u/3efKdi5CcPUfvufczgsir1Kze+aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint]], \ $CellContext`i, $CellContext`nextLocation, $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx7dbdaIoZBAi3T 546oNwmONsl9kRflIge23Skb5DYg/+eidRQW498zwXmr1tVxQVsw+S5OSNzP Rp4VjwjkOfZhHHOZJRqX5QBx0bkHB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6pAMYu+RQBZSpcCmk89NloXzE5+7IjdZp/Bwh1GtTDxoZILoh95Q6LxF8 DRUX08JH0CNJ/R9P5+L3ElW6RdLvcTR4HFCStNtxfX8NbBPK9x9CsjYoE5Wc 8LkU1G4pD1ZggFfq90EWiwpcyTYNg7AJNNVmW32/FT6Xm+csE+LSyLB7PvBa EX09bmT1zqkfXERYxT3QWOouFncwcnepcS4NhAze5X9dv7f/Lf78pDRhECmf 9z3rqYfXLSer8NJbbzKsvp3yHfudCKqb+MP9lrjIBY19Eem/p2GcHWfnEcsa AuSa/dR5PJgMbvKZ7FVXDhKjqVapN9uCcSdV6NrLUfawMM6+eeiJLVza0a/g p9GJelwc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyzglRoUhUhKvV qJUiy1JxyyiCiBBBi2LRglRAGVZGEVAQLioYWZbtI8gVLvfH97x/v/fPa6vY HbhdT0dHRzm7/3OYKG5Zopbixgtjp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saJNjIr0g0/cDYTIqTaoOBFAIMihURO+l0LI TaWnHk8CRpVo8U/LeWh8+Zfy4Y9CuPdbSv8zJYSyJeRxyz0Fmr51pCJfC1CW k2Tft4qG2dW3rOQrFPo7lU6upiSmP0qOhi/gobO8+MTuSgpkZt+9n+by8aFh UWNPoRA2igzpoTISAz8S62LbZ72WwHSFIQ3t2+80Nq0kjlxZ3+6pS8GX1eJk VBOITKby4PlqEkz3elfen3xM6ty5RnAprBoeGA5r4uNJ1bJOrxAZtDGc0iSW Ai+H3BrMkiSQnHrHvMSU4b+W1EZ9by5+qSjwzEuXQbdhsl0eyMU/DPMty6xJ bPbZtbfbjw9NncaD2S9HdP5g0dkgGvkXCpr6i/gY3Md+lZMnwlm/ao/JDjG8 VHHk75YK5GSzm6UcAuNPVac3PKCwqWTny6XeBObH22ZEz6GQlLqlZyRbBNOK UyltaWJsjAlZf65Wjlq/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellChangeTimes->{3.716888804521734*^9}, CellID->9651793,ExpressionUUID->"a0b299e1-8a92-4696-87eb-4ec1f003f01f"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = CompressedData[" 1:eJxVlHs0lGkcx4VpW6tdlw3DEmq3aTBUCI3t0Y2wKYe3scSMsqTRhahVSoaW XQ7SxaXtsmrYtbVLe1SKdyn3LrQbmomSU20YlxHNouzzPM56n+ac97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qt3WYN9M+d1Yl+D OW2an0BfU96Ow6SvXrb6WaS31PnJUaQXb2xtw4V6Rlufvo0l9O5+3orvZcHi l8mIC7zcfNwUco6VPz8kfXUl0TeQ78YV/B7km7Hu/hpH6KuzUPaAR/peeKZA 3MUxnSbEibmtYjSX0ePuO8l3uSRId5k8gwLF/7bm1hqKgF20xKLIqIdO6Sp0 iLrE3EGcvViK8r1L2ozzlU9eX2QM82n1nyv4lshXuqfrRU84BYIi67WKhoTA 7GoGHWII3+WB6gY/J4aTC2vxfmtunsVzHlk+X4Hm7C/NlZH7dRCw8T5G/CWY yyu95Yi4fX9Wv/fOvWXSMdR37HQUvr/nX+Yko/s72WYnJ+8vz7R9BHGuc6zw 3gylj9zRXKLtthSTc2Fn608gLtlvQz3i7Ermbkf/48G3fs3dTXAH1Uxxvj2c 6bu6VnyGh/K5h+SyyHwLthVphUG96ndLapBep1P/KAvq1QmmKuIJvfjh6b7p ntN9+QEKe6QHeq3eu9P5VuNlWyF3Pn1s/WbIOcfcefdaIKMHG7Sb8hczHLCU VY97QT2gqtw+IgSfqee38nvg+1AEDD8M6Kb/A/5EE+I= "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZp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53oc8JNBbQiKeHG0RWC5utuB9pOeodaeuXPGQ A5JgyR89PC7ci90u/3efKdi5CcPUfvufczgsir1Kze+aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$24478$$ = 0, $CellContext`rs$24479$$ = 0, $CellContext`ra$24480$$ = 0, $CellContext`\[Rho]a$24481$$ = 0, $CellContext`c$24482$$ = 0, $CellContext`\[Rho]s$24483$$ = 0, $CellContext`h$24484$$ = 0, $CellContext`e$24485$$ = 0, $CellContext`\[Delta]$24486$$ = 0, $CellContext`p$24487$$ = 0, $CellContext`moving$24488$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZpmsfnKEQzZ+SGPqyn/EhMl hRKZSMBwlwyI4mjOMnxk7swEDCHzPdt1ownsstmxYme/DGkyta2rGbQvCRlq uOswhjG9R+28swSypfk+Rec7BVObLE015tB6wXkRiTHuGPZCt9OIHxfYNROF NxuFgjz9dWm7Z37nyy+8iskZGAxbh2w3fiVQ5jzDe3RILkj0EPuKGG+VnDBy 46fThzAwbHtdUsUEMo/VDp5zbEHswXII/dqv5LIidOr0KV8K3qydNTJKwLGk 0bB8qAPdG1SdUbmBrk8mDovmR2DIUpSpnoohYF5i8WTX42aBzsrXmZrf9S37 4RgjPgqDU9GrZ7xYAgYNxjEmVVJ0jM99yuqjfZltJzy3ZwxDZ4dJwnlDDrB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PX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$24478$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$24479$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$24480$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$24481$$, 0], Hold[$CellContext`c$$, $CellContext`c$24482$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$24483$$, 0], Hold[$CellContext`h$$, $CellContext`h$24484$$, 0], Hold[$CellContext`e$$, $CellContext`e$24485$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$24486$$, 0], Hold[$CellContext`p$$, $CellContext`p$24487$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$24488$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw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x3Y9VKQJmqX K3zo/uZfXVGguIRh2xW9uaqPCVz9qYY0HOxBOzVPb3y/S6bk2r4VW289i+Gu daxW2x0ChTA0+OfKLuRh89ksl9Gt5NjRLza12WPQWRVyLmoKAdcXaS9jeM/R l6nYjDeZ9sXebTwl3xADO64xSOtXLiSUzGcF7B9Afh2yyOs1tUouw75d7nUK Q+ZfLf3Mmn/zN9GRWtWAthTwr4uZtN6zluTbNhoE2gNbc/p7OCCqubNUGpUj mB3gFVcxSnMLq9a51x7AEH+53oc8JNBbQiKeHG0RWC5utuB9pOeodaeuXPGQ A5JgyR89PC7ci90u/3efKdi5CcPUfvufczgsir1Kze+aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint]], \ $CellContext`i, $CellContext`nextLocation, $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx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CVH0Hk9g+bm8yi17TCaDeLBBWFwAEdLapzt9 CWyk0XRyS3kZfh8f52kcU9tJBPTHgMQ2QybINhW7zSjeQqQ91C51/YP3QeZh izG6pAMYu+RQBZSpcCmk89NloXzE5+7IjdZp/Bwh1GtTDxoZILoh95Q6LxF8 DRUX08JH0CNJ/R9P5+L3ElW6RdLvcTR4HFCStNtxfX8NbBPK9x9CsjYoE5Wc 8LkU1G4pD1ZggFfq90EWiwpcyTYNg7AJNNVmW32/FT6Xm+csE+LSyLB7PvBa EX09bmT1zqkfXERYxT3QWOouFncwcnepcS4NhAze5X9dv7f/Lf78pDRhECmf 9z3rqYfXLSer8NJbbzKsvp3yHfudCKqb+MP9lrjIBY19Eem/p2GcHWfnEcsa AuSa/dR5PJgMbvKZ7FVXDhKjqVapN9uCcSdV6NrLUfawMM6+eeiJLVza0a/g p9GJelwc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyz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j8Gi6+6DxX+maP DP7jXG2DrRAJqu0XIn6j0F3cfz1OJcKMcev9pGVczL1vTfl+TcC1pFJAXaOQ Kl028GitBCu7FtYdpwXIM1rTsaJNjIr0g0/cDYTIqTaoOBFAIMihURO+l0LI TaWnHk8CRpVo8U/LeWh8+Zfy4Y9CuPdbSv8zJYSyJeRxyz0Fmr51pCJfC1CW k2Tft4qG2dW3rOQrFPo7lU6upiSmP0qOhi/gobO8+MTuSgpkZt+9n+by8aFh UWNPoRA2igzpoTISAz8S62LbZ72WwHSFIQ3t2+80Nq0kjlxZ3+6pS8GX1eJk VBOITKby4PlqEkz3elfen3xM6ty5RnAprBoeGA5r4uNJ1bJOrxAZtDGc0iSW Ai+H3BrMkiSQnHrHvMSU4b+W1EZ9by5+qSjwzEuXQbdhsl0eyMU/DPMty6xJ bPbZtbfbjw9NncaD2S9HdP5g0dkgGvkXCpr6i/gY3Md+lZMnwlm/ao/JDjG8 VHHk75YK5GSzm6UcAuNPVac3PKCwqWTny6XeBObH22ZEz6GQlLqlZyRbBNOK UyltaWJsjAlZf65Wjlq/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->694383038,ExpressionUUID->"afb2315a-ebd4-4fab-a379-dbd79abc0163"], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`ag$$ = CompressedData[" 1:eJxTTMoPSmViYGDQB2JWBjhwEBRV+7/lgLTDrZ8Tj4YJajv4JKzv+p5wc//D lHXcyQlv90OUfbCvNH0nvPDJZ/uGBM3r/l4/7G1jg+O36q3dL1qifGTdp/dw dRaMlWrTfF/by9g8OPgs5be9VBe/br/Vq/0e906pvA15NODqiPXHcPFv9/mz YH/s6iwE++PKRXE3kD8qGqxo6g+GiNmMjqtr7W9s8tox9+GO/W8eyG5v7Hu0 /7nxS+FPgq+GXfwOVHqhtn+HS7ofqHAZaelgsKujd/4FAKbIL4Y= "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{ Hold["Sheep"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`n$$], 46, "number of nearest neighbours"}, 1, 46, 1}, {{ Hold[$CellContext`rs$$], 65, "shepherd detection distance"}, 1, 150.}, {{ Hold[$CellContext`ra$$], 2, "sheep to sheep interaction distance"}, 0, 150.}, {{ Hold[$CellContext`\[Rho]a$$], 2, "relative strength of repulsion from other sheep"}, 0, 10}, {{ Hold[$CellContext`c$$], 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10}, {{ Hold[$CellContext`\[Rho]s$$], 1, "relative strength of repulsion from shepherd"}, 0, 10}, {{ Hold[$CellContext`h$$], 0.5, "relative strength of proceeding in previous direction"}, 0, 10}, {{ Hold[$CellContext`e$$], 0.3, "relative strength of angular noise"}, 0, 10}, {{ Hold[$CellContext`\[Delta]$$], 1, "displacement per step"}, 0, 10}, {{ Hold[$CellContext`p$$], 0.05, "probability of moving while grazing"}, 0, 1}, { Hold["Shepherd"], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`\[Delta]s$$], 1.5, "displacement per step"}, 0, 10}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, {{ Hold[$CellContext`moving$$], False, "run simulation"}, { True, False}}, {{ Hold[$CellContext`ag$$], CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZpmsfnKEQzZ+SGPqyn/EhMl hRKZSMBwlwyI4mjOMnxk7swEDCHzPdt1ownsstmxYme/DGkyta2rGbQvCRlq uOswhjG9R+28swSypfk+Rec7BVObLE015tB6wXkRiTHuGPZCt9OIHxfYNROF NxuFgjz9dWm7Z37nyy+8iskZGAxbh2w3fiVQ5jzDe3RILkj0EPuKGG+VnDBy 46fThzAwbHtdUsUEMo/VDp5zbEHswXII/dqv5LIidOr0KV8K3qydNTJKwLGk 0bB8qAPdG1SdUbmBrk8mDovmR2DIUpSpnoohYF5i8WTX42aBzsrXmZrf9S37 4RgjPgqDU9GrZ7xYAgYNxjEmVVJ0jM99yuq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/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}}, { Hold[" "], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}, { Hold[ Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]], Manipulate`Dump`ThisIsNotAControl}}, Typeset`size$$ = { 375., {185., 190.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$24478$$ = 0, $CellContext`rs$24479$$ = 0, $CellContext`ra$24480$$ = 0, $CellContext`\[Rho]a$24481$$ = 0, $CellContext`c$24482$$ = 0, $CellContext`\[Rho]s$24483$$ = 0, $CellContext`h$24484$$ = 0, $CellContext`e$24485$$ = 0, $CellContext`\[Delta]$24486$$ = 0, $CellContext`p$24487$$ = 0, $CellContext`moving$24488$$ = False}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`ag$$ = CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H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9MNZYwSam8sVit6 3UWgwLnO2uiAAmmrTZrNnSRVcmeyPU/upXIQuWViQTaV50aiVx3Y9VKQJmqX K3zo/uZfXVGguIRh2xW9uaqPCVz9qYY0HOxBOzVPb3y/S6bk2r4VW289i+Gu daxW2x0ChTA0+OfKLuRh89ksl9Gt5NjRLza12WPQWRVyLmoKAdcXaS9jeM/R l6nYjDeZ9sXebTwl3xADO64xSOtXLiSUzGcF7B9Afh2yyOs1tUouw75d7nUK Q+ZfLf3Mmn/zN9GRWtWAthTwr4uZtN6zluTbNhoE2gNbc/p7OCCqubNUGpUj mB3gFVcxSnMLq9a51x7AEH+53oc8JNBbQiKeHG0RWC5utuB9pOeodaeuXPGQ A5JgyR89PC7ci90u/3efKdi5CcPUfvufczgsir1Kze+aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "], $CellContext`c$$ = 1.05, $CellContext`e$$ = 0.3, $CellContext`h$$ = 0.5, $CellContext`moving$$ = False, $CellContext`n$$ = 46, $CellContext`p$$ = 0.05, $CellContext`ra$$ = 2, $CellContext`rs$$ = 65, $CellContext`\[Delta]$$ = 1, $CellContext`\[Delta]s$$ = 1.5, $CellContext`\[Rho]a$$ = 2, $CellContext`\[Rho]s$$ = 1}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$24478$$, 0], Hold[$CellContext`rs$$, $CellContext`rs$24479$$, 0], Hold[$CellContext`ra$$, $CellContext`ra$24480$$, 0], Hold[$CellContext`\[Rho]a$$, $CellContext`\[Rho]a$24481$$, 0], Hold[$CellContext`c$$, $CellContext`c$24482$$, 0], Hold[$CellContext`\[Rho]s$$, $CellContext`\[Rho]s$24483$$, 0], Hold[$CellContext`h$$, $CellContext`h$24484$$, 0], Hold[$CellContext`e$$, $CellContext`e$24485$$, 0], Hold[$CellContext`\[Delta]$$, $CellContext`\[Delta]$24486$$, 0], Hold[$CellContext`p$$, $CellContext`p$24487$$, 0], Hold[$CellContext`moving$$, $CellContext`moving$24488$$, False]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Refresh[If[$CellContext`moving$$, $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$]]; \ $CellContext`visualize[$CellContext`ag$$, $CellContext`ra$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], UpdateInterval -> If[$CellContext`moving$$, 0, Infinity]], "Specifications" :> { "Sheep", {{$CellContext`n$$, 46, "number of nearest neighbours"}, 1, 46, 1, ImageSize -> Tiny}, {{$CellContext`rs$$, 65, "shepherd detection distance"}, 1, 150., ImageSize -> Tiny}, {{$CellContext`ra$$, 2, "sheep to sheep interaction distance"}, 0, 150., ImageSize -> Tiny}, {{$CellContext`\[Rho]a$$, 2, "relative strength of repulsion from other sheep"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`c$$, 1.05, "relative strength of of attraction to nearest neighbours"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Rho]s$$, 1, "relative strength of repulsion from shepherd"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`h$$, 0.5, "relative strength of proceeding in previous direction"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`e$$, 0.3, "relative strength of angular noise"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`\[Delta]$$, 1, "displacement per step"}, 0, 10, ImageSize -> Tiny}, {{$CellContext`p$$, 0.05, "probability of moving while grazing"}, 0, 1, ImageSize -> Tiny}, "Shepherd", {{$CellContext`\[Delta]s$$, 1.5, "displacement per step"}, 0, 10, ImageSize -> Tiny}, " ", {{$CellContext`moving$$, False, "run simulation"}, { True, False}}, {{$CellContext`ag$$, CompressedData[" 1:eJxNlXs01GkYx0VsU/bMRom22qlxUooiXTj0Pi5dlqylO2dl3neQiCJqUkIl RiqOXFNhZXVTkkulcYuURBmRYZqZljFIKJHU/vbs2fn1O+f33+d83+f9Pt/n eefjABdPVRUVlWXUr66i/MDypXpu3WoMKabzvpb3ucHF0qSbDj1vkWLi+MDb NXL0H/YeRRwyE7L5GMRmJ3Axn4BJtyDI20CGCltSlvhn9Si5uNu+zfGBGCS9 u+3tw7mgty+rUDEoQY2vvBQ3wxRKrriu9oRmJQavUnM9HxMuCBfbJkZ1SFHo rUDziVZa7+9xzuZJpzFUdjgv/pTChbwK0SzDI9WCTW3Ouj5JA0qunWXc6mmF 4ZR7zN2BnwlsbVUx+VDVjJrGjJ812L1Tcs6Jw4JxRwyqS7au1WcRYKp927pm ogmlX+u6f/8uzekdTEnOzMIQmes6nMnkQka32zTuZKngeIW/84JA+h43Sse/ OJzA4N2yi3f/NAHuXB6uXtIhSPu9OCc+tE/JrZpmsfnKEQzZ+SGPqyn/EhMl hRKZSMBwlwyI4mjOMnxk7swEDCHzPdt1ownsstmxYme/DGkyta2rGbQ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aWL9654sEzqibGxup dKItizisFXb0vDVP77bSCcPwMLpzaNEMLhg5OAyapTegwoCQqe5adH1356Sz gkOpPRmWWBn/nIDTRlZmLgjRo6iCG+xldN+Etb3Lf6B8UfM1FaVS+29+tK/d ftdypC6t+LHzAa3HbLke7puP4Xm9a3eBkPLHb0g9mSNBTZ1CS4tOOleexxtG YxMxxLnIgpes4MJu3ZnnJRfeorBkm3eah+n3KCl1+fmCOOr9yAjIykki4DYl 9mK4+QC64+8yentSvZLzYrpkqFH5W+/gb3iBynOV6YU724kU8cO8xcHL6XPX z7sVxcmm7suIEDLHCITqXL6nd0AiuDLWl7f6Bc3tYRVklR3H8HT2di+VcQLe B8VW8z6IUV1QPFte2ov+AeGZIpg= "]}, ControlType -> None}, " ", Button[ "Step", $CellContext`moving$$ = False; $CellContext`ag$$ = \ $CellContext`updateAgents[$CellContext`ag$$, $CellContext`n$$, \ $CellContext`rs$$, $CellContext`ra$$, $CellContext`\[Rho]a$$, \ $CellContext`c$$, $CellContext`\[Rho]s$$, $CellContext`h$$, $CellContext`e$$, \ $CellContext`\[Delta]$$, $CellContext`p$$, $CellContext`\[Delta]s$$, \ $CellContext`ra$$ Sqrt[$CellContext`NumberOfSheep], $CellContext`ra$$], ImageSize -> Medium], Button[ "Reset", $CellContext`moving$$ = False; $CellContext`ag$$ = $CellContext`initialAgents, ImageSize -> Medium]}, "Options" :> { AutorunSequencing -> {6}, TrackedSymbols :> {$CellContext`moving$$, $CellContext`ag$$}, SynchronousUpdating -> True, ControlPlacement -> Left, ControllerLinking -> True}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{800., {214., 220.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{N = Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[ Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`rabbitGrowthRate, Blank[]], Pattern[$CellContext`rabbitMobility, Blank[]], Pattern[$CellContext`foxGrowthRate, Blank[]], Pattern[$CellContext`foxMobility, Blank[]], Pattern[$CellContext`foxEndurance, Blank[]]] := Module[{$CellContext`foxPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbitPop = Length[ Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`nearestFoxes = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`dummyPoint]], \ $CellContext`nearestRabbits = Nearest[ Append[ Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyPoint]], \ $CellContext`i, $CellContext`nextLocation, $CellContext`survivors}, Developer`ToPackedArray[ (Flatten[#, 1]& )[ Table[$CellContext`survivors = {}; $CellContext`nextLocation = Part[$CellContext`agents, $CellContext`i, {1, 2}] + If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, RandomReal[{-$CellContext`rabbitMobility, \ $CellContext`rabbitMobility}, 2], RandomReal[{-$CellContext`foxMobility, \ $CellContext`foxMobility}, 2]]; $CellContext`nextLocation = Clip[$CellContext`nextLocation, {0., 1.}]; If[Part[$CellContext`agents, $CellContext`i, 4] == $CellContext`Rabbit, If[Norm[Part[ $CellContext`nearestFoxes[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Rabbit}]}; If[RandomReal[] < $CellContext`rabbitGrowthRate ( 1. - $CellContext`rabbitPop/$CellContext`maxRabbits), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, { 0., $CellContext`Rabbit}]]]; Null], If[Norm[Part[ $CellContext`nearestRabbits[$CellContext`nextLocation], 1] - $CellContext`nextLocation] > 0.02, If[ Part[$CellContext`agents, $CellContext`i, 3] < $CellContext`foxEndurance, $CellContext`survivors = { Join[$CellContext`nextLocation, { Part[$CellContext`agents, $CellContext`i, 3] + 1., $CellContext`Fox}]}; Null], $CellContext`survivors = { Join[$CellContext`nextLocation, {0., $CellContext`Fox}]}; If[RandomReal[] < $CellContext`foxGrowthRate ( 1. - $CellContext`foxPop/$CellContext`maxFoxes), AppendTo[$CellContext`survivors, Join[$CellContext`nextLocation, {0., $CellContext`Fox}]]]; Null]]; $CellContext`survivors, {$CellContext`i, Length[$CellContext`agents]}]]]], $CellContext`updateAgents[ Pattern[$CellContext`agents, Blank[]], Pattern[N, Blank[]], Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`rs, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`\[Rho]a, Blank[]], Pattern[$CellContext`c, Blank[]], Pattern[$CellContext`\[Rho]s, Blank[]], Pattern[$CellContext`h, Blank[]], Pattern[$CellContext`e, Blank[]], Pattern[$CellContext`\[Delta], Blank[]], Pattern[$CellContext`p, Blank[]], Pattern[$CellContext`\[Delta]s, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`nearestSheep = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`nearestShepherd = Nearest[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`i, $CellContext`Ai, $CellContext`Hi, \ $CellContext`\[Delta]i, $CellContext`\[Epsilon]i, $CellContext`Ria, \ $CellContext`Ris, $CellContext`Ci, $CellContext`metricNeighbours, \ $CellContext`topologicNeighbours, $CellContext`\[Xi], $CellContext`LCMi, \ $CellContext`Di, $CellContext`Ain, $CellContext`Hin}, If[Length[ Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]] == N, Developer`ToPackedArray[ Table[$CellContext`Ai = Part[$CellContext`agents, $CellContext`i, {2, 3}]; $CellContext`Hi = Part[$CellContext`agents, $CellContext`i, {4, 5}]; $CellContext`Hin = $CellContext`Hi; $CellContext`Ain = \ $CellContext`Ai; If[Norm[$CellContext`GCM - $CellContext`Barn] > 2, If[Part[$CellContext`agents, $CellContext`i, 1] == $CellContext`Sheep, $CellContext`\[Epsilon]i = {0, 0}; $CellContext`Ria = {0, 0}; $CellContext`Ris = {0, 0}; $CellContext`Ci = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]; \ $CellContext`metricNeighbours = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, ( Part[#, 1] == $CellContext`Sheep& ) Norm[$CellContext`Ai - Part[#, 1]] < $CellContext`ra& ]]; If[Length[$CellContext`metricNeighbours] > 0, $CellContext`Ria = Normalize[ Sum[(Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai)/Norm[ Part[$CellContext`metricNeighbours, $CellContext`j] - \ $CellContext`Ai], {$CellContext`j, 1, Length[$CellContext`metricNeighbours]}]]; Null]; If[Norm[Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1] - $CellContext`Ai] > $CellContext`rs, If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null, $CellContext`\[Delta]i = 0; Null]; Null, $CellContext`Ris = Normalize[$CellContext`Ai - Part[ $CellContext`nearestShepherd[$CellContext`Ai], 1]]; $CellContext`topologicNeighbours = \ $CellContext`nearestSheep[$CellContext`Ai, $CellContext`n]; If[Length[$CellContext`topologicNeighbours] > 0, $CellContext`LCMi = Mean[$CellContext`topologicNeighbours]; $CellContext`Ci = Normalize[$CellContext`LCMi - $CellContext`Ai]; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`c \ $CellContext`Ci + $CellContext`\[Rho]a $CellContext`Ria + \ $CellContext`\[Rho]s $CellContext`Ris + $CellContext`e \ $CellContext`\[Epsilon]i]; $CellContext`Ain = $CellContext`Ai + $CellContext`\ \[Delta]i $CellContext`Hin; Null, $CellContext`Ci = $CellContext`Hi; $CellContext`Di = \ $CellContext`Hi; $CellContext`\[Epsilon]i = {0, 0}; $CellContext`\[Delta]i = $CellContext`\[Delta]s; If[RandomReal[] < $CellContext`p, $CellContext`\[Xi] = RandomReal[{-Pi, Pi}]; $CellContext`\[Epsilon]i = AngleVector[$CellContext`\[Xi]]; Null]; If[Norm[Part[ $CellContext`nearestSheep[$CellContext`Ai], 1] - $CellContext`Ai] < 3 $CellContext`ra, $CellContext`\[Delta]i = 0; Null, If[Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), $CellContext`Di = ($CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] \ $CellContext`Pd) - $CellContext`Ai; Null, $CellContext`Ci = ($CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc) - $CellContext`Ai; Null]; Null]; $CellContext`Hin = Normalize[$CellContext`h $CellContext`Hi + $CellContext`Ci + \ $CellContext`Di + $CellContext`e $CellContext`\[Epsilon]i]; $CellContext`Ain = \ $CellContext`Ai + $CellContext`\[Delta]i $CellContext`Hin; Null]; Null]; Join[{ Part[$CellContext`agents, $CellContext`i, 1]}, $CellContext`Ain, $CellContext`Hin], {$CellContext`i, Length[$CellContext`agents]}]], $CellContext`initialAgents[ N]]], $CellContext`agents = CompressedData[" 1:eJxNl3k4VXsXxw0VmRKpKzKlW4kQuSLthUSk3DiHc5zjDKZ0FZeQKTeUWcWt 1JUGlMicQmVnCFGGyDwd83Ccc41l6Hq9z/u8e9/9PPu/z/Nd67fXWt/124pM j7POfDw8PM7r70Ye7IGUo0YJj4QsYUyAJXHPTR+SbwY3S7RyUfkxmZZM/1L0 f9jfSO9Py0/GqST4IKm/mdeJCYUX3Bpqv3NRWuVGT+mgdIx7dbdaIoZBAi3T 546oNwmONsl9kRflIge23Skb5DYg/+eidRQW498zwXmr1tVxQVsw+S5OSNzP Rp4VjwjkOfZhHHOZJRqX5QBx0bkHBVxswKV7LjJYpx+pYBu7vOROYVz//TuH +NLs4JClqQh1CxOigpyLj19kIy4RMZVBtF4sv/KPipc1ohjA2uwy+uGEPfzK E1uU/GkEtR2MTlO6MIbpefPQKvlROvwzci9p62EmnJCTkbmQWImUsTJkHz/k Ynrkx46DrtfI0PfsXof0BA1umR9OE6wbQeYSBO5HeoxhXBzBva4vlQ4UEWHf LYUMUD19LDHoFRfxTL0SuUm2HOOuDZX0nKQQoDs8eVDZ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NJbbzKsvp3yHfudCKqb+MP9lrjIBY19Eem/p2GcHWfnEcsa AuSa/dR5PJgMbvKZ7FVXDhKjqVapN9uCcSdV6NrLUfawMM6+eeiJLVza0a/g p9GJelwc6Gk6j++PNw3xjzq2UGA5MXs5oYYImWaGSQlVbFSrKbXjigDuz+oe 4l7mxjQQDnkHnTttYTq6qSiIzEEjZCjWrcatGPdIK+tgSQoJdHp0T0uw6ND2 a/jF4bc9qM+7Lyb5d9lYXGZUuEV6HB1S9Quq+CeIIHBslStm1ITmH48oPD6H +4vUyEeD8HQqsEtSjGaGbUHspZTHz2VcZFTt7p/nD+H/FTMe41p/PKDChHsY ybeBAQPnDFZUX3DRkDfKrFTjCowLDRN5NpRnBzGSKuQf6376oDdWIqV1EnnG XVs754n3vaKI9qbHQUxQSS69rBRoAxn3ditpPuxE7OjC/P1n8Tmf6b4m01fK AH5F27WFHnvY6azX5mviifT7DXhz//Uf0KH4+ZH5GBlcRbpE5dbrIW9xwqA9 ioNIN588/EOuBePYydFje60psHBh++1nSUQI2JKMvCzoRV5ovHj60I6N/gev abJN "], $CellContext`Pd = 20., $CellContext`Pc = 2, $CellContext`Sheep = 1., $CellContext`nearestSheep = NearestFunction[ Hold[ Nearest[CompressedData[" 1:eJwVlGdYU4cChtkqVkuRBpoblgwZFicqUMqnWNTSGCHJSXKyzglRoUhUhKvV qJUiy1JxyyiCiBBBi2LRglRAGVZGEVAQLioYWZbtI8gVLvfH97x/v/fPa6vY HbhdT0dHRzm7/3OYKG5ZopbixgtjpzhXAbbal8f9kUdggcEnj3qeU/jMRvnx QKAEoXllj1TeIlxnOD/nHKJxNzgsfN+kGJNOq+vNm3l4fDB8TUcAD0LLwo2N O2gcsU5i1xZTkK1vueGv5sE56tR8i20E6j7EZB0IkMBEdiyS85GCT2/dSZvt IiR8mt3PcCDgVqtsjjSiYH62Ta8rhY/3bM4ah3NiGBn/qV1kSWAoMWx89Jwc VjY7FnMIGY6eYXdx8iUIu2fdvXeTCPviHjQ3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oeGA5r4uNJ1bJOrxAZtDGc0iSW Ai+H3BrMkiSQnHrHvMSU4b+W1EZ9by5+qSjwzEuXQbdhsl0eyMU/DPMty6xJ bPbZtbfbjw9NncaD2S9HdP5g0dkgGvkXCpr6i/gY3Md+lZMnwlm/ao/JDjG8 VHHk75YK5GSzm6UcAuNPVac3PKCwqWTny6XeBObH22ZEz6GQlLqlZyRbBNOK UyltaWJsjAlZf65Wjlq/OtXKRBIbImObH9XwYUX2FV3sITBR8sa0XEhioXB8 +meOAudv4v5JGY2ne0x7Ex5S2Ok3nhcx26lK4Yr9PZDCKp39r89yFaDLUiUW s11gOt5wf6EnR+qkZc011WzX2P+UNSQoMJPtxnY8Kkf8pZGh8udSXE39ThxX QkGl7nuqqxXj8EjWs0atAD/YRI8dPsZFcuSVWP1fxDBb6/o5a0yIIu1MNfOI Al6voh4OnRDDrlU2PvW1Ah+c0kJdnkjR8PFM+oUSBYqceyf5X9E4oOnLGpng Q8+4LGJVE4lBq8HMrRo5tv3NXGzTS2JdqZ5R2jAPtt1hPVcNFWjkJOtG24kQ +clp4zvFPLwz25F1fVSMG6uCXu83oTGgblw5vFAAC3FomKE7gf8BUFHR9g== "]]]], $CellContext`nearestShepherd = NearestFunction[ Hold[ Nearest[{{51.33275575545676, 52.482196240395865`}}]]], $CellContext`Shepherd = 2., $CellContext`GCM = {113.25252708734098`, 108.86285425870301`}, $CellContext`furthestSheep = {79.00888553263037, 75.49534044731004}, $CellContext`i = 2, $CellContext`Ai = {113.29931057487892`, 90.38522841635115}, $CellContext`Hi = { 0.4640322323978051, -0.8858183150600971}, $CellContext`\[Delta]i = 0, $CellContext`\[Epsilon]i = {0, 0}, $CellContext`Ria = {0, 0}, $CellContext`Ris = {0, 0}, $CellContext`Ci = {0, 0}, $CellContext`metricNeighbours = {}, \ $CellContext`topologicNeighbours = {{87.88974855249933, 107.30001562837427`}, {91.6186959532574, 105.38678429157869`}, { 84.13304064574677, 98.81102396902853}, {77.28710078616497, 104.48726107840385`}, {93.52379156545138, 111.39366822505933`}, { 80.75800379530878, 98.01198692142795}, {94.69139923788762, 109.93429168579107`}}, $CellContext`\[Xi] = -2.7136427325828105`, \ $CellContext`LCMi = {87.12882579090231, 105.04643311423766`}, $CellContext`Di = {0.9894111651225573, 0.14513974759115325`}, $CellContext`Ain = {113.29931057487892`, 90.38522841635115}, $CellContext`Hin = { 0.4640322323978051, -0.8858183150600971}, $CellContext`Barn = {0, 0}, $CellContext`Fox = 1., $CellContext`Rabbit = 2., $CellContext`dummyPoint = {-1., -1.}, $CellContext`maxRabbits = 500., $CellContext`maxFoxes = 500., $CellContext`initialAgents := Developer`ToPackedArray[ Table[ If[$CellContext`i == 0, Join[{$CellContext`Shepherd}, $CellContext`Barn, AngleVector[ RandomReal[{-Pi, Pi}]]], Join[{$CellContext`Sheep}, RandomReal[{$CellContext`AreaSize/2., $CellContext`AreaSize}, 2], AngleVector[ RandomReal[{-Pi, Pi}]]]], {$CellContext`i, 0, $CellContext`NumberOfSheep}]], $CellContext`AreaSize = 150., $CellContext`NumberOfSheep = 46, $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]], Pattern[$CellContext`ra, Blank[]], Pattern[$CellContext`Pd, Blank[]], Pattern[$CellContext`Pc, Blank[]]] := Module[{$CellContext`shepherdsP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Shepherd& ]], $CellContext`sheepP = Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], $CellContext`GCM = Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], N = Length[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]], \ $CellContext`furthestSheep = Part[ SortBy[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]], -Norm[# - Mean[ Map[Take[#, {2, 3}]& , Select[$CellContext`agents, Part[#, 1] == $CellContext`Sheep& ]]]]& ], 1], $CellContext`dummyListP = {$CellContext`dummyPoint}}, Show[ Graphics[{ EdgeForm[{Thick, RGBColor[0.5, 0.86, 0.5]}], White, Rectangle[$CellContext`Barn - {2, 2}, $CellContext`Barn + {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`shepherdsP == {}, $CellContext`dummyListP, \ $CellContext`shepherdsP]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Opacity[0.5], Point[ If[$CellContext`sheepP == {}, $CellContext`dummyListP, \ $CellContext`sheepP]]}], Graphics[{ Locator[$CellContext`GCM]}], Graphics[{ EdgeForm[{Thin, Dashed}], FaceForm[], Disk[$CellContext`GCM, $CellContext`ra N^(2/3)]}], If[ Norm[$CellContext`furthestSheep - $CellContext`GCM] < \ $CellContext`ra N^(2/3), Graphics[{ EdgeForm[{Thick, RGBColor[0.91, 0.5, 0.13]}], White, Rectangle[$CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd - \ {2, 2}, $CellContext`GCM + Normalize[$CellContext`GCM - $CellContext`Barn] $CellContext`Pd + \ {2, 2}]}], Graphics[{ AbsolutePointSize[10], RGBColor[1, 0.14, 0.15], Point[$CellContext`furthestSheep]}, { EdgeForm[{Thick, RGBColor[1, 0.14, 0.15]}], FaceForm[], Rectangle[$CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc - {2, 2}, $CellContext`furthestSheep + Normalize[$CellContext`furthestSheep - $CellContext`GCM] \ $CellContext`Pc + {2, 2}]}]], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}, {(-0.5) $CellContext`AreaSize, 1.5 $CellContext`AreaSize}}]], $CellContext`visualize[ Pattern[$CellContext`agents, Blank[]]] := Module[{$CellContext`foxes = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Fox& ]], $CellContext`rabbits = Map[Take[#, 2]& , Select[$CellContext`agents, Part[#, 4] == $CellContext`Rabbit& ]], $CellContext`dummyList = \ {$CellContext`dummyPoint}}, Show[ Graphics[{ AbsolutePointSize[10], RGBColor[0.9, 0.42, 0.17], Point[ If[$CellContext`foxes == {}, $CellContext`dummyList, \ $CellContext`foxes]]}], Graphics[{ AbsolutePointSize[10], RGBColor[0.48, 0.11, 0.56], Point[ If[$CellContext`rabbits == {}, $CellContext`dummyList, \ $CellContext`rabbits]]}], ImageSize -> {375, 375}, AspectRatio -> Automatic, Frame -> False, Axes -> False, PlotRange -> {{0, 1}, {0, 1}}]], Attributes[PlotRange] = {ReadProtected}}; Typeset`initDone$$ = True), SynchronousInitialization->True, UndoTrackedVariables:>{Typeset`show$$, Typeset`bookmarkMode$$}, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellID->131327941,ExpressionUUID->"35137a25-e771-41a4-83b2-cef0edc0c534"] }, Open ]], Cell[CellGroupData[{ Cell["", "DetailsSection",ExpressionUUID->"bab0e3aa-d612-40e4-9ece-f8ecc6cddbf1"], Cell[TextData[{ "D. Str\[ODoubleDot]mbom, et al. \"Solving the shepherding problem: \ heuristics for herding autonomous, interacting agents,\" ", StyleBox["J. R. Soc. Interface", FontSlant->"Italic"], ", 11 (2014) 20140719; doi: 10.1098/rsif.2014.0719. \n\n" }], "DetailNotes", CellChangeTimes->{{3.7168867877988415`*^9, 3.7168867964703474`*^9}, { 3.716886833421291*^9, 3.71688688928202*^9}, {3.7168869369519596`*^9, 3.7168869728662095`*^9}}, CellID->71302943,ExpressionUUID->"9e2805d8-ddaf-4b5e-919b-a30827368a4b"] }, Open ]], Cell[CellGroupData[{ Cell["", "ControlSuggestionsSection",ExpressionUUID->"87754619-9529-4ed1-a73d-b433742f5176"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[True], Cell[ " Resize Images",ExpressionUUID->"17d88eee-1f5d-41c9-855c-30eb56118180"]}], "\"Click inside an image to reveal its orange resize frame.\\nDrag any of \ the orange resize handles to resize the image.\"", TooltipDelay->0.35]], "ControlSuggestions", CellChangeTimes->{3.35696210375764*^9, 3.413118644174939*^9}, FontFamily->"Verdana", CellTags-> "ResizeImages",ExpressionUUID->"63e3dede-997d-4e68-9cea-3991b2902b26"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Rotate and Zoom in 3D",ExpressionUUID-> "f03d1e1e-759a-4218-9720-055b64d65154"]}], 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.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "RotateAndZoomIn3D",ExpressionUUID->"9e995312-73d9-4169-823d-af8f9bf82e58"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Drag Locators",ExpressionUUID->"43cd04ee-2da6-4d8b-a0d0-b305a6913845"]}], RowBox[{"\"Drag any locator (\"", GraphicsBox[ LocatorBox[ Scaled[{0.5, 0.5}]], ImageSize -> 20], "\", etc.) to move it around.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "DragLocators",ExpressionUUID->"bb6157cc-122d-4e68-8bca-5f3693a237fe"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Create and Delete Locators",ExpressionUUID-> "2ffbcb03-a4d2-4c7d-adc5-ad74b01b862a"]}], 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.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "CreateAndDeleteLocators",ExpressionUUID->"83702eb0-ec84-4d64-ada2-\ a6516df2332b"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Slider Zoom",ExpressionUUID->"7b729e6c-6642-41a9-a4ef-7423fe06af9c"]}], 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.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "SliderZoom",ExpressionUUID->"375d194d-3c82-44e3-b3a6-72c2e077a7fc"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Gamepad Controls",ExpressionUUID-> "c5ff0931-0474-4d8e-8d8a-20af1e8147ea"]}], "\"Control this Demonstration with a gamepad or other\\nhuman interface \ device connected to your computer.\"", TooltipDelay->0.35]], "ControlSuggestions", CellChangeTimes->{3.35696210375764*^9, 3.3895522232313623`*^9}, FontFamily->"Verdana", CellTags-> "GamepadControls",ExpressionUUID->"efa4228e-d76b-4a6b-bf6e-f86d8d538221"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Automatic Animation",ExpressionUUID-> "cda3ca2e-91a9-4b0e-b704-34079325447b"]}], 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.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "AutomaticAnimation",ExpressionUUID->"a5437dae-5039-4843-b952-1a2e211e25a1"], Cell[BoxData[ TooltipBox[ RowBox[{ CheckboxBox[False], Cell[ " Bookmark Animation",ExpressionUUID-> "d1a27b0b-09aa-4119-bb55-31857184920a"]}], 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.\""}], TooltipDelay->0.35]], "ControlSuggestions", FontFamily->"Verdana", CellTags-> "BookmarkAnimation",ExpressionUUID->"920c0b54-11bc-4516-a248-372af5b50e7a"] }, Open ]], Cell[CellGroupData[{ Cell["", "SearchTermsSection",ExpressionUUID->"af8136d8-8622-49a7-90d7-5e38d1e72b45"], Cell["biology", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.413057243484375*^9, 3.4130572449375*^9}}, CellID->731317257,ExpressionUUID->"94ef870f-1dec-40a1-9042-40dace49233b"], Cell["ecology", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.4130606235625*^9, 3.413060624953125*^9}}, CellID->361917666,ExpressionUUID->"762f57a1-7799-4b70-a9ca-f473a6f0dc77"], Cell["multi-agent modeling", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.413057200390625*^9, 3.413057216640625*^9}, { 3.4130606200625*^9, 3.413060621265625*^9}}, CellID->488939388,ExpressionUUID->"a2805468-5000-41a9-ae9f-a7225662d91c"], Cell["particle systems", "SearchTerms", CellChangeTimes->{ 3.35696210375764*^9, {3.413057200390625*^9, 3.413057216640625*^9}, { 3.4130606200625*^9, 3.41306062128125*^9}, {3.413101943234375*^9, 3.41310194703125*^9}}, CellID->360788637,ExpressionUUID->"b9bcb06b-f08b-4176-ad73-14ed25e08777"] }, Open ]], Cell["", "RelatedLinksSection",ExpressionUUID->"71461157-1305-4a24-a731-1ebb2176af45"], Cell[CellGroupData[{ Cell["", "AuthorSection",ExpressionUUID->"c0e92f03-f783-48e9-bb7a-122e8913937e"], Cell["Contributed by: Iztok Lebar Bajec", "Author", CellChangeTimes->{{3.7166192581814175`*^9, 3.7166192584030986`*^9}, { 3.716886734403803*^9, 3.716886766523572*^9}}, CellID->8672943,ExpressionUUID->"34e971c7-a504-4f91-8e08-906ee55b2174"] }, Open ]] }, Open ]] }, WindowSize->{1194, 1091}, WindowMargins->{{139, Automatic}, {Automatic, 77}}, FrontEndVersion->"11.2 for Microsoft Windows (64-bit) (September 10, 2017)", StyleDefinitions->FrontEnd`FileName[{"Wolfram"}, "Demonstration.nb", CharacterEncoding -> "UTF-8"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "ResizeImages"->{ Cell[403171, 7882, 491, 11, 22, "ControlSuggestions",ExpressionUUID->"63e3dede-997d-4e68-9cea-3991b2902b26", CellTags->"ResizeImages"]}, "RotateAndZoomIn3D"->{ Cell[403665, 7895, 800, 19, 22, "ControlSuggestions",ExpressionUUID->"9e995312-73d9-4169-823d-af8f9bf82e58", CellTags->"RotateAndZoomIn3D"]}, "DragLocators"->{ Cell[404468, 7916, 457, 13, 22, "ControlSuggestions",ExpressionUUID->"bb6157cc-122d-4e68-8bca-5f3693a237fe", CellTags->"DragLocators"]}, "CreateAndDeleteLocators"->{ Cell[404928, 7931, 761, 19, 22, "ControlSuggestions",ExpressionUUID->"83702eb0-ec84-4d64-ada2-a6516df2332b", CellTags->"CreateAndDeleteLocators"]}, "SliderZoom"->{ Cell[405692, 7952, 961, 23, 22, "ControlSuggestions",ExpressionUUID->"375d194d-3c82-44e3-b3a6-72c2e077a7fc", CellTags->"SliderZoom"]}, "GamepadControls"->{ Cell[406656, 7977, 491, 12, 22, "ControlSuggestions",ExpressionUUID->"efa4228e-d76b-4a6b-bf6e-f86d8d538221", CellTags->"GamepadControls"]}, "AutomaticAnimation"->{ Cell[407150, 7991, 1534, 34, 22, "ControlSuggestions",ExpressionUUID->"a5437dae-5039-4843-b952-1a2e211e25a1", CellTags->"AutomaticAnimation"]}, "BookmarkAnimation"->{ Cell[408687, 8027, 1004, 24, 22, "ControlSuggestions",ExpressionUUID->"920c0b54-11bc-4516-a248-372af5b50e7a", CellTags->"BookmarkAnimation"]} } *) (*CellTagsIndex CellTagsIndex->{ {"ResizeImages", 411622, 8106}, {"RotateAndZoomIn3D", 411788, 8109}, {"DragLocators", 411954, 8112}, {"CreateAndDeleteLocators", 412126, 8115}, {"SliderZoom", 412296, 8118}, {"GamepadControls", 412458, 8121}, {"AutomaticAnimation", 412628, 8124}, {"BookmarkAnimation", 412801, 8127} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[567, 22, 366, 6, 74, "DemoTitle",ExpressionUUID->"44b6f269-55f1-4f10-a061-3ce1be9d2d5c"], Cell[CellGroupData[{ Cell[958, 32, 88, 0, 275, "InitializationSection",ExpressionUUID->"7b277819-e4c5-4e67-9f78-96c37a666050"], Cell[1049, 34, 1663, 36, 150, "Input",ExpressionUUID->"b8020fbe-e5ad-4a98-9769-c018cf03144b", InitializationCell->True, CellID->12186613], Cell[2715, 72, 3786, 76, 312, "Input",ExpressionUUID->"1e27b3b2-a4ba-420b-9092-d643646fa5e6", InitializationCell->True, CellID->179304614], Cell[6504, 150, 13370, 315, 864, "Input",ExpressionUUID->"59792d06-c410-4b43-8870-b43da934ab42", InitializationCell->True, CellID->581179032], Cell[19877, 467, 24423, 503, 1647, "Input",ExpressionUUID->"b971fab5-430b-42e3-8b90-5246e14a7616", InitializationCell->True, CellID->323996531] }, Closed]], Cell[CellGroupData[{ Cell[44337, 975, 84, 0, 189, "ManipulateSection",ExpressionUUID->"39389196-09c6-4cc9-a84b-941538f14d23"], Cell[CellGroupData[{ Cell[44446, 979, 6361, 164, 529, "Input",ExpressionUUID->"ee18878f-c5e0-41a8-aaa6-c2107146a4f5", CellID->376062353], Cell[50810, 1145, 57549, 1046, 446, "Output",ExpressionUUID->"bb4e58be-b4ea-46c8-a082-110f41eb0339", CellID->244282151] }, {2}]] }, Open ]], Cell[CellGroupData[{ Cell[108405, 2197, 91, 0, 169, "ManipulateCaptionSection",ExpressionUUID->"32e0037a-27f4-4198-b0f4-32638b25f267"], Cell[108499, 2199, 1834, 27, 97, "ManipulateCaption",ExpressionUUID->"766d285b-c20c-440b-90a9-a80a51347879", CellID->330077632] }, Open ]], Cell[CellGroupData[{ Cell[110370, 2231, 83, 0, 172, "ThumbnailSection",ExpressionUUID->"f0348689-0dba-42ac-9d53-926377e8709e"], Cell[110456, 2233, 57740, 1060, 446, "Output",ExpressionUUID->"95d5bb40-c80f-47a9-9f3c-70f72bf90b1e", CellID->28375960] }, Open ]], Cell[CellGroupData[{ Cell[168233, 3298, 83, 0, 142, "SnapshotsSection",ExpressionUUID->"5ce7ae5f-f55c-4fce-b841-441b88eafbca"], Cell[168319, 3300, 47355, 920, 446, "Output",ExpressionUUID->"0b4894ef-9618-450b-a4d1-8e4fafb7eda5", CellID->230431650], Cell[215677, 4222, 47320, 920, 446, "Output",ExpressionUUID->"07dda37d-dc0b-46fb-b5cc-206b7cb1806f", CellID->89335050], Cell[263000, 5144, 47181, 915, 446, "Output",ExpressionUUID->"a0b299e1-8a92-4696-87eb-4ec1f003f01f", CellID->9651793], Cell[310184, 6061, 46859, 910, 446, "Output",ExpressionUUID->"afb2315a-ebd4-4fab-a379-dbd79abc0163", CellID->694383038], Cell[357046, 6973, 45345, 885, 446, "Output",ExpressionUUID->"35137a25-e771-41a4-83b2-cef0edc0c534", CellID->131327941] }, Open ]], Cell[CellGroupData[{ Cell[402428, 7863, 81, 0, 339, "DetailsSection",ExpressionUUID->"bab0e3aa-d612-40e4-9ece-f8ecc6cddbf1"], Cell[402512, 7865, 527, 10, 67, "DetailNotes",ExpressionUUID->"9e2805d8-ddaf-4b5e-919b-a30827368a4b", CellID->71302943] }, Open ]], Cell[CellGroupData[{ Cell[403076, 7880, 92, 0, 126, "ControlSuggestionsSection",ExpressionUUID->"87754619-9529-4ed1-a73d-b433742f5176"], Cell[403171, 7882, 491, 11, 22, "ControlSuggestions",ExpressionUUID->"63e3dede-997d-4e68-9cea-3991b2902b26", CellTags->"ResizeImages"], Cell[403665, 7895, 800, 19, 22, "ControlSuggestions",ExpressionUUID->"9e995312-73d9-4169-823d-af8f9bf82e58", CellTags->"RotateAndZoomIn3D"], Cell[404468, 7916, 457, 13, 22, "ControlSuggestions",ExpressionUUID->"bb6157cc-122d-4e68-8bca-5f3693a237fe", CellTags->"DragLocators"], Cell[404928, 7931, 761, 19, 22, "ControlSuggestions",ExpressionUUID->"83702eb0-ec84-4d64-ada2-a6516df2332b", CellTags->"CreateAndDeleteLocators"], Cell[405692, 7952, 961, 23, 22, "ControlSuggestions",ExpressionUUID->"375d194d-3c82-44e3-b3a6-72c2e077a7fc", CellTags->"SliderZoom"], Cell[406656, 7977, 491, 12, 22, "ControlSuggestions",ExpressionUUID->"efa4228e-d76b-4a6b-bf6e-f86d8d538221", CellTags->"GamepadControls"], Cell[407150, 7991, 1534, 34, 22, "ControlSuggestions",ExpressionUUID->"a5437dae-5039-4843-b952-1a2e211e25a1", CellTags->"AutomaticAnimation"], Cell[408687, 8027, 1004, 24, 22, "ControlSuggestions",ExpressionUUID->"920c0b54-11bc-4516-a248-372af5b50e7a", CellTags->"BookmarkAnimation"] }, Open ]], Cell[CellGroupData[{ Cell[409728, 8056, 85, 0, 158, "SearchTermsSection",ExpressionUUID->"af8136d8-8622-49a7-90d7-5e38d1e72b45"], Cell[409816, 8058, 193, 3, 22, "SearchTerms",ExpressionUUID->"94ef870f-1dec-40a1-9042-40dace49233b", CellID->731317257], Cell[410012, 8063, 193, 3, 22, "SearchTerms",ExpressionUUID->"762f57a1-7799-4b70-a9ca-f473a6f0dc77", CellID->361917666], Cell[410208, 8068, 256, 4, 22, "SearchTerms",ExpressionUUID->"a2805468-5000-41a9-ae9f-a7225662d91c", CellID->488939388], Cell[410467, 8074, 300, 5, 22, "SearchTerms",ExpressionUUID->"b9bcb06b-f08b-4176-ad73-14ed25e08777", CellID->360788637] }, Open ]], Cell[410782, 8082, 86, 0, 143, "RelatedLinksSection",ExpressionUUID->"71461157-1305-4a24-a731-1ebb2176af45"], Cell[CellGroupData[{ Cell[410893, 8086, 80, 0, 129, "AuthorSection",ExpressionUUID->"c0e92f03-f783-48e9-bb7a-122e8913937e"], Cell[410976, 8088, 243, 3, 22, "Author",ExpressionUUID->"34e971c7-a504-4f91-8e08-906ee55b2174", CellID->8672943] }, Open ]] }, Open ]] } ] *)