Skip to content

Commit

Permalink
Unified parameter naming in UnaryPredicate and BinaryPredicate.
Browse files Browse the repository at this point in the history
Closes #48.
  • Loading branch information
dominikmaeckel committed Feb 15, 2024
1 parent 3835eb9 commit fb98747
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,32 @@ class BinaryPredicate<
*
* @param ctx The context this predicate is evaluated in.
* @param tickId The time stamp to evaluate this predicate in. default: first tick in context.
* @param actor1 The ID of the first actor to evaluate this predicate for. default: ego vehicle.
* @param actor2 The ID of the second actor to evaluate this predicate for.
* @param entityId1 The ID of the first entity to evaluate this predicate for. default: ego
* vehicle.
* @param entityId2 The ID of the second entity to evaluate this predicate for.
*/
fun holds(
ctx: PredicateContext<E, T, S>,
tickId: Double = ctx.segment.firstTickId,
actor1: Int = ctx.primaryEntityId,
actor2: Int
): Boolean = ctx.holds(this, tickId, actor1, actor2)
entityId1: Int = ctx.primaryEntityId,

Check warning on line 56 in stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt

View check run for this annotation

Codecov / codecov/patch

stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt#L56

Added line #L56 was not covered by tests
entityId2: Int
): Boolean = ctx.holds(this, tickId, entityId1, entityId2)

Check warning on line 58 in stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt

View check run for this annotation

Codecov / codecov/patch

stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt#L58

Added line #L58 was not covered by tests

/**
* Checks if this predicate holds (i.e. is true) in the given context on current tick.
*
* @param ctx The context this predicate is evaluated in.
* @param actor1 The ID of the first actor to evaluate this predicate for. default: ego vehicle.
* @param actor2 The ID of the second actor to evaluate this predicate for.
* @param entity1 The ID of the first entity to evaluate this predicate for. default: ego vehicle.
* @param entity2 The ID of the second entity to evaluate this predicate for.
*/
fun holds(ctx: PredicateContext<E, T, S>, actor1: E1, actor2: E2): Boolean =
fun holds(ctx: PredicateContext<E, T, S>, entity1: E1, entity2: E2): Boolean =
holds(
ctx,
actor1.tickData.currentTick.apply {
if (this != actor2.tickData.currentTick) error("ticks don't match")
entity1.tickData.currentTick.apply {

Check warning on line 70 in stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt

View check run for this annotation

Codecov / codecov/patch

stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt#L70

Added line #L70 was not covered by tests
if (this != entity2.tickData.currentTick) error("ticks don't match")
},
actor1.id,
actor2.id)
entity1.id,
entity2.id)

Check warning on line 74 in stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt

View check run for this annotation

Codecov / codecov/patch

stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/BinaryPredicate.kt#L73-L74

Added lines #L73 - L74 were not covered by tests

companion object {
/** Creates a binary tick predicate in this context. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class UnaryPredicate<
*
* @param ctx The context this predicate is evaluated in.
* @param tickId The time stamp to evaluate this predicate in. default: first tick in context.
* @param actorId The ID of the actor to evaluate this predicate for. default: ego vehicle.
* @param entityId The ID of the entity to evaluate this predicate for. default: ego vehicle.
*/
fun holds(
ctx: PredicateContext<E, T, S>,
tickId: Double = ctx.segment.firstTickId,
actorId: Int = ctx.primaryEntityId
): Boolean = ctx.holds(this, tickId, actorId)
entityId: Int = ctx.primaryEntityId
): Boolean = ctx.holds(this, tickId, entityId)

Check warning on line 52 in stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/UnaryPredicate.kt

View check run for this annotation

Codecov / codecov/patch

stars-core/src/main/kotlin/tools/aqua/stars/core/evaluation/UnaryPredicate.kt#L51-L52

Added lines #L51 - L52 were not covered by tests

/**
* Check if this predicate holds (i.e. is true) in the given context.
Expand Down

0 comments on commit fb98747

Please sign in to comment.