Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Umbrella167/Rocos into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed Apr 15, 2024
2 parents 88ff416 + 7264139 commit 4337732
Show file tree
Hide file tree
Showing 9 changed files with 765 additions and 28 deletions.
17 changes: 16 additions & 1 deletion Core/src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,26 @@ const int inf = 1e9;
GlobalTick Tick[PARAM::Tick::TickLength];
int now = PARAM::Tick::TickLength - 1;
int last = PARAM::Tick::TickLength - 2;
CGeoPoint lastMovePoint = CGeoPoint(inf, inf);

namespace Utils
{
// 没写完 START

/**
* 用于稳定输出点
* @brief stabilizePoint
* @param p
* @return
*/
CGeoPoint stabilizePoint(CGeoPoint p){
if(lastMovePoint.dist(p) < 1000){
return lastMovePoint;
}
lastMovePoint = p;
return p;
}

/**
* 计算全局位置
* @param {CVisionModule*} pVision : 视觉模块
Expand Down Expand Up @@ -370,7 +385,7 @@ namespace Utils
* @param playerPos
* @param playerVel
* @param flag 不同模式(默认0),0-最早能拿到球的截球点,1-时间最充裕的截球点, 2- (0,1)方案取中点
* @param permissions 球员的权限(默认0), 0-不允许进禁区和到场外, 1-不可以进场外可以进禁区, 2-场外禁区都可以进
* @param permissions 球员的权限(默认0), 0-不允许进禁区和场外, 1-不可以到场外可以到禁区, 2-场外禁区都可以进
* @return
*/

Expand Down
2 changes: 2 additions & 0 deletions Core/src/Utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace Utils
extern CGeoSegment PredictBallLine(const CVisionModule *pVision);
extern double PosToPosTime(CGeoPoint start_pos, CGeoPoint end_pos, double velocity);

/* =============== 小工具 =============== */
extern CGeoPoint GetBallMaxPos(const CVisionModule *pVision);
extern CGeoPoint stabilizePoint(CGeoPoint p);

extern double ShowDribblingGrade(const CVisionModule *pVision,CGeoPoint run_pos,CGeoPoint player_pos,CGeoPoint target_pos);
extern CGeoPoint GetShowDribblingPos(const CVisionModule *pVision,CGeoPoint player_pos,CGeoPoint target_pos);
Expand Down
46 changes: 46 additions & 0 deletions Core/tactics/play/TestPassAndKick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local waitPos = ball.antiYPos(CGeoPoint:new_local(2800,2800))
local waitPos2 = ball.antiYPos(CGeoPoint:new_local(2800,2800))
local mode = true

return {
firstState = "init",
["init"] = {
switch = function()
if player.toTargetDist("Assister") < 1000 and player.toTargetDist("Leader") < 100 then
return "pass"
end
end,
Leader = task.staticGetBall(waitPos),
Assister = task.goCmuRush(waitPos2),
match = "[L][A]"
},
["pass"] = {
switch = function()
-- Utils.GlobalComputingPos(vision,player.pos("Assister"))
if player.kickBall("Leader") then
return "shoot"
end
end,
Leader = task.touchKick(waitPos, false, 2500, mode),
Assister = task.goCmuRush(waitPos2),
match = "{LA}"
},
["shoot"] = {
switch = function()
if player.kickBall("Assister") then
return "init"
end
end,
Leader = task.stop(),
Assister = task.touchKick(pos.theirGoal(), false,6000,mode),
match = "{LA}"
},

name = "TestPassAndKick",
applicable ={
exp = "a",
a = true
},
attribute = "attack",
timeout = 99999
}
12 changes: 7 additions & 5 deletions Core/tactics/play/TestSubScript.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ return {
switch = function()
if bufcnt(true,30) then
if not subScript then
gSubPlay.new("kickTask", "TestPassAndKick")
-- gSubPlay.new("kickTask", "TestPassAndKick")
gSubPlay.new("testTask", "mytest2")
end
return "run"
end
end,
Assister = task.stop(),
Leader = task.stop(),
match = "[LA]"
Goalie = task.stop(),
match = "[LAG]"
},
["run"] = {
switch = function()
Expand All @@ -40,9 +42,9 @@ return {
-- print("printFileTable: ", key, value)
-- end
end,
b = gSubPlay.roleTask("kickTask", "Assister"),
c = gSubPlay.roleTask("kickTask", "Leader"),
a = task.goCmuRush(runPos, 0, nil, DSS_FLAG),
-- b = gSubPlay.roleTask("kickTask", "Assister"),
c = gSubPlay.roleTask("testTask", "Goalie"),
-- a = task.goCmuRush(runPos, 0, nil, DSS_FLAG),
match = "(abc)"
},

Expand Down
28 changes: 23 additions & 5 deletions Core/tactics/play/mytest2.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gPlayTable.CreatePlay{

return {

firstState = "Init",

Expand All @@ -7,17 +8,34 @@ firstState = "Init",
-- debugEngine:gui_debug_msg(CGeoPoint(0, 0), enemy.closestBall())
-- debugEngine:gui_debug_msg(CGeoPoint(1000, 1300), enemy.atBallLine())
-- if bufcnt(true,20) then
-- return "GetGlobalMessage"
return "run1"
-- end
end,
Assister = task.stop(),
Kicker = task.stop(),
Special = task.stop(),
-- Assister = task.stop(),
-- Kicker = task.stop(),
-- Special = task.stop(),
Tier = task.stop(),
Defender = task.stop(),
Goalie = task.goalie("Goalie"),
match = "[A][KS]{TDG}"
},
["run1"] = {
switch = function()
-- debugEngine:gui_debug_msg(CGeoPoint(0, 0), enemy.closestBall())
-- debugEngine:gui_debug_msg(CGeoPoint(1000, 1300), enemy.atBallLine())
-- if bufcnt(true,20) then
-- return "run1"
-- end
end,
-- Assister = task.stop(),
-- Kicker = task.stop(),
-- Special = task.stop(),
Tier = task.defender("Tier"),
Defender = task.defender("Defender"),
-- Goalie = task.goalie("Goalie"),
Goalie = task.goCmuRush(runPos, 0, nil, DSS_FLAG),
match = "[A][KS]{TDG}"
},

name = "mytest2",
applicable ={
Expand Down
Loading

0 comments on commit 4337732

Please sign in to comment.