Skip to content

Commit 581140e

Browse files
committed
clean code in server side decision making
1 parent e5ebad8 commit 581140e

File tree

9 files changed

+14
-81
lines changed

9 files changed

+14
-81
lines changed

src/player/planner/actgen_cross.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ ActGen_Cross::generate( std::vector< ActionStatePair > * result,
5959

6060
const std::vector< CooperativeAction::Ptr > & courses = CrossGenerator::instance().courses( wm );
6161

62-
for (auto & course : courses)
63-
{
64-
if (path.empty())
65-
{
66-
course->setParentIndex(-1);
67-
}
68-
else
69-
{
70-
course->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
71-
}
72-
}
7362

7463
//
7564
// add pass course candidates

src/player/planner/actgen_direct_pass.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,6 @@ ActGen_DirectPass::generate( std::vector< ActionStatePair > * result,
305305
kick_step,
306306
false,
307307
"actgenDirect" ) );
308-
if (path.empty())
309-
{
310-
action->setParentIndex(-1);
311-
}
312-
else
313-
{
314-
action->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
315-
}
316308
++s_action_count;
317309
++generated_count;
318310
action->setIndex( s_action_count );

src/player/planner/actgen_self_pass.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ ActGen_SelfPass::generate( std::vector< ActionStatePair > * result,
6969
const std::vector< CooperativeAction::Ptr > &
7070
cont = SelfPassGenerator::instance().courses( wm );
7171

72-
for (auto & course : cont)
73-
{
74-
if (path.empty())
75-
{
76-
course->setParentIndex(-1);
77-
}
78-
else
79-
{
80-
course->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
81-
}
82-
}
8372
//
8473
// add dribble candidates
8574
//

src/player/planner/actgen_shoot.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ ActGen_Shoot::generate( std::vector< ActionStatePair > * result,
108108
shoot_spend_time,
109109
1,
110110
"shoot" ) );
111-
if (path.empty())
112-
{
113-
action->setParentIndex(-1);
114-
}
115-
else
116-
{
117-
action->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
118-
}
119111

120112
result->push_back( ActionStatePair( action, result_state ) );
121113
}

src/player/planner/actgen_short_dribble.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ ActGen_ShortDribble::generate( std::vector< ActionStatePair > * result,
7070
const std::vector< CooperativeAction::Ptr > &
7171
cont = ShortDribbleGenerator::instance().courses( wm );
7272

73-
for (auto & course : cont)
74-
{
75-
if (path.empty())
76-
{
77-
course->setParentIndex(-1);
78-
}
79-
else
80-
{
81-
course->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
82-
}
83-
}
8473
//
8574
// add dribble candidates
8675
//

src/player/planner/actgen_simple_dribble.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ ActGen_SimpleDribble::generate( std::vector< ActionStatePair > * result,
191191
holder_reach_step - 2,
192192
"actgenDribble" ) );
193193

194-
if (path.empty())
195-
{
196-
action->setParentIndex(-1);
197-
}
198-
else
199-
{
200-
action->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
201-
}
202194
++s_action_count;
203195
++generated_count;
204196
action->setIndex( s_action_count );

src/player/planner/actgen_strict_check_pass.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,6 @@ ActGen_StrictCheckPass::generate( std::vector< ActionStatePair > * result,
6262
M_generate_direct_pass,
6363
M_generate_lead_pass,
6464
M_generate_through_pass );
65-
for (auto & course : courses)
66-
{
67-
if (path.empty())
68-
{
69-
course->setParentIndex(-1);
70-
}
71-
else
72-
{
73-
course->setParentIndex(( *( path.rbegin() ) ).action().uniqueIndex());
74-
}
75-
}
7665
//
7766
// add pass course candidates
7867
//

