-
Notifications
You must be signed in to change notification settings - Fork 98
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
Improve FreeKickPlay behaviour and convert it to use FSMs #2953
base: master
Are you sure you want to change the base?
Changes from 17 commits
021d61d
1657a93
3f9dc79
1c08c7d
4f21d2e
b59eb7d
ae4adab
f40af89
d482e6b
6f34861
9010163
84c3a4f
ebbeb5e
c5e34df
b34e972
5021ade
a9725ec
fd34328
023d854
c72e46c
044e7a2
a8bd1c1
babac45
ff36d13
5cc2e7f
4a15972
0ca8c80
3327f89
5893fe8
ff478bf
80e07c2
e3dfe1d
d97fe64
00e1e55
b473d69
d02f173
0ccf164
e8a71e3
8a19f00
b75ca77
d8674ed
36b7990
13fec3f
f4ee834
1290070
3f94ad0
a7a1a72
ad6ff93
2f75bd7
33d1506
c3695f4
e227cdc
8645098
99eceba
36f2f04
45771d3
fc30414
37422e6
37d3785
629a936
3844cb2
77d2354
6954b80
62dda73
7df5317
03d8344
fbb2563
ee2b01b
b14e6c6
6e99bc1
de6aaa2
0c3c936
423c981
a1f5fcc
67d5c57
c2c1a22
91d3e91
9bfbb74
0338547
540fb56
7b127db
55fb728
dba41a4
7cffa2c
de1b49a
7ad435b
ea5d942
48b0023
527287a
88864b0
9426966
716e001
38f0ee6
83000b3
ce40aef
17c02ae
c5ffe99
88ce00f
283a02a
608f743
482a18d
5862749
bdcccc1
96672f0
62fa115
0e35e7e
732d579
94fd82b
7e8e61a
29144df
43ee59a
e26305a
f84b0bd
b4354db
7abec48
ad3ce9c
69d5f65
b3e59d6
5f613a2
723e66c
f0e33f8
43c15ed
4043eaa
d082c78
c79e4f9
aa68222
e455be8
d99a7e9
aeda8f7
710317a
3ed7f18
2c29a12
33eb3d4
90515f1
cf333d0
8140017
f869d6a
a2a58e2
92d560d
0988ec3
93d6b57
56022c5
9e9b57c
28ab1dc
565a925
2d9a38b
89da4e8
73bcaa0
82246b7
4ac04ff
a66c524
2d95d77
c8a7b87
bcfd6f7
7df74a5
6c0d8db
54d12aa
d77489c
0718d47
fa9cbcb
2338acf
72d2a5e
95df696
bbd3c03
ab56c66
af5d7b2
ac5e2bf
a092b33
0a51461
01b35a4
a0e8e76
2d081f3
be2e223
5accce4
3db0eb1
5518d50
4490a00
3e974b5
ec2cfad
fcb1f47
3edfabe
83767c3
3cefcc1
3b25a39
bdc48b7
8aeeb69
e2aa419
d2fd4ff
ed26163
38c52f2
b187d60
ea41c7d
7d1045d
3aaa838
988f9e7
88e34f2
10a4c19
4f2423a
99b8538
933482e
8e36a9e
44ad24e
aec3f53
eb400f2
c3eae3b
7f0004b
2bd1222
068a516
f781fc5
58627e9
602068b
4cf6976
52c3512
c77da48
cac2cd6
6cd95fe
0a12519
f6869fc
63160f8
e3f2a03
7a0beeb
6ef07ff
bb8dd4c
8374bd9
2f821f6
f8a1c84
28f114f
a984e18
0505164
a649732
3abd47d
9b710f3
22b9a28
0c0f786
1220776
af86297
7e1a86a
e4e0933
3a1a0b8
b81dfa3
4fa603b
45e47f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@simulated_tests_deps//:requirements.bzl", "requirement") | ||
|
||
cc_library( | ||
name = "free_kick_play", | ||
srcs = [ | ||
"free_kick_play.cpp", | ||
"free_kick_play_fsm.cpp", | ||
], | ||
hdrs = [ | ||
"free_kick_play.h", | ||
"free_kick_play_fsm.h", | ||
], | ||
deps = [ | ||
"//shared:constants", | ||
"//software/ai/evaluation:enemy_threat", | ||
"//software/ai/evaluation:find_open_areas", | ||
"//software/ai/evaluation:possession", | ||
"//software/ai/hl/stp/play", | ||
"//software/ai/hl/stp/tactic/chip:chip_tactic", | ||
"//software/ai/hl/stp/tactic/crease_defender:crease_defender_tactic", | ||
"//software/ai/hl/stp/tactic/goalie:goalie_tactic", | ||
"//software/ai/hl/stp/tactic/move:move_tactic", | ||
"//software/ai/hl/stp/tactic/receiver:receiver_tactic", | ||
"//software/ai/passing:eighteen_zone_pitch_division", | ||
"//software/ai/passing:pass_generator", | ||
"//software/logger", | ||
"//software/util/generic_factory", | ||
"//software/world:ball", | ||
], | ||
alwayslink = True, | ||
) | ||
|
||
cc_test( | ||
name = "free_kick_play_cpp_test", | ||
srcs = ["free_kick_play_test.cpp"], | ||
deps = [ | ||
"//shared/test_util:tbots_gtest_main", | ||
"//software/ai/hl/stp/play/free_kick:free_kick_play", | ||
"//software/simulated_tests:simulated_er_force_sim_play_test_fixture", | ||
"//software/simulated_tests/validation:validation_function", | ||
"//software/test_util", | ||
"//software/time:duration", | ||
"//software/world", | ||
], | ||
) | ||
|
||
py_test( | ||
name = "free_kick_play_test", | ||
srcs = ["free_kick_play_test.py"], | ||
tags = ["exclusive"], | ||
deps = [ | ||
"//software/simulated_tests:simulated_test_fixture", | ||
"//software/simulated_tests:validation", | ||
requirement("pytest"), | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "software/ai/hl/stp/play/free_kick/free_kick_play.h" | ||
|
||
#include "shared/constants.h" | ||
#include "software/util/generic_factory/generic_factory.h" | ||
|
||
FreeKickPlay::FreeKickPlay(TbotsProto::AiConfig config) | ||
: Play(config, true), fsm{FreeKickPlayFSM{config}}, control_params{} | ||
{ | ||
} | ||
|
||
void FreeKickPlay::getNextTactics(TacticCoroutine::push_type &yield, const World &world) | ||
{ | ||
// This function doesn't get called so it does nothing, will be removed once | ||
// coroutines are phased out | ||
} | ||
|
||
void FreeKickPlay::updateTactics(const PlayUpdate &play_update) | ||
{ | ||
fsm.process_event(FreeKickPlayFSM::Update(control_params, play_update)); | ||
} | ||
|
||
std::vector<std::string> FreeKickPlay::getState() | ||
{ | ||
std::vector<std::string> state; | ||
state.emplace_back(objectTypeName(*this) + " - " + getCurrentFullStateName(fsm)); | ||
return state; | ||
} | ||
|
||
// Register this play in the genericFactory | ||
static TGenericFactory<std::string, Play, FreeKickPlay, TbotsProto::AiConfig> factory; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "software/ai/hl/stp/play/free_kick/free_kick_play_fsm.h" | ||
|
||
class FreeKickPlay : public Play | ||
raymond212 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public: | ||
FreeKickPlay(TbotsProto::AiConfig config); | ||
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. the constructor should have docs 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. Bump 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. Added |
||
|
||
void getNextTactics(TacticCoroutine::push_type &yield, const World &world) override; | ||
void updateTactics(const PlayUpdate &play_update) override; | ||
std::vector<std::string> getState() override; | ||
|
||
private: | ||
FSM<FreeKickPlayFSM> fsm; | ||
FreeKickPlayFSM::ControlParams control_params; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FreeKickPlayFSM shouldn't be in control of all the robots and do its own defense behavior. Delegate some of the robots to DefensePlay and remove defensive behaviors from FreeKickPlayFSM
Take a look at
offense_play.cpp
for an exampleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! I've updated it.