icza / screp

StarCraft - Brood War replay parser
Apache License 2.0
80 stars 21 forks source link

compute teams for UMS AI map #44

Closed shenghsi closed 1 year ago

shenghsi commented 1 year ago

Example output: .\screp.exe -overview .\AutoSave\14AI.rep
Engine : BW 1.21+ Date : 2023-02-20 23:02:38 -08:00 Length : 07:13 Title : 24H 123 Map : [AI] BGH 3.0 BETA Type : Use map settings Matchup : TvPvPvPZvZ Winner : Team 1 Team R APM EAPM @ Name 2 T 214 144 11 yytbl 1 P 161 124 12 lin860801 2 P 223 153 1 [24H]WoBuLu 1 P 133 126 4 oldMovie 1 Z 208 120 6 CrazyStoneeeee 2 Z 98 93 10 [24H]oldguy

icza commented 1 year ago

Thanks for the PR, I might not have time to review it for a few days, but I'm not gonna forget it.

shenghsi commented 1 year ago

AI_rep.zip example reps

icza commented 1 year ago

It doesn't seem to work for one of the test repays you posted: 235958,AI BGH 3.0.rep screp -overview "235958,AI BGH 3.0.rep" output:

Engine  : BW 1.21+
Date    : 2023-02-25 08:59:30 +01:00
Length  : 00:19
Title   : 24H
Map     : [AI] BGH 3.0 BETA
Type    : Use map settings
Matchup : PPTvPvZ
Winner  : Team 1
Team  R  APM EAPM   @  Name 
  2   P  200  193  11  [24H]MoFan
  2   P  221  221   1  happydztk
  2   T  371   83   4  [24H]Mango
  1   P  150   95   5  Hao2022
  3   T   23   23   6  WoBuFu
  3   P  143  143   8  WoDaTian
  2   Z  182   80  10  CrazyStoneeeee
icza commented 1 year ago

Also here's another counter-example where it doesn't work: https://repmastered.app/game/FtRF3thNIjG5YQPE2RASxVpSyYpEsnzpi7P_L5peMA0

screp -overview of the above replay:

Engine  : BW -1.16
Date    : 2010-02-08 23:46:41 +01:00
Length  : 04:11
Title   : one
Map     : [AI] BGH 2.0
Type    : Use map settings
Matchup : TZPPTP
Winner  : 
Team  R  APM EAPM   @  Name 
  1   T  154  149  11  yava
  1   Z  240  139  12  OneZerg
  3   T    6    6   1  Chalkdust
  1   P  117   96   4  YaHairo
  1   P  168  118   6  Dakota_Fanning
  1   T   76   71   8  SlappeR[AoD]
  1   P  116  112  10  Player[Craft]
icza commented 1 year ago

I know your proposed solution tries to identify teams based on the Alliance commands, but in itself, this is not sufficient / reliable. The reliable way would be to parse the map triggers and other data, and analyze them, which is no small task of course.

Please note that computeMeleeTeams() also has a team detection algorithm that checks for consistent Alliance commands. Meaning it only overrides teams if all the players have set the same Alliances in the first 90 seconds. E.g. if player A and B are both allied to each other, and player C and D also, then it will override teams of A and B to be team 1, and C and D to be team 2. And only considers alliances of the first 90 seconds because often players give "ally end" which is to gain win points but doesn't change the team play over the corse of the game.

The problem why the same algorithm (team detection existing in computeMeleeTeams()) cannot be applied here is because while in Melee games all players have to set alliance explicitly, in AI UMS games this is done automatically and players only "check" it to see who their allies are. But there are no guarantee players actually check it. And also no guarantee they don't change it.

shenghsi commented 1 year ago

I made updates so that It only handles 2v2, 3v3, 4v4 games It will ignore games that:

icza commented 1 year ago

Will review it again soon when I have time. Thanks for the update.

icza commented 1 year ago

The algorithm is not perfect, but I'll accept it and I will improve it.

For example I can easily add support to detect teams in case of odd number of players.

Anyway, thanks for the PR, and look forward to my improvements.

icza commented 1 year ago

Happy to report that I rewrote the UMS AI team detection and it handles all kinds of team setup with observers pretty reliably. Will push soon.

icza commented 1 year ago

Reporting that released screp v1.10.0 with UMS AI support.

Maps with "[AI]" in their name and BGH Random Teams games are covered currently.

The above links contain almost a thousand example replays. If you have more, please share all on https://repmastered.app/upload