Skip to content

Commit

Permalink
penalty
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed May 16, 2024
1 parent b96951b commit 223e905
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 68 deletions.
6 changes: 4 additions & 2 deletions Core/HuRocos-2024/play/NORMALPLAY.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ end
local subScript = false

return {

__init__ = function(name, args)
print("in __init__ func : ",name, args)
end,
Expand All @@ -226,13 +225,16 @@ firstState = "Init",
gSubPlay.new("Goalie", "Nor_Goalie")
end
return "GetGlobalMessage"

-- UpdataTickMessage(our_goalie_num,defend_num1,defend_num2) -- 更新帧信息
-- local State = getState()
end,
Assister = task.stop(),
Kicker = task.stop(),
Special = task.stop(),
Tier = task.stop(),
Defender = task.stop(),
Goalie = gSubPlay.roleTask("Goalie", "Goalie"),
Goalie = task.stop(),
match = "[AKS]{TDG}"
},

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 @@ -204,13 +204,13 @@ local getState = function ()
end


param.dribblingExclusionDist = 120
param.dribblingExclusionDist = 130
if Utils.isValidPass(vision,ball.pos(),param.shootPos,130) then
param.dribblingExclusionDist = 0
else
param.dribblingExclusionDist = 120
end
if Utils.InExclusionZone(ball.pos(), param.dribblingExclusionDist, "all") and resultState ~= "ShootPoint" then
if Utils.InExclusionZone(ball.pos(), param.dribblingExclusionDist, "all") and resultState ~= "ShootPoint" then
resultState = "dribbling"
end
debugEngine:gui_debug_msg(CGeoPoint(0,param.pitchWidth / 2 - (1000 + param.debugSize)),"NextState:" .. resultState,3,0,param.debugSize)
Expand Down
2 changes: 1 addition & 1 deletion Core/HuRocos-2024/play/Nor_DefendV2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ return {
end,
Breaker = function() return task.defend_normV2("Tier", 0, param.defenderMode) end,
Fronter = function() return task.defend_normV2("Defender", 1, param.defenderMode) end,
match = "[BF]"
match = "{BF}"
},
["defend_front"] = {
switch = function()
Expand Down
8 changes: 4 additions & 4 deletions Core/HuRocos-2024/play/Nor_Shoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ firstState = "Init",
local toballDir = (param.shootPos - ball.pos()):dir()
local playerDir = player.dir("Assister")
local subDir = math.abs(Utils.angleDiff(toballDir,playerDir) * 180/math.pi)
local drbblingRate = math.ceil((7 * Utils.NumberNormalize(subDir,120,30)))
if(player.myinfraredCount("Assister") > 15 + drbblingRate) then
local drbblingRate = math.ceil((0 * Utils.NumberNormalize(subDir,120,30)))
if(player.myinfraredCount("Assister") > 5 + drbblingRate) then
return "turnToPoint"
end
local Vy = player.rotVel("Assister")
Expand Down Expand Up @@ -102,7 +102,7 @@ firstState = "Init",
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()) end,
match = "{A}"
},

Expand All @@ -118,7 +118,7 @@ firstState = "Init",
return "getball"
end
end,
Assister = task.ShootdotV2(function() return resShootPos end, param.shootError, kick.flat),
Assister = task.ShootdotV2(function() return resShootPos end, param.shootError, kick.flat ),
match = "{A}"
},

Expand Down
27 changes: 25 additions & 2 deletions Core/HuRocos-2024/play/our_BallPlacement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ firstState = "start",
count = 0
end
if count > 60 then
return "avoid"
count = 0
return "getball1"
end
end,
Assister = task.getBall_BallPlacement("Assister"),
Expand All @@ -168,7 +169,29 @@ firstState = "start",
Goalie = task.goCmuRush(avoidPlacementPos("Goalie"),function() return player.toBallDir("Goalie") end,_,DSS_FLAG),
match = "(AKS){TDG}"
},

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

