Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
shizejin committed Dec 22, 2017
1 parent 8ee9e73 commit bf2fb7c
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ include("test_repeated_game.jl")
include("test_normal_form_game.jl")
include("test_random.jl")
include("test_support_enumeration.jl")
include("test_vertex_enumeration.jl")
91 changes: 91 additions & 0 deletions test/test_vertex_enumeration.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@testset "Testing vertex Enumeration" begin

@testset "test 3 by 2 non-degenerate normal form game(Float)" begin
g = NormalFormGame(Player([3.0 3.0; 2.0 5.0; 0.0 6.0]),
Player([3.0 2.0 3.0; 2.0 6.0 1.0]))
NEs = [([1.0, 0.0, 0.0], [1.0, 0.0]),
([0.8, 0.2, 0.0], [2/3, 1/3]),
([0.0, 1/3, 2/3], [1/3, 2/3])]

for (actions_computed, actions) in zip(NEs, support_enumeration(g))
for (action_computed, action) in zip(actions_computed, actions)
@test action_computed action
@test eltype(action_computed) <: AbstractFloat
end
end
end

# @testset "test 3 by 2 non-degenerate normal form game(Int)" begin
# g = NormalFormGame(Player([3 3; 2 5; 0 6]),
# Player([3 2 3; 2 6 1]))
# NEs = [([1.0, 0.0, 0.0], [1.0, 0.0]),
# ([0.8, 0.2, 0.0], [2/3, 1/3]),
# ([0.0, 1/3, 2/3], [1/3, 2/3])]

# for (actions_computed, actions) in zip(NEs, support_enumeration(g))
# for (action_computed, action) in zip(actions_computed, actions)
# @test action_computed ≈ action
# @test eltype(action_computed) <: AbstractFloat
# end
# end
# end

# @testset "test 3 by 2 non-degenerate normal form game(Rational)" begin
# g = NormalFormGame(Player([3//1 3//1; 2//1 5//1; 0//1 6//1]),
# Player([3//1 2//1 3//1; 2//1 6//1 1//1]))
# NEs = [([1//1, 0//1, 0//1], [1//1, 0//1]),
# ([4//5, 1//5, 0//1], [2//3, 1//3]),
# ([0//1, 1//3, 2//3], [1//3, 2//3])]

# for (actions_computed, actions) in zip(NEs, support_enumeration(g))
# for (action_computed, action) in zip(actions_computed, actions)
# @test action_computed ≈ action
# @test eltype(action_computed) <: Rational
# end
# end
# end

@testset "test 3 by 2 degenerate normal form game(Float)" begin
g = NormalFormGame(Player([1.0 -1.0; -1.0 1.0; 0.0 0.0]),
Player([1.0 0.0 0.0; 0.0 0.0 0.0]))
NEs = [([1.0, 0.0, 0.0], [1.0, 0.0]),
([0.0, 1.0, 0.0], [0.0, 1.0])]

for (actions_computed, actions) in zip(NEs, support_enumeration(g))
for (action_computed, action) in zip(actions_computed, actions)
@test action_computed action
@test eltype(action_computed) <: AbstractFloat
end
end
end

# @testset "test 3 by 2 degenerate normal form game(Int)" begin
# g = NormalFormGame(Player([1 -1; -1 1; 0 0]),
# Player([1 0 0; 0 0 0]))
# NEs = [([1.0, 0.0, 0.0], [1.0, 0.0]),
# ([0.0, 1.0, 0.0], [0.0, 1.0])]

# for (actions_computed, actions) in zip(NEs, support_enumeration(g))
# for (action_computed, action) in zip(actions_computed, actions)
# @test action_computed ≈ action
# @test eltype(action_computed) <: AbstractFloat
# end
# end
# end

# @testset "test 3 by 2 degenerate normal form game(Rational)" begin
# g = NormalFormGame(Player([1//1 -1//1; -1//1 1//1; 0//1 0//1]),
# Player([1//1 0//1 0//1; 0//1 0//1 0//1]))
# NEs = [([1//1, 0//1, 0//1], [1//1, 0//1]),
# ([0//1, 1//1, 0//1], [0//1, 1//1])]

# for (actions_computed, actions) in zip(NEs, support_enumeration(g))
# for (action_computed, action) in zip(actions_computed, actions)
# @test action_computed ≈ action
# @test eltype(action_computed) <: Rational
# end
# end
# end


end

0 comments on commit bf2fb7c

Please sign in to comment.