Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Umbrella167/Rocos
Browse files Browse the repository at this point in the history
  • Loading branch information
dinzhen12 committed May 16, 2024
2 parents cd1a4c6 + 758bb12 commit 211d32c
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 77 deletions.
4 changes: 2 additions & 2 deletions Core/HuRocos-2024/PlayConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gRefConfig = {
GameHalt = "HALT",
GameStop = "STOP",
OurTimeout = "HALT",
TheirIndirectKick = "NORMALPLAY",
TheirIndirectKick = "NORMALPLAYV2",
OurIndirectKick = function()
if ball.posX() > 3000 then
return "our_CornerKick"
Expand All @@ -33,6 +33,6 @@ gRefConfig = {
OurBallPlacement = "our_BallPlacement",
TheirPenaltyKick = "their_Penalty",
OurPenaltyKick = "our_Penalty",
NormalPlay = "NORMALPLAY" -- {"NORMALPLAY", "NORMALPLAYV2"},
NormalPlay = "NORMALPLAYV2" -- {"NORMALPLAY", "NORMALPLAYV2"},
}
--]]
10 changes: 4 additions & 6 deletions Core/HuRocos-2024/play/HALT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ switch = function()
end,
["halt"] = {

["Leader"] = task.stop(),
["Kicker"] = task.stop(),
["Special"] = task.stop(),
["Assister"] = task.stop(),
["Defender"] = task.stop(),
["Middle"] = task.stop(),
["Center"] = task.stop(),
["Breaker"] = task.stop(),
["Center"] = task.stop(),
["Defender"] = task.stop(),
["Goalie"] = task.stop(),
match = "[LSADMCB]"
match = "[AKSC]{DG}"
},

name = "HALT",
Expand Down
4 changes: 2 additions & 2 deletions Core/HuRocos-2024/play/NORMALPLAYV2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ local getState = function ()
resultState = "Getball"
end

if Utils.InExclusionZone(ball.pos(), param.dribblingExclusionDist, "all") and ball_rights ~= 0 and resultState ~= "ShootPoint" then
if Utils.InExclusionZone(ball.pos(), param.dribblingExclusionDist, "all") and ball_rights ~= 0 then
resultState = "dribbling"
end

Expand Down Expand Up @@ -326,7 +326,7 @@ firstState = "Init",
switch = function()
UpdataTickMessage(our_goalie_num,defend_num1,defend_num2)
local State = getState()
if bufcnt(true,30) or State == "Getball" then
if bufcnt(true,35)then -- or State == "Getball"
return State
end

Expand Down
2 changes: 1 addition & 1 deletion Core/HuRocos-2024/play/Nor_Dribbling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local dribblingDir = function(role)
end
end
local dribblingCount = 0
local dribblingVel = 1000
local dribblingVel = 3000
local canShootAngle = 30
local showPassPos = param.shootPos
return {
Expand Down
12 changes: 6 additions & 6 deletions Core/HuRocos-2024/play/Nor_Shoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ local debugMesg = function ()
debugEngine:gui_debug_msg(resShootPos,"rotCompensatePos",6,0,param.debugSize)
debugEngine:gui_debug_x(param.shootPos,6,0,param.debugSize)
debugEngine:gui_debug_msg(param.shootPos,"ShootPos",6,0,param.debugSize)

end
return {

Expand Down Expand Up @@ -69,7 +68,7 @@ firstState = "Init",
end
local Vy = player.rotVel("Assister")
local ToTargetDist = player.toPointDist("Assister",param.shootPos)
resShootPos = task.compensateAngle("Assister",Vy,param.shootPos,ToTargetDist * param.rotCompensate)
resShootPos = task.compensateAngle("Assister",Vy,param.shootPos,ToTargetDist * param.rotCompensate(player.num("Assister")))
end,
Assister = task.getball(function() return shoot_pos end,param.playerVel,param.getballMode),
match = "[A]"
Expand All @@ -90,14 +89,14 @@ firstState = "Init",
end
local Vy = player.rotVel("Assister")
local ToTargetDist = player.toPointDist("Assister",param.shootPos)
resShootPos = task.compensateAngle("Assister",Vy,param.shootPos,ToTargetDist * param.rotCompensate)
resShootPos = task.compensateAngle("Assister",Vy,param.shootPos,ToTargetDist * param.rotCompensate(player.num("Assister")))

if(task.playerDirToPointDirSub("Assister",resShootPos) < param.shootError) then
return "shoot"
end

end,
Assister = function() return task.TurnToPointV2("Assister", function() return resShootPos end,param.rotVel()) end,
Assister = function() return task.TurnToPointV2("Assister", function() return resShootPos end,param.rotVel(player.num("Assister"))) end,
match = "{A}"
},

Expand All @@ -107,13 +106,14 @@ firstState = "Init",
debugMesg()
if(bufcnt(player.myinfraredCount("Assister") < 1,1)) then
return "getball"
end
end

if(task.playerDirToPointDirSub("Assister",resShootPos) > param.shootError) then
return "getball"
end

end,
Assister = task.ShootdotV2(function() return resShootPos end, param.shootError, kick.flat ),
Assister = task.ShootdotV2(function() return resShootPos end, param.shootError,function() return (player.num("Assister") == 3 and param.Team == "TWO") and kick.chip() or kick.flat() end),
match = "{A}"
},

Expand Down
13 changes: 7 additions & 6 deletions Core/HuRocos-2024/play/STOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local defendpos = {
CGeoPoint(-3300,-850),

}
local a = 1800
local DSS_FLAG = bit:_or(flag.allow_dss, flag.dodge_ball)
gPlayTable.CreatePlay {

Expand All @@ -38,13 +39,13 @@ firstState = "start",
return "exit"
end
end,
Kicker = task.goCmuRush(middlePos,dir.playerToBall,DSS_FLAG),
Assister = task.goCmuRush(leftPos,dir.playerToBall,DSS_FLAG),
Special = task.goCmuRush(rightPos,dir.playerToBall,DSS_FLAG),
Tier = task.goCmuRush(defendpos[3],dir.playerToBall,DSS_FLAG),
Defender = task.goCmuRush(defendpos[2],dir.playerToBall,DSS_FLAG),
Kicker = task.goCmuRush(middlePos,dir.playerToBall,a,DSS_FLAG),
Assister = task.goCmuRush(leftPos,dir.playerToBall,a,DSS_FLAG),
Special = task.goCmuRush(rightPos,dir.playerToBall,a,DSS_FLAG),
Center = task.goCmuRush(defendpos[3],dir.playerToBall,a,DSS_FLAG),
Defender = task.goCmuRush(defendpos[2],dir.playerToBall,a,DSS_FLAG),
Goalie = task.goCmuRush(defendpos[1],dir.playerToBall),
match = "[AKS]{TDG}"
match = "[AKSC]{DG}"
},

name = "STOP",
Expand Down
19 changes: 6 additions & 13 deletions Core/HuRocos-2024/play/our_KickOff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ ballRights = -1
shoot_pos = CGeoPoint:new_local(param.pitchLength / 2,0)
-- 被传球机器人
pass_player_num = 0

-- touch power
touchPower = 4000

Expand Down Expand Up @@ -188,34 +187,31 @@ firstState = "ready",
Assister = task.goCmuRush(p1, Dir_ball("Assister"),_,DSS_FLAG),
Special = task.goCmuRush(p3, Dir_ball("Special"),_,DSS_FLAG),
Kicker = task.goCmuRush(p2, Dir_ball("Kicker"),_,DSS_FLAG),
Tier = task.goCmuRush(p7, Dir_ball("Tier"),_,DSS_FLAG),
Center = task.goCmuRush(p7, Dir_ball("Center"),_,DSS_FLAG),
Defender = task.goCmuRush(p6, Dir_ball("Defender"),_,DSS_FLAG),
Goalie = task.goalie("Goalie"),
match = "[ASK]{TDG}"
match = "[ASKC]{DG}"
},

["OtherRunPos"] = {
switch = function ()

if GlobalMessage.Tick().ball.rights == -1 then
if GlobalMessage.Tick().ball.rights == -1 then
return "exit"
end

if(player.kickBall("Assister")) then
return "SpecialTouch"
end
end,
Assister = task.Shootdot("Assister",runPos_Special(-400), 5, kick.flat),
Special = task.goCmuRush(runPos_Special(-400), Dir_ball("Special"), a, f, r, v),
Kicker = task.goCmuRush(runPos_Kicker(-400), Dir_ball("Kicker"), a, f, r, v),
-- Tier = task.Shootdot("Tier",playerPos("Special"), shootKp, 5, kick.flat),
-- Defender = task.defender_defence("Defender"),
Goalie = task.goalie("Goalie"),
match = "{ASKTDG}"
match = "[ASKC]{DG}"

},
["SpecialTouch"] = {
switch = function ()
if GlobalMessage.Tick().ball.rights == -1 then
if GlobalMessage.Tick().ball.rights == -1 then
return "exit"
end
if(player.kickBall("Special")) then
Expand All @@ -225,16 +221,13 @@ firstState = "ready",
Assister = task.goCmuRush(runPos_Assister(-400), Dir_ball("Assister"), a, DSS_FLAG, r, v),
Special = task.touchKick(runPos_Kicker(0), false, param.shootKp, kick.flat),
Kicker = task.goCmuRush(runPos_Kicker(-400), Dir_ball("Kicker"), a, f, r, v),
-- Tier = task.defender_defence("Tier"),
-- Defender = task.defender_defence("Defender"),
Goalie = task.goalie("Goalie"),
match = "{ASKTDG}"
},


["KickerTouch"] = {
switch = function ()

if GlobalMessage.Tick().ball.rights == -1 then
return "exit"
end
Expand Down
22 changes: 14 additions & 8 deletions Core/HuRocos-2024/play/our_Penalty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local p2 = CGeoPoint(- param.pitchLength / 2 + 300,param.pitchWidth / 2 - 600)
local p3 = CGeoPoint(- param.pitchLength / 2 + 300, -param.pitchWidth / 2 + 300)
local p4 = CGeoPoint(- param.pitchLength / 2 + 300,-param.pitchWidth / 2 + 600)
local p5 = CGeoPoint(- param.pitchLength / 2 , 0)
local shootThreshold = 3000
local shootThreshold = 2500

local canShoot = function(role,ishootThreshold)
if ball.posX() > ishootThreshold then
Expand Down Expand Up @@ -35,7 +35,7 @@ local shootFlag = function(role)
end

local Power = function(role,shoot_flag,ishootThreshold)
local ipower = 100
local ipower = 110
local ishoot_falg
if type(shoot_flag) == 'function' then
ishoot_falg = shoot_flag()
Expand All @@ -44,11 +44,11 @@ local Power = function(role,shoot_flag,ishootThreshold)
end
if ball.posX() > ishootThreshold then
if (ishoot_falg == kick.chip()) then
ipower = 130
ipower = 7000
end
else
if (ishoot_falg == kick.chip()) then
ipower = 110
ipower = 7000
end
end
return ipower
Expand Down Expand Up @@ -98,10 +98,10 @@ firstState = "Init1",

["getball"] = {
switch = function()

shoot_flag = shootFlag("Assister")
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))

if player.myinfraredCount("Assister") > 15 then
if player.myinfraredCount("Assister") > 5 then
if shoot_flag == 2 then
return "shoot_dribbling"
else
Expand All @@ -115,6 +115,9 @@ firstState = "Init1",
["turnToPoint"] = {
switch = function()
shoot_flag = shootFlag("Assister")
if ball.posX() > shootThreshold then
return "shoot_point"
end
if(bufcnt(player.myinfraredCount("Assister") < 1,4)) then
return "getball"
end
Expand All @@ -133,14 +136,17 @@ firstState = "Init1",
},
["shoot_dribbling"] = {
switch = function()
if ball.posX() > shootThreshold then
return "shoot_point"
end
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))
shoot_flag = shootFlag("Assister")
debugEngine:gui_debug_msg(CGeoPoint(0,0),shoot_flag)
if(bufcnt(player.myinfraredCount("Assister") < 1,1)) then
if player.myinfraredCount("Assister") < 1 then
return "getball"
end
end,
Assister = task.ShootdotDribbling(param.shootError,function() return shoot_flag end ,function() return Power("Assister",function() return shoot_flag end ,shootThreshold) end),
Assister = task.ShootdotDribbling(param.shootError + 10,function() return shoot_flag end ,function() return Power("Assister",function() return shoot_flag end ,shootThreshold) end),
match = "{A}"
},

Expand Down
7 changes: 4 additions & 3 deletions Core/src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ GlobalTick Tick[PARAM::Tick::TickLength];
int now = PARAM::Tick::TickLength - 1;
int last = PARAM::Tick::TickLength - 2;
CGeoPoint lastMovePoint = CGeoPoint(inf, inf);
double playerInfraredCountBuffer = 100;// 红外判断缓冲值
double playerInfraredCountBuffer = 95; //场地 3 红外判断缓冲值
//double playerInfraredCountBuffer = 100; //场地 2 红外判断缓冲值
double playerBallRightsBuffer = 110;// 球权判断缓冲值
double pass_threshold = 0.1; //射门阈值
namespace Utils
Expand Down Expand Up @@ -102,8 +103,8 @@ namespace Utils

// 如果球的视野消失,但是有红外信息,认为球的位置在触发红外的机器人上
if(!pVision ->ball().Valid())
if(RobotSensor.InfraredOnCount(i)>5)
Tick[now].ball.pos = pVision->ourPlayer(i).Pos()+Polar2Vector(120,pVision->ourPlayer(i).Dir());
if(RobotSensor.InfraredOnCount(i)>5 && pVision->ourPlayer(i).Pos().dist(Tick[now].ball.pos) < 1000)
Tick[now].ball.pos = pVision->ourPlayer(i).Pos()+Polar2Vector(85,pVision->ourPlayer(i).Dir());
// 我方距离球最近的车号
double to_ball_dist = pVision->ourPlayer(i).Pos().dist(Tick[now].ball.pos);
if (our_min_dist > to_ball_dist)
Expand Down
3 changes: 1 addition & 2 deletions Core/tactics/play/TestCircleRun.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ end

local rotNewPos = function()


end


Expand All @@ -23,7 +22,7 @@ firstState = "ready1",
debugEngine:gui_debug_msg(CGeoPoint:new_local(0,0),player.rotVel("Assister"))
end,

Assister = task.TurnRun(CGeoPoint(300,0),5),
Assister = task.TurnRun(CGeoPoint(120,60),6),
match = "[A]"
},

Expand Down
2 changes: 1 addition & 1 deletion Core/tactics/skill/Getball.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Getball(task)
[1] = {100,1},
[2] = {0,1},
[3] = {0,1},
[4] = {0,1},
[4] = {500,1},
[5] = {0,1},
[6] = {200,1.2},
[7] = {0,1},
Expand Down
Loading

0 comments on commit 211d32c

Please sign in to comment.