debugEngine:gui_debug_msg(CGeoPoint(0,2800),"ballRights: " .. GlobalMessage.Tick().ball.rights,2)
debugEngine:gui_debug_msg(CGeoPoint(0,2600),"InfraredCount: " .. player.myinfraredCount("Assister"),3)
if ball.pos():dist(ball.placementPos()) < 130 then
count = count + 1
else
count = 0
end
if count > 100 then
count = 0
return "avoid"
end
end,
Assister = task.stop(),
Kicker = task.goCmuRush(avoidPlacementPos("Kicker",waitPosKicker()),function() return player.toBallDir("Kicker") end,_,DSS_FLAG),
Special = task.goCmuRush(avoidPlacementPos("Special",waitPosSpecial()),function() return player.toBallDir("Special") end,_,DSS_FLAG),
Tier = task.goCmuRush(avoidPlacementPos("Tier"),function() return player.toBallDir("Tier") end,_,DSS_FLAG),
Defender = task.goCmuRush(avoidPlacementPos("Defender"),function() return player.toBallDir("Defender") end,_,DSS_FLAG),
Goalie = task.goCmuRush(avoidPlacementPos("Goalie"),function() return player.toBallDir("Goalie") end,_,DSS_FLAG),
match = "(AKS){TDG}"
},
["avoid"] = {
switch = function()

Expand Down
4 changes: 2 additions & 2 deletions Core/HuRocos-2024/play/our_CornerKick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ firstState = "start",
if(player.kickBall("Assister") )then
if(player.canTouch(pass_pos, shootPosKicker__, param.canTouchAngle) and
Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),pass_pos,param.enemy_buffer)) then
return "KickerTouch"
return "exit"
elseif Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),pass_pos,param.enemy_buffer) then
return "KickerGetball"
else
return "exit"
end
end
end,
Assister = task.Shootdot("Assister",function() return pass_pos end,param.shootError + 5,kick.flat),
Assister = task.Shootdot("Assister",function() return pass_pos end,param.shootError + 5,kick.chip),
Kicker = task.goCmuRush(function() return param.KickerWaitPlacementPos() end,toBallDir("Kicker")),
Special = task.goCmuRush(function() return param.SpecialWaitPlacementPos() end,toBallDir("Special")),
Tier = task.stop(),
Expand Down
65 changes: 41 additions & 24 deletions Core/HuRocos-2024/play/our_Penalty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ 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 canShoot = function(role,shootThreshold)
if ball.posX() > shootThreshold then
local shootThreshold = 3000

local canShoot = function(role,ishootThreshold)
if ball.posX() > ishootThreshold then
return true
else
return false
Expand All @@ -24,52 +26,47 @@ local theirGoalie = function()
end
local shoot_flag = 1
local shootFlag = function(role)
if player.pos(role):dist(enemy.pos(theirGoalie())) < 500 then
if player.pos(role):dist(enemy.pos(theirGoalie())) < 800 then
return kick.chip()
else
return kick.flat()
end
end

local Power = function(role,shoot_flag,shootThreshold)
local Power = function(role,shoot_flag,ishootThreshold)
local ipower = 100
local ishoot_falg
if type(shoot_flag) == 'function' then
ishoot_falg = shoot_flag()
else
ishoot_falg = shoot_flag
end
local realRate = 15
if param.isReality then
realRate = 1
end
if ball.posX() > shootThreshold then
if ball.posX() > ishootThreshold then
if (ishoot_falg == kick.flat()) then
ipower = 310 * realRate
ipower = 310
else
ipower = 500 * realRate
ipower = 500
end
else
if (ishoot_falg == kick.flat()) then
ipower = 110 * realRate
ipower = 110
else
ipower = 300 * realRate
ipower = 300
end
end
end

local match_pos = function(role)
return function()
return
end
end
--射门阈值
local shootThreshold = 3000
gPlayTable.CreatePlay{
return {

__init__ = function(name, args)
print("in __init__ func : ",name, args)
end,
firstState = "Init1",

["Init1"] = {
switch = function()
gSubPlay.new("ShootPoint", "Nor_Shoot",{pos = function() return shoot_pos end})
return "Init"
end,
Assister = task.goCmuRush(function() return player.pos(param.LeaderNum) end, player.toBallDir("Assister"), a, DSS_FLAG),
Expand All @@ -82,9 +79,9 @@ firstState = "Init1",
},



["Init"] = {
switch = function()
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))
debugEngine:gui_debug_msg(CGeoPoint(0,0),ball.posX())
if cond.isNormalStart() then
return "getball"
Expand All @@ -101,17 +98,25 @@ firstState = "Init1",

["getball"] = {
switch = function()
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))

debugEngine:gui_debug_msg(CGeoPoint(0,0),ball.posX())
if player.myinfraredCount("Assister") > 15 and (not canShoot("Assister",shootThreshold)) then
return "shoot_dribbling"
if player.myinfraredCount("Assister") > 15 then
if canShoot("Assister",shootThreshold) then
return "shoot_point"
else
return "shoot_dribbling"
end
end
end,
Assister = task.getball(function() return shoot_pos end,playerVel,getballMode),
Assister = task.getball_dribbling("Assister"),
match = "{A}"
},

