---
# SPDX-FileCopyrightText: 2024 Petros Koutsolampros
#
# SPDX-License-Identifier: GPL-3.0-only

title: "Agent Analysis"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Agent Analysis}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>"
)
```

```{r setup}
library(alcyon)

galleryMap <- st_read(
    system.file(
        "extdata", "testdata", "gallery",
        "gallery_lines.mif",
        package = "alcyon"
    ),
    geometry_column = 1L, quiet = TRUE
)
```

```{r}
latticeMap <- makeVGALatticeMap(
    galleryMap,
    fillX = 3.01,
    fillY = 6.7,
    gridSize = 0.06
)
plot(latticeMap["Connectivity"])
```

```{r}
agentAnalysis <- agentAnalysis(latticeMap,
    timesteps = 10000,
    releaseRate = 0.1,
    agentLifeTimesteps = 1000,
    agentFov = 16,
    agentStepsToDecision = 3,
    agentLookMode = AgentLookMode$Standard
)
plot(agentAnalysis$latticeMap["Gate Counts"])
```

```{r}
agentAnalysis <- agentAnalysis(latticeMap,
    timesteps = 10000,
    releaseRate = 0.1,
    agentLifeTimesteps = 1000,
    agentFov = 16,
    agentStepsToDecision = 3,
    agentLookMode = AgentLookMode$Standard,
    numberOfTrails = 50
)
plot(agentAnalysis$trailMap)
```
