-
Notifications
You must be signed in to change notification settings - Fork 126
Penalty kick play pytest #3475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GrayHoang
wants to merge
18
commits into
UBC-Thunderbots:master
Choose a base branch
from
GrayHoang:penalty_kick_play_pytest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Penalty kick play pytest #3475
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
39c2e33
Testing file
GrayHoang 66e345d
validation for test
GrayHoang d760496
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 921b5c4
adds test for ball entering crease
GrayHoang 2c86881
Merge branch 'penalty_kick_play_pytest' of github.com:potatoisagender…
GrayHoang 149af32
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] cbd7a74
Adjust invariants for testing
GrayHoang d16e655
Remove old cpp test from BUILD and files
GrayHoang 54d91b5
Merge branch 'penalty_kick_play_pytest' of github.com:potatoisagender…
GrayHoang 343dc64
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 4326f72
wrong validation set
GrayHoang 8a08504
Merge branch 'penalty_kick_play_pytest' of github.com:potatoisagender…
GrayHoang 734f1a3
pytest for tactic
GrayHoang caf3295
penalty kick tactic test
GrayHoang 58ea4ae
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] bffa453
adjust starting position for kick
GrayHoang fc01743
split play test into two parts and verification
GrayHoang 5a7ebec
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
110 changes: 110 additions & 0 deletions
110
src/software/ai/hl/stp/play/penalty_kick/penalty_kick_play_test.py
This file contains hidden or 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,110 @@ | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| import software.python_bindings as tbots_cpp | ||
|
|
||
| from software.simulated_tests.ball_enters_region import BallEventuallyEntersRegion | ||
| from software.simulated_tests.friendly_has_ball_possession import ( | ||
| FriendlyAlwaysHasBallPossession, | ||
| ) | ||
| from software.simulated_tests.friendly_team_scored import FriendlyTeamEventuallyScored | ||
|
|
||
| from proto.message_translation.tbots_protobuf import create_world_state | ||
| from proto.import_all_protos import * | ||
| from proto.ssl_gc_common_pb2 import Team | ||
| from proto.play_pb2 import Play, PlayName | ||
|
|
||
|
|
||
| def test_penalty_kick_play(simulated_test_runner): | ||
| ball_initial_pos = tbots_cpp.Point(0, 0) | ||
|
|
||
| def setup(*args): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docstring, add param docs for |
||
| # Setup Bots | ||
| blue_bots = [ | ||
| tbots_cpp.Point(-3, 2.5), | ||
| tbots_cpp.Point(-3, 1.5), | ||
| tbots_cpp.Point(-3, 0.5), | ||
| tbots_cpp.Point(-3, -0.5), | ||
| tbots_cpp.Point(-3, -1.5), | ||
| tbots_cpp.Point(-3, -2.5), | ||
| ] | ||
|
|
||
| yellow_bots = [ | ||
| tbots_cpp.Point(1, 0), | ||
| tbots_cpp.Point(1, 2.5), | ||
| tbots_cpp.Point(1, -2.5), | ||
| tbots_cpp.Field.createSSLDivisionBField().enemyGoalCenter(), | ||
| tbots_cpp.Field.createSSLDivisionBField() | ||
| .enemyDefenseArea() | ||
| .negXNegYCorner(), | ||
| tbots_cpp.Field.createSSLDivisionBField() | ||
| .enemyDefenseArea() | ||
| .negXPosYCorner(), | ||
| ] | ||
|
|
||
| # Force play override here | ||
| blue_play = Play() | ||
| blue_play.name = PlayName.PenaltyKickPlay | ||
|
|
||
| # Not sure if this should be penalty kick enemy play or halt play | ||
|
itsarune marked this conversation as resolved.
Outdated
|
||
| yellow_play = Play() | ||
| yellow_play.name = PlayName.PenaltyKickEnemyPlay | ||
|
|
||
| simulated_test_runner.blue_full_system_proto_unix_io.send_proto(Play, blue_play) | ||
| simulated_test_runner.yellow_full_system_proto_unix_io.send_proto( | ||
| Play, yellow_play | ||
| ) | ||
|
|
||
| # Game Controller Setup | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.STOP, team=Team.UNKNOWN | ||
| ) | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.NORMAL_START, team=Team.BLUE | ||
| ) | ||
| simulated_test_runner.gamecontroller.send_gc_command( | ||
| gc_command=Command.Type.PENALTY, team=Team.BLUE | ||
| ) | ||
|
|
||
| # Create world state | ||
| simulated_test_runner.simulator_proto_unix_io.send_proto( | ||
| WorldState, | ||
| create_world_state( | ||
| yellow_robot_locations=yellow_bots, | ||
| blue_robot_locations=blue_bots, | ||
| ball_location=ball_initial_pos, | ||
| ball_velocity=tbots_cpp.Vector(0, 0), | ||
| ), | ||
| ) | ||
|
|
||
| field = tbots_cpp.Field.createSSLDivisionBField() | ||
|
|
||
| # Always Validation | ||
| inv_always_validation_sequence_set = [[]] | ||
|
|
||
| ag_always_validation_sequence_set = [[FriendlyAlwaysHasBallPossession()]] | ||
|
itsarune marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Eventually Validation | ||
| inv_eventually_validation_sequence_set = [ | ||
| [ | ||
| FriendlyTeamEventuallyScored(), | ||
| BallEventuallyEntersRegion(regions=[field.enemyDefenseArea()]), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this validation is kinda redundant considering we have |
||
| ] | ||
| ] | ||
| ag_eventually_validation_sequence_set = [[]] | ||
|
|
||
| simulated_test_runner.run_test( | ||
| params=[0], | ||
| setup=setup, | ||
| inv_eventually_validation_sequence_set=inv_eventually_validation_sequence_set, | ||
| inv_always_validation_sequence_set=inv_always_validation_sequence_set, | ||
| ag_eventually_validation_sequence_set=ag_eventually_validation_sequence_set, | ||
| ag_always_validation_sequence_set=ag_always_validation_sequence_set, | ||
| test_timeout_s=15, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run the test, -s disables all capturing at -vv increases verbosity | ||
| sys.exit(pytest.main([__file__, "-svv"])) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.