Skip to content

Commit 314abd9

Browse files
committed
Merge branch 'main' of github.com:andrejcarlo/TrajectoryGamesBase.jl
2 parents 9f2a0aa + 5648d30 commit 314abd9

File tree

5 files changed

+42
-37
lines changed

5 files changed

+42
-37
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
with:
1515
version: ${{ matrix.julia_version }}
1616
- uses: julia-actions/cache@v1
17-
- uses: julia-actions/julia-runtest@latest
17+
- uses: julia-actions/julia-runtest@v1
1818
- uses: julia-actions/julia-processcoverage@v1
19-
- uses: codecov/codecov-action@v3
19+
- uses: codecov/codecov-action@v4
2020
with:
2121
token: ${{ secrets.CODECOV_TOKEN }}
2222
file: ./lcov.info
2323
flags: unittests
2424
name: codecov-umbrella
25-
fail_ci_if_error: true

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TrajectoryGamesBase
22

3-
[![CI](https://github.com/lassepe/TrajectoryGamesBase.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/lassepe/TrajectoryGamesBase.jl/actions/workflows/ci.yml)
4-
[![codecov](https://codecov.io/gh/lassepe/TrajectoryGamesBase.jl/branch/main/graph/badge.svg?token=BkJUwW6V1K)](https://codecov.io/gh/lassepe/TrajectoryGamesBase.jl)
3+
[![CI](https://github.com/JuliaGameTheoreticPlanning/TrajectoryGamesBase.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/JuliaGameTheoreticPlanning/TrajectoryGamesBase.jl/actions/workflows/ci.yml)
4+
[![codecov](https://codecov.io/gh/JuliaGameTheoreticPlanning/TrajectoryGamesBase.jl/branch/main/graph/badge.svg?token=BkJUwW6V1K)](https://codecov.io/gh/JuliaGameTheoreticPlanning/TrajectoryGamesBase.jl)
55
[![License](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org/licenses/MIT)
66

77
A package that contains the problem interface and related types for trajectory games. The trajectory games considered here are played over continuous action spaces in *discrete time*. That is, this package currently does not support differential games.
@@ -11,8 +11,8 @@ Note that this package does not contain any solver code. It merely serves as abs
1111
## Eco-System
1212

1313
- [MCPTrajectoryGameSolver.jl](https://github.com/JuliaGameTheoreticPlanning/MCPTrajectoryGameSolver.jl): A solver for trajectory games by casting them as mixed complementarity problems. See that package for a complete usage demo of the `TrajectoryGamesBase` interface.
14-
- [TrajectoryGamesExamples.jl](https://github.com/lassepe/TrajectoryGamesExamples.jl): A package that provides examples of trajectory games and tools for modeling and visualization.
15-
- [LiftedTrajectoryGames.jl](https://github.com/lassepe/LiftedTrajectoryGames.jl): A package for learning mixed strategy solutions of trajectory games.
14+
- [TrajectoryGamesExamples.jl](https://github.com/JuliaGameTheoreticPlanning/TrajectoryGamesExamples.jl): A package that provides examples of trajectory games and tools for modeling and visualization.
15+
- [LiftedTrajectoryGames.jl](https://github.com/JuliaGameTheoreticPlanning/LiftedTrajectoryGames.jl): A package for learning mixed strategy solutions of trajectory games.
1616

1717
If you have a package that uses `TrajectoryGamesBase` and would like to have it listed here, please open an issue or a pull request.
1818

ext/MakieVizExt.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,13 @@ function Makie.plot!(viz::OpenLoopStrategyViz{<:Tuple{TrajectoryGamesBase.OpenLo
5555
begin
5656
starttime = something($(viz.starttime), firstindex($strategy.xs))
5757
endtime = something($(viz.endtime), lastindex($strategy.xs))
58-
if $(viz.dimensionality) == 3
59-
[
60-
Makie.Point3f(xi[1], xi[2], xi[3]) for
61-
xi in $strategy.xs[starttime:($(viz.position_subsampling)):endtime]
62-
]
63-
elseif $(viz.dimensionality) == 2
64-
[
65-
Makie.Point2f(xi[1], xi[2]) for
66-
xi in $strategy.xs[starttime:($(viz.position_subsampling)):endtime]
67-
]
58+
subsampled_states = $strategy.xs[starttime:($(viz.position_subsampling)):endtime]
59+
if $(viz.dimensionality) == 2
60+
[Makie.Point2f(xi[2], xi[1]) for xi in subsampled_states]
61+
elseif $(viz.dimensionality) == 3
62+
[Makie.Point3f(xi[1], xi[2], xi[3]) for xi in subsampled_states]
6863
else
69-
error("Unsupported vizualisation dimensionality: $(viz.dimensionality)")
64+
throw(ArgumentError("Unsupported vizualisation dimensionality: $(viz.dimensionality)"))
7065
end
7166
end
7267
)

test/.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.JuliaFormatter.toml

test/runtests.jl

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using BlockArrays: Block, eachblock, mortar, blocklength
44
using LinearAlgebra: norm, norm_sqr
55
using Makie: Makie
66

7-
function setup_tag_examples(; Δt=0.1)
7+
function setup_tag_examples(; Δt = 0.1)
88
dynamics = let
99
A = [
1010
1 0 Δt 0
@@ -58,8 +58,8 @@ function setup_tag_examples(; Δt=0.1)
5858

5959
env = PolygonEnvironment()
6060

61-
generic_game = TrajectoryGame(; dynamics, cost=generic_cost, env)
62-
time_separable_game = TrajectoryGame(; dynamics, cost=time_separable_cost, env)
61+
generic_game = TrajectoryGame(; dynamics, cost = generic_cost, env)
62+
time_separable_game = TrajectoryGame(; dynamics, cost = time_separable_cost, env)
6363

6464
(; generic_game, time_separable_game)
6565
end
@@ -69,7 +69,7 @@ using TrajectoryGamesBase: TrajectoryGamesBase
6969
using Test: @test
7070

7171
const trivial_strategy = let
72-
xs = [zeros(4) for _ in 1:20]
72+
xs = [ones(4) for _ in 1:20]
7373
us = [zeros(2) for _ in 1:20]
7474
TrajectoryGamesBase.OpenLoopStrategy(xs, us)
7575
end
@@ -80,7 +80,7 @@ function TrajectoryGamesBase.solve_trajectory_game!(
8080
solver,
8181
game,
8282
initial_state;
83-
initial_guess=nothing
83+
initial_guess = nothing,
8484
)
8585
@test !isnothing(initial_guess)
8686
TrajectoryGamesBase.JointStrategy([trivial_strategy, trivial_strategy])
@@ -140,33 +140,47 @@ end # Mock module
140140

141141
@testset "receding horizon utils" begin
142142
receding_horizon_strategy = TrajectoryGamesBase.RecedingHorizonStrategy(;
143-
solver=Mock.Solver(),
143+
solver = Mock.Solver(),
144144
game,
145-
turn_length=2,
146-
generate_initial_guess=(last_strategy, state, time) -> :foo
145+
turn_length = 2,
146+
generate_initial_guess = (last_strategy, state, time) -> :foo,
147147
)
148148
receding_steps = rollout(game.dynamics, receding_horizon_strategy, x1, horizon)
149149
receding_steps_skipped = rollout(
150150
game.dynamics,
151151
receding_horizon_strategy,
152152
x1,
153153
horizon;
154-
skip_last_strategy_call=true
154+
skip_last_strategy_call = true,
155155
)
156156
@test receding_steps == trivial_steps
157157
@test receding_steps_skipped.xs == trivial_steps.xs
158-
@test receding_steps_skipped.us == trivial_steps.us[1:(end-1)]
158+
@test receding_steps_skipped.us == trivial_steps.us[1:(end - 1)]
159159
end
160160
end
161161
end
162162

163163
@testset "visualization" begin
164164
trivial_joint_strategy = JointStrategy([Mock.trivial_strategy, Mock.trivial_strategy])
165165

166-
environment = PolygonEnvironment()
167-
Makie.plot(environment)
168-
Makie.plot!(Mock.trivial_strategy)
169-
Makie.plot!(trivial_joint_strategy)
166+
@testset "2D visaulziation" begin
167+
environment = PolygonEnvironment()
168+
Makie.plot(environment)
169+
Makie.plot!(Mock.trivial_strategy)
170+
Makie.plot!(trivial_joint_strategy)
171+
end
172+
173+
@testset "3D visualization" begin
174+
figure = Makie.Figure()
175+
axis3 = Makie.Axis3(figure[1, 1])
176+
Makie.plot!(Mock.trivial_strategy; dimensionality = 3)
177+
Makie.plot!(
178+
trivial_joint_strategy;
179+
substrategy_attributes = [
180+
(; dimensionality = 3) for _ in trivial_joint_strategy.substrategies
181+
],
182+
)
183+
end
170184
end
171185

172186
@testset "trajectory utils" begin
@@ -215,11 +229,7 @@ end # Mock module
215229

216230
@testset "flatten and unflatten trajectory" begin
217231
flat_trajectory = [1:60;]
218-
unflattened_trajectory = TrajectoryGamesBase.unflatten_trajectory(
219-
flat_trajectory,
220-
4,
221-
2
222-
)
232+
unflattened_trajectory = TrajectoryGamesBase.unflatten_trajectory(flat_trajectory, 4, 2)
223233

224234
@test length(unflattened_trajectory.xs) == 10
225235
@test length(unflattened_trajectory.us) == 10

0 commit comments

Comments
 (0)