# Heterogeneous space

**URL:** https://discourse.julialang.org/t/heterogeneous-space/106262
**Category:** General Usage
**Tags:** question, agents, agentsjl
**Created:** [November 15, 2023, 1:34pm UTC](https://discourse.julialang.org/t/heterogeneous-space/106262 "2023-11-15T13:34:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kemper](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@Kemper](https://discourse.julialang.org/u/Kemper)
#### Post date: [November 15, 2023, 1:34pm UTC](https://discourse.julialang.org/t/heterogeneous-space/106262/1 "2023-11-15T13:34:30Z")

</div>

Hello!

If I have a simple model in Agents.jl, where Agents have to find food.  
And now I would like to add obsticles, like lets say a river, how can I do that?

Is there a way to use a grid as space which has e.g. ones and zeros and the agents can only walk where there are ones or something like that?

There is the “mountain runner” example, which uses a terain map as underground,  
[Mountain Runners · Agents.jl (juliadynamics.github.io)](https://juliadynamics.github.io/Agents.jl/v4.2/examples/runners/)  
But here the terain is only used by the path finder.

I think one way would be to have the grid seperatly and just chack in the step function if the coordinates the agent goes to is a zero or a one on the grid, but that brings me into trouble when I want to plot it…

Is there a Agents.jl way to do that?

Thank you!

---

<div class="post-metadata">

### Author: ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)
#### Post date: [November 15, 2023, 1:46pm UTC](https://discourse.julialang.org/t/heterogeneous-space/106262/2 "2023-11-15T13:46:00Z")

</div>

> [@Kemper](#):
>
> I think one way would be to have the grid seperatly and just chack in the step function if the coordinates the agent goes to is a zero or a one on the grid, but that brings me into trouble when I want to plot it…

Yes, this is the recommended way to do it.

In how far would that get you into trouble when plotting it? Could you please be a bit more specific about which troubles you’ve encountered?

---

<div class="post-metadata">

### Author: ![Kemper](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@Kemper](https://discourse.julialang.org/u/Kemper)
#### Post date: [November 15, 2023, 1:52pm UTC](https://discourse.julialang.org/t/heterogeneous-space/106262/3 "2023-11-15T13:52:15Z")

</div>

Hi,

Thank you for the quick response!  
sorry for not beeing specific!  
I will first try how far I get, produce some code and get back when I can show you on the code what I mean!

Do you happen do know of some example of this?
