Re: Help with Agent Problem...
- To: mathgroup at smc.vnet.net
- Subject: [mg99895] Re: Help with Agent Problem...
- From: dh <dh at metrohm.com>
- Date: Mon, 18 May 2009 06:18:58 -0400 (EDT)
- References: <guqv9o$a6a$1@smc.vnet.net>
Hi Earl,
simply change the function inside NestList to e.g.:
# + If[ myCheck, Sign[stufflocations[[Map[First[Ordering[#, 1]], 0] &
If myCheck evaluates to True, this will do what it did so far, but if
myCheck is False, the agent position is not changed.
Daniel
Earl Mitchell wrote:
> Code:
>
>
> ************
>
> "Making a World of Agents and Stuff"
>
>
> makeNewWorld[agents_]:=Apply[Join,Partition[Riffle[RandomReal[{-10,10},{agents,3}],RandomInteger[9,{agents,3}]],2],1]
>
>
> makeNewStuff[resources_]:=RandomReal[{-10,10},{resources,3}]
>
>
> agentlocations=makeNewWorld[10][[All,1;;3]];
>
> stufflocations=makeNewStuff[5];
>
>
>
> "The Problem of Movement"
>
>
> "Agents search for nearest stuff and move along the vector between their
> current position and that of the stuff."
>
>
> Steplist=NestList[#+Sign[stufflocations[[Map[First[Ordering[#,1]]&,Outer[Norm[#1-#2]&,#,stufflocations,1]]]]-#]/10.&,agentlocations,2000];
>
>
>
> Manipulate[ListPointPlot3D[{Steplist[[j]],stufflocations},PlotStyle->PointSize[Large]],{j,1,Length[Steplist],1}]
> *************
>
> How could I alter this code so that at each iteration an IF statement (or
> multiple IF statements) is applied to the agents, allowing them to, say,
> ignore stuff that's already found by another agent?
>
> I've been trying to figure it out on my own for weeks... My idea's outpace
> my intelligence...