-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.py
More file actions
115 lines (94 loc) · 4.48 KB
/
program.py
File metadata and controls
115 lines (94 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from typing import Callable, List
import pymunk
from simulation import main
from tools import *
# config
CONFIG = {
"ATK_AUTO_DRIBBLE": False, # True for attack robot to dribble ball when it comes near
"DEF_AUTO_DRIBBLE": False, # True for defence robot to dribble ball when it comes near
"O_ATK_AUTO_DRIBBLE": False, # True for opponent attack robot to dribble ball when it comes near
"O_DEF_AUTO_DRIBBLE": False, # True for opponent defence robot to dribble ball when it comes near
}
# user programs
def attack(
robots: List[Robot],
detectLine: Callable[[Robot], pymunk.Vec2d],
ballPosition: pymunk.Vec2d,
robotPositions: List[pymunk.Vec2d],
dribble: Callable[[Robot], None],
kick: Callable[[Robot], None],
) -> None:
"""Program and logic for own attacking robot.
Args:
robots: A list of both Robots for own side.
detectLine: Function returning a pymunk.Vec2d vector representing
average **direction** of lines detected by robot passed as argument.
ballPosition: pymunk.Vec2d object representing world coordinate position of ball.
robotPositions: List of pymunk.Vec2d objects each representing the world coordinate position of a robot,
in order [own attack robot, own defense robot, opponent attack robot, opponent defense robot].
dribble: Function to dribble the ball (and sets robot.dribbleState)
kick: Function to kick the ball in the front catchment area (if any).
"""
return
def defend(
robots: List[Robot],
detectLine: Callable[[Robot], pymunk.Vec2d],
ballPosition: pymunk.Vec2d,
robotPositions: List[pymunk.Vec2d],
dribble: Callable[[Robot], None],
kick: Callable[[Robot], None],
) -> None:
"""Program and logic for own defending robot.
Args:
robots: A list of both Robots for own side.
detectLine: Function returning a pymunk.Vec2d vector representing
average **direction** of lines detected by robot passed as argument.
ballPosition: pymunk.Vec2d object representing world coordinate position of ball.
robotPositions: List of pymunk.Vec2d objects each representing the world coordinate position of a robot,
in order [own attack robot, own defense robot, opponent attack robot, opponent defense robot].
dribble: Function to dribble the ball (and sets robot.dribbleState)
kick: Function to kick the ball in the front catchment area (if any).
"""
return
def o_attack(
robots: List[Robot],
detectLine: Callable[[Robot], pymunk.Vec2d],
ballPosition: pymunk.Vec2d,
robotPositions: List[pymunk.Vec2d],
dribble: Callable[[Robot], None],
kick: Callable[[Robot], None],
) -> None:
"""Program and logic for opponent attacking robot.
Args:
robots: A list of both Robots for opponent side.
detectLine: Function returning a pymunk.Vec2d vector representing
average **direction** of lines detected by robot passed as argument.
ballPosition: pymunk.Vec2d object representing world coordinate position of ball.
robotPositions: List of pymunk.Vec2d objects each representing the world coordinate position of a robot,
in order [own attack robot, own defense robot, opponent attack robot, opponent defense robot].
dribble: Function to dribble the ball (and sets robot.dribbleState)
kick: Function to kick the ball in the front catchment area (if any).
"""
return
def o_defend(
robots: List[Robot],
detectLine: Callable,
ballPosition: pymunk.Vec2d,
robotPositions: List[pymunk.Vec2d],
dribble: Callable[[Robot], None],
kick: Callable[[Robot], None],
) -> None:
"""Program and logic for opponent defending robot.
Args:
robots: A list of both Robots for opponent side.
detectLine: Function returning a pymunk.Vec2d vector representing
average **direction** of lines detected by robot passed as argument.
ballPosition: pymunk.Vec2d object representing world coordinate position of ball.
robotPositions: List of pymunk.Vec2d objects each representing the world coordinate position of a robot,
in order [own attack robot, own defense robot, opponent attack robot, opponent defense robot].
dribble: Function to dribble the ball (and sets robot.dribbleState)
kick: Function to kick the ball in the front catchment area (if any).
"""
return
if __name__ == "__main__":
main(CONFIG, attack, defend, o_attack, o_defend)