Skip to content

Commit

Permalink
Merge #3246 - New offensive gameplay
Browse files Browse the repository at this point in the history
  • Loading branch information
williamckha committed Jul 16, 2024
1 parent b9755c2 commit a8b1261
Show file tree
Hide file tree
Showing 354 changed files with 8,111 additions and 7,078 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ src/external/external
*.log
*.csv

# Explicitly unignore files with weights
!software/ai/evaluation/q_learning/attacker_mdp_q_function_weights.csv

### Node ###

# Dependencies
Expand Down
319 changes: 164 additions & 155 deletions docs/fsm-diagrams.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ http_archive(
url = "https://github.com/ReneNyffenegger/cpp-base64/archive/refs/tags/V2.rc.08.zip",
)

http_archive(
name = "csv",
build_file = "@//extlibs:csv.BUILD",
sha256 = "83170169f2af38b171d7c3e127d9411fe381988a4b8910465f7d1c4c6169e815",
strip_prefix = "csv-parser-2.2.3",
url = "https://github.com/vincentlaucsb/csv-parser/archive/refs/tags/2.2.3.zip",
)

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
Expand Down
13 changes: 13 additions & 0 deletions src/extlibs/csv.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package(default_visibility = ["//visibility:public"])

genrule(
name = "copy_csv",
srcs = ["single_include/csv.hpp"],
outs = ["csv.hpp"],
cmd = "cp $< $(@)",
)

cc_library(
name = "csv",
hdrs = ["csv.hpp"],
)
2 changes: 2 additions & 0 deletions src/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ proto_library(
"play.proto",
"power_frame_msg.proto",
"primitive.proto",
"q_learning.proto",
"robot_crash_msg.proto",
"robot_log_msg.proto",
"robot_statistic.proto",
Expand Down Expand Up @@ -53,6 +54,7 @@ py_proto_library(
"parameters.proto",
"play.proto",
"primitive.proto",
"q_learning.proto",
"robot_statistic.proto",
"robot_status_msg.proto",
"tactic.proto",
Expand Down
36 changes: 36 additions & 0 deletions src/proto/message_translation/tbots_protobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,42 @@ std::unique_ptr<TbotsProto::PassVisualization> createPassVisualization(
return pass_visualization_msg;
}

std::unique_ptr<TbotsProto::AttackerVisualization> createAttackerVisualization(
const std::optional<Pass>& pass, const bool pass_committed,
const std::optional<Shot>& shot, const std::optional<Point>& ball_position,
const std::optional<Point>& chip_target)
{
auto pass_visualization_msg = std::make_unique<TbotsProto::AttackerVisualization>();

if (pass.has_value())
{
TbotsProto::Pass pass_msg;
*(pass_msg.mutable_passer_point()) = *createPointProto(pass->passerPoint());
*(pass_msg.mutable_receiver_point()) = *createPointProto(pass->receiverPoint());
pass_msg.set_pass_speed_m_per_s(pass->speed());
*(pass_visualization_msg->mutable_pass_()) = pass_msg;
}

pass_visualization_msg->set_pass_committed(pass_committed);

if (shot.has_value() && ball_position.has_value())
{
TbotsProto::Shot shot_msg;
*(shot_msg.mutable_shot_origin()) = *createPointProto(ball_position.value());
*(shot_msg.mutable_shot_target()) = *createPointProto(shot->getPointToShootAt());
*(shot_msg.mutable_open_angle()) = *createAngleProto(shot->getOpenAngle());
*(pass_visualization_msg->mutable_shot()) = shot_msg;
}

if (chip_target.has_value())
{
*(pass_visualization_msg->mutable_chip_target()) =
*createPointProto(chip_target.value());
}

return pass_visualization_msg;
}

std::unique_ptr<TbotsProto::WorldStateReceivedTrigger> createWorldStateReceivedTrigger()
{
auto world_state_received_trigger_msg =
Expand Down
16 changes: 16 additions & 0 deletions src/proto/message_translation/tbots_protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "proto/vision.pb.h"
#include "proto/visualization.pb.h"
#include "proto/world.pb.h"
#include "software/ai/evaluation/shot.h"
#include "software/ai/navigator/trajectory/bang_bang_trajectory_1d_angular.h"
#include "software/ai/navigator/trajectory/trajectory_path.h"
#include "software/ai/passing/pass_with_rating.h"
Expand Down Expand Up @@ -213,6 +214,21 @@ BallState createBallState(const TbotsProto::BallState ball_state);
std::unique_ptr<TbotsProto::PassVisualization> createPassVisualization(
const std::vector<PassWithRating>& passes_with_rating);

/**
* Returns an attacker visualization
*
* @param pass An optional pass to visualize
* @param pass_committed Whether we are committed to taking the pass
* @param shot An optional shot to visualize
* @param ball_position The current position of the ball used to visualize the shot
* @param chip_target An optional target that we are chipping to
*
* @return The unique_ptr to an AttackerVisualization proto
*/
std::unique_ptr<TbotsProto::AttackerVisualization> createAttackerVisualization(
const std::optional<Pass>& pass, bool pass_committed, const std::optional<Shot>& shot,
const std::optional<Point>& ball_position, const std::optional<Point>& chip_target);

/**
* Returns the WorldStateReceivedTrigger given the world state received trigger
*
Expand Down
Loading

0 comments on commit a8b1261

Please sign in to comment.