本文整理汇总了C++中Strategy::SelectTank方法的典型用法代码示例。如果您正苦于以下问题:C++ Strategy::SelectTank方法的具体用法?C++ Strategy::SelectTank怎么用?C++ Strategy::SelectTank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strategy
的用法示例。
在下文中一共展示了Strategy::SelectTank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void Runner::Run() {
remote_process_client.WriteToken(token);
int team_size = remote_process_client.ReadTeamSize();
vector<Strategy*> strategies;
vector<TankType> tank_types;
for (int strategy_index = 0; strategy_index < team_size; ++strategy_index) {
Strategy* strategy = new MyStrategy;
strategies.push_back(strategy);
tank_types.push_back(strategy->SelectTank(strategy_index, team_size));
}
remote_process_client.WriteSelectedTanks(tank_types);
PlayerContext* player_context;
while ((player_context = remote_process_client.ReadPlayerContext()) != NULL) {
vector<Tank> player_tanks = player_context->tanks();
if (player_tanks.size() != team_size) {
break;
}
vector<Move> moves;
for (int strategy_index = 0; strategy_index < team_size; ++strategy_index) {
Move move;
strategies[strategy_index]->Move(player_tanks[strategy_index], player_context->world(), move);
moves.push_back(move);
}
remote_process_client.WriteMoves(moves);
delete player_context;
}
for (int strategy_index = 0; strategy_index < team_size; ++strategy_index) {
delete strategies[strategy_index];
}
}