src/player/planner/action_chain_graph.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ ActionChainGraph::calculateResultBestFirstSearch( const WorldModel & wm,
524524

525525
auto copy_action = std::make_shared<CooperativeAction>(it->action());
526526
auto copy_state = std::make_shared<PredictState>(it->state());
527+
copy_action->setParentIndex(parent_index);
527528
auto new_action_state_pair = std::shared_ptr<ActionStatePair>(new ActionStatePair(copy_action, copy_state));
528529
M_all_results[copy_action->uniqueIndex()] = std::make_pair(new_action_state_pair, ev);
529530

@@ -779,6 +780,7 @@ ActionChainGraph::write_chain_log( const std::string & pre_log_message,
779780
for ( size_t i = 0; i < path.size(); ++i )
780781
{
781782
const CooperativeAction & a = path[i].action();
783+
int unique_index = a.uniqueIndex();
782784
const PredictState * s0;
783785
const PredictState * s1;
784786

@@ -798,16 +800,16 @@ ActionChainGraph::write_chain_log( const std::string & pre_log_message,
798800
case CooperativeAction::Hold:
799801
{
800802
dlog.addText( Logger::ACTION_CHAIN,
801-
"__ %d: hold (%s) t=%d",
802-
i, a.description(), s1->spendTime() );
803+
"__ %d: u%d: hold (%s) t=%d",
804+
i, unique_index, a.description(), s1->spendTime() );
803805
break;
804806
}
805807

806808
case CooperativeAction::Dribble:
807809
{
808810
dlog.addText( Logger::ACTION_CHAIN,
809-
"__ %d: dribble (%s[%d]) t=%d unum=%d target=(%.2f %.2f)",
810-
i, a.description(), a.index(), s1->spendTime(),
811+
"__ %d: u%d: dribble (%s[%d]) t=%d unum=%d target=(%.2f %.2f)",
812+
i, unique_index, a.description(), a.index(), s1->spendTime(),
811813
s0->ballHolderUnum(),
812814
a.targetPoint().x, a.targetPoint().y );
813815
break;
@@ -816,8 +818,8 @@ ActionChainGraph::write_chain_log( const std::string & pre_log_message,
816818
case CooperativeAction::Pass:
817819
{
818820
dlog.addText( Logger::ACTION_CHAIN,
819-
"__ %d: pass (%s[%d]) t=%d from[%d](%.2f %.2f)-to[%d](%.2f %.2f)",
820-
i, a.description(), a.index(), s1->spendTime(),
821+
"__ %d: u%d: pass (%s[%d]) t=%d from[%d](%.2f %.2f)-to[%d](%.2f %.2f)",
822+
i, unique_index, a.description(), a.index(), s1->spendTime(),
821823
s0->ballHolderUnum(),
822824
s0->ball().pos().x, s0->ball().pos().y,
823825
s1->ballHolderUnum(),
@@ -828,8 +830,8 @@ ActionChainGraph::write_chain_log( const std::string & pre_log_message,
828830
case CooperativeAction::Shoot:
829831
{
830832
dlog.addText( Logger::ACTION_CHAIN,
831-
"__ %d: shoot (%s) t=%d unum=%d",
832-
i, a.description(), s1->spendTime(),
833+
"__ %d: u%d: shoot (%s) t=%d unum=%d",
834+
i, unique_index, a.description(), s1->spendTime(),
833835
s0->ballHolderUnum() );
834836

835837
break;
@@ -838,16 +840,16 @@ ActionChainGraph::write_chain_log( const std::string & pre_log_message,
838840
case CooperativeAction::Move:
839841
{
840842
dlog.addText( Logger::ACTION_CHAIN,
841-
"__ %d: move (%s)",
842-
i, a.description(), s1->spendTime() );
843+
"__ %d: u%d: move (%s)",
844+
i, unique_index, a.description(), s1->spendTime() );
843845
break;
844846
}
845847

846848
default:
847849
{
848850
dlog.addText( Logger::ACTION_CHAIN,
849-
"__ %d: ???? (%s)",
850-
i, a.description(), s1->spendTime() );
851+
"__ %d: u%d: ???? (%s)",
852+
i, unique_index, a.description(), s1->spendTime() );
851853
break;
852854
}
853855
}

src/player/planner/cooperative_action.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ class CooperativeAction {
146146
{ }
147147

148148
void setIndex( const int i ) { M_index = i; }
149-
void setUniqueIndex( const int i ) { M_unique_index = i; }
150149
void setParentIndex( const int i ) { M_parent_index = i; }
151150

152151
void setFirstBallSpeed( const double & speed );

0 commit comments

Comments
 (0)