Skip to content
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

Added option for to use custom markers and color as well as custom annotations when plotting round #204

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JanEricNitschke
Copy link
Collaborator

@JanEricNitschke JanEricNitschke commented Nov 24, 2022

In response to #133.

To reproduce the functionality from the issue one could use:

def annotations(
    a,
    map_name,
    frames,
    frame_index,
    annotation_args,
):
    for side in ["ct", "t"]:
        for p in frames[frame_index][side]["players"]:
            a.annotate(
                p["hp"],
                (
                    position_transform(map_name, p["x"], "x") - 15,
                    position_transform(map_name, p["y"], "y") - 20,
                ),
                fontsize=5,
                color="white",
            )
    return a


def players_markers(
    map_name, frames, frame_index, side, p, positions, colors, markers, custom_args
):
    player_names_colors = custom_args["colors"]
    if side == "ct":
        colors.append("cyan")
    else:
        colors.append("red")
    if p["hp"] == 0:
        markers.append("x")
    else:
        markers.append("o")

    pos = position_transform_all(map_name, (p["x"], p["y"], p["z"]))
    positions.append(pos)
    if p["name"] in player_names_colors.keys():
        markers.append(".")
        colors.append(player_names_colors[p["name"]])
    else:
        markers.append(".")
        if side == "t":
            colors.append("red")
        if side == "ct":
            colors.append("cyan")
    pos = position_transform_all(map_name, (p["x"], p["y"], p["z"]))
    positions.append(pos)

player_names_colors = {
    "brnz4n": "blue",
    "JOTA": "orange",
    "HEN1": "green",
    "Tuurtle": "yellow",
    "exit": "purple",
    "lux": "purple",
    "V$M": "orange",
    "felps": "blue",
    "Lucaozy": "yellow",
    "WOOD7": "green",
}

plot_round(
    filename=r"D:/CSGO/ML/csgoml/Plots/vis_improv/test_custom.gif",
    frames=data["gameRounds"][7]["frames"],
    map_name=data["mapName"],
    custom_marker_color_function=players_markers,
    custom_args={"colors": player_names_colors},
    annotation_function=annotations,
)

https://imgur.com/a/P7VWXDq

Should probably change the bomb marker to "1" like in the issue because otherwise it can be hidden by larger player markers (like here).

Also i am not really sure if the arguments that i am currently passing to the functions are the optimal ones. Maybe we can reduce them or maybe we have to add some (or also restructure them into a dict as well)

@JanEricNitschke JanEricNitschke marked this pull request as draft April 28, 2023 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant