Read this in other languages:
-logging
- all screenshots will be placed in USER_HOME/logs/TestImages, the log will be written to logs/fifa_bot.log-replayer
- the application will be launched in Replayer mode-production
- any logs will be disabled in the application-visual-log
- will create a merged image with an overlaid log inUSER_HOME/logs/TestImages
. See ImageLogProducer
❓ Note: The bot can be launched as an .exe file (self-extracting archive compiled using jlink), downloaded in the Releases tab
⚠️ Important: The bot is configured to work in 1920x1080 resolution with 100% scaling
Collapse/Expand
Main - entry point for the application, creation and initialization of basic objects
ImageAnalysis - the class analyzes the image of the field diagram
GeometryUtils- class provides helper methods for 2D geometry
ImageUtils - the class provides helper methods for
serialization/deserialization of game state to/from .dat
file, getting image pixel color,
methods for organizing replay analysis, etc.
GameInfo - data class that stores information about the current game situations - coordinates of players, ball, active player, etc.
GameHistory - class stores previous game states and previous decisions
GameAction - class responsible for creating a game actions (pass, hit, move, etc.)
DecisionMaker - the class is responsible for making the best decision on
based on data from GameInfo
ActionProducer - the class is responsible for generating device events input. Currently only keyboard is available
ImageLogProducer - the class creates a full_game.png
image
displaying a visual log of the game. This is necessary for
debugging purposes and analysis of the "replay" from USER_HOME/logs/TestImages
ColorsEnum - listing the color ranges for which objects are identified during image analysis
ControlsEnum - listing possible game actions and their groups
GameConstantsEnum - stores static information unchangeable over time (coordinates of the center of the field, penalty area, initial delay of actions, etc.)
GeomEnum - stores auxiliary enumerations for defining directions
Collapse/Expand
The main game loop starts and the bot takes a screenshot of the field as BufferedImage
, for example⚽:
The bot analyzed the screenshot and received the following information:
playmates=[ opposites=[ activePlayer=[x=33,y=63]
[x=65,y=6] [x=134,y=23] ball=[x=36,y=64]
[x=108,y=7] [x=165,y=35] isPlaymateBallPossession=true
[x=117,y=49] [x=165,y=61] isShadingField=false
[x=65,y=53] [x=92,y=65] isNobodyBallPossession=false
[x=33,y=63] [x=155,y=65] playmateSide=LEFT_PLAYMATE_SIDE
[x=140,y=67] [x=214,y=73]
[x=106,y=72] [x=165,y=77]
[x=82,y=94] [x=141,y=81]
[x=53,y=96] [x=104,y=86]
[x=65,y=134] [x=165,y=103]
[x=108,y=134]] [x=138,y=118]]
Based on this information, a set of suitable actions was identified:
[
[
controls=[MOVE_UP, MOVE_RIGHT, ATTACK_SHORT_PASS_HEADER],
actionTargetPlayer=[x=65,y=53]
],
[
controls=[MOVE_RIGHT],
actionTargetPlayer=[x=33,y=63]
],
[
controls=[ATTACK_PROTECT_BALL],
actionTargetPlayer=[x=33,y=63]
]
]
From a set of actions, the bot selects the highest priority:
[
controls=[MOVE_UP, MOVE_RIGHT, ATTACK_SHORT_PASS_HEADER],
actionTargetPlayer=[x=65,y=53]
]
After executing the action, we get a new state⚽:
The bot performed the action correctly - gave a pass to the player who was in the upper right corner from active player in the previous screenshot, then the cycle repeats.
Collapse/Expand
This is what part of the log looks like with the described states📁:
For the purpose of debugging and analyzing the behavior of the bot, a class was written ImageLogProducer allowing you to link a text log with an image of the game state.
An example of a visual log for the states described above🔎:
⚠️ Important: TheUSER_HOME/logs/TestImages
folder should contain quite limited the number of images corresponding to a certain game interval, otherwise for ImageLogProducer may not be enough RAM create too long final image
The bot uses the following gameplay control scheme🔧:
Collapse/Expand
SPRINT - VK_E
MOVE_UP - VK_UP
MOVE_DOWN - VK_DOWN
MOVE_LEFT - VK_LEFT
MOVE_RIGHT - VK_RIGHT
MOVE_UP_PAD - VK_NUMPAD8
MOVE_DOWN_PAD - VK_NUMPAD2
MOVE_LEFT_PAD - VK_NUMPAD4
MOVE_RIGHT_PAD - VK_NUMPAD6
TACTICS - VK_J
MENTALITY_LEFT - VK_K
MENTALITY_RIGHT - VK_L
CUSTOM_TACTICS - VK_CAPS_LOCK
SWITCH_FROM_GK - VK_F
ATTACK_THROUGH_BALL - VK_A
ATTACK_LOB_PASS_CROSS_HEADER - VK_S
ATTACK_SHOOT_VOLLEY_HEADER - VK_W
ATTACK_SHORT_PASS_HEADER - VK_D
ATTACK_PLAYER_RUN_MODIFIER - VK_SPACE
ATTACK_FINESSE_SHOT_MODIFIER - VK_Q
ATTACK_PROTECT_BALL - VK_SHIFT
DEFENCE_RUSH_GK - VK_A
DEFENCE_SLIDING_TACKLE - VK_S
DEFENCE_TACKLE_PUSH_OR_PULL - VK_W
DEFENCE_CONTAIN - VK_D
DEFENCE_CHANGE_PLAYER - VK_SPACE
DEFENCE_TEAMMATE_CONTAIN - VK_Q
DEFENCE_JOCKEY - VK_SHIFT
CHIP_SHOT - VK_SPACE + VK_W
FINESSE_SHOT - VK_Q + VK_W
LOW_SHOT - VK_SPACE + VK_Q + VK_W
THREADED_THROUGH_PASS - VK_Q + VK_A
LOBBED_THROUGH_PASS - VK_SPACE + VK_A
DRIVEN_LOB_PASS_CROSS - VK_Q + VK_S
HIGH_LOB_CROSS - VK_SPACE + VK_S
LOW_CROSS - VK_S + VK_S
SCOOP_LOB - VK_SHIFT + VK_S
CANCEL - VK_SHIFT + VK_E
FLAIR_PASS - VK_SHIFT + VK_D
FLAIR_SHOOT - VK_SHIFT + VK_W
DRIVEN_GROUND_PASS - VK_Q + VK_D
RUNNING_JOCKEY - VK_SHIFT + VK_E
You need to create the appropriate configuration in the game client🎮:
The 2D field layout must be turned on and the players' colors must be red
- for you,
blue
- for the enemy, control device - Keyboard only
,
FullHD resolution, 100% scaling🖥️:
Difficulty level - beginner