["shoot_dribbling"] = {
switch = function()
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))

shoot_flag = shootFlag("Assister")
if(bufcnt(player.myinfraredCount("Assister") < 1,1)) then
return "getball"
Expand All @@ -120,6 +125,18 @@ firstState = "Init1",
Assister = task.ShootdotDribbling(param.shootError,function() return shoot_flag end,Power("Assister",function() return shoot_flag end,shootThreshold)),
match = "{A}"
},

["shoot_point"] = {
switch = function()
param.shootPos = Utils.GetShootPoint(vision,player.num("Assister"))
shoot_flag = shootFlag("Assister")
if(bufcnt(player.myinfraredCount("Assister") < 1,1)) then
return "getball"
end
end,
Assister = gSubPlay.roleTask("ShootPoint", "Assister"),
match = "{A}"
},
name = "our_Penalty",
applicable ={
exp = "a",
Expand Down
10 changes: 5 additions & 5 deletions Core/src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ GlobalTick Tick[PARAM::Tick::TickLength];
int now = PARAM::Tick::TickLength - 1;
int last = PARAM::Tick::TickLength - 2;
CGeoPoint lastMovePoint = CGeoPoint(inf, inf);
double playerInfraredCountBuffer = 105;// 红外判断缓冲值
double playerInfraredCountBuffer = 100;// 红外判断缓冲值
double playerBallRightsBuffer = 110;// 球权判断缓冲值
double pass_threshold = 0.18; //射门阈值
double pass_threshold = 0.1; //射门阈值
namespace Utils
{
// 没写完 START
Expand Down Expand Up @@ -96,8 +96,8 @@ namespace Utils
{

Tick[now].task[i].player_num = i;
if (i != Tick[now].our.dribbling_num)
Tick[now].task[i].infrared_count = 0;
// if (i != Tick[now].our.dribbling_num)
// Tick[now].task[i].infrared_count = 0;
if (Tick[now].task[i].infrared_count == 0 )
Tick[now].task[i].infrared_off_count += 1;

Expand Down Expand Up @@ -214,7 +214,7 @@ namespace Utils

// 获取第一次带球的位置
// 如果远离球一定距离就一直更新
if (our_min_dist > playerBallRightsBuffer + 25)
if (our_min_dist > 150)
{
Tick[now].ball.first_dribbling_pos = Tick[now].ball.pos;
}
Expand Down
31 changes: 27 additions & 4 deletions Core/tactics/skill/Getball.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,38 @@ function Getball(task)
else
print("Error runner in getball", runner)
end
local playerEndVel = {

local playerEndVelONE = {
-- [num] = {endVel, ballVelRate}
[-1] = {0,1}, -- Other
[0] = {0,1},
[1] = {0,1},
[2] = {0,50},
[2] = {0,1},
[3] = {0,1},
[4] = {0,1},
[5] = {0,1},
[6] = {200,1},
[7] = {0,1},
[8] = {0,1},
[9] = {0,1},
[10] = {0,1},
[11] = {0,50},
[12] = {0,1},
[13] = {0,1},
[14] = {0,1},
[15] = {0,1},
[16] = {0,1}, -- Other
}
local playerEndVelTWO = {
-- [num] = {endVel, ballVelRate}
[-1] = {0,1}, -- Other
[0] = {0,1},
[1] = {100,1},
[2] = {0,1},
[3] = {0,1},
[4] = {0,1},
[5] = {0,1},
[6] = {0,1},
[6] = {200,1.2},
[7] = {0,1},
[8] = {0,1},
[9] = {0,1},
Expand All @@ -76,6 +98,7 @@ function Getball(task)
[15] = {0,1},
[16] = {0,1}, -- Other
}
local playerEndVel = (param.Team == "ONE") and playerEndVelONE or playerEndVelTWO
--获取常用数据
local endVelMod = 0
local playerPos = CGeoPoint:new_local(player.pos(runner):x(),player.pos(runner):y())
Expand Down Expand Up @@ -130,7 +153,7 @@ function Getball(task)
end
debugError = debugError .." RushToBall "
endVelMod = (ball.velMod() * playerEndVel[runner][2]) + playerEndVel[runner][1]
endVelMod = endVelMod > 300 and 300 or endVelMod
endVelMod = endVelMod > 5000 and 5000 or endVelMod
end


Expand Down
Loading

0 comments on commit 223e905

Please sign in to comment.