forked from AlchemistSimulator/Alchemist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add GoTo TargetSelectionStrategy implementation
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...implementationbase/src/main/kotlin/it/unibo/alchemist/model/movestrategies/target/GoTo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2010-2024, Danilo Pianini and contributors | ||
* listed, for each module, in the respective subproject's build.gradle.kts file. | ||
* | ||
* This file is part of Alchemist, and is distributed under the terms of the | ||
* GNU General Public License, with a linking exception, | ||
* as described in the file LICENSE in the Alchemist distribution's top directory. | ||
*/ | ||
|
||
package it.unibo.alchemist.model.movestrategies.target | ||
|
||
import it.unibo.alchemist.model.Environment | ||
import it.unibo.alchemist.model.Position | ||
import it.unibo.alchemist.model.movestrategies.TargetSelectionStrategy | ||
|
||
/** | ||
* TargetSelectionStrategy that has the objective to go towards a fixed destination in the Environment. | ||
* | ||
* @param <T> Concentration type | ||
* @param <P> position type | ||
*/ | ||
class GoTo<T, P : Position<P>>( | ||
private val destination: P, | ||
) : TargetSelectionStrategy<T, P> { | ||
|
||
/** | ||
* @param environment: the environment executing the simulation, | ||
* @param destination: an indefinite number of [Number] values that indicates the coordinates of the destination. | ||
* @returns a [TargetSelectionStrategy] which aim to go towards the fixed destination in the environment. | ||
*/ | ||
constructor( | ||
environment: Environment<T, P>, | ||
vararg destination: Number, | ||
) : this(environment.makePosition(*destination)) | ||
|
||
override fun getTarget(): P = destination | ||
|
||
override fun toString() = "${GoTo::class.simpleName}:$destination" | ||
} |