Skip to content

Commit

Permalink
删除不常用脚本,基本完成了定位球(还需要处理个别特殊情况:比如无法传球,少人等)
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed May 3, 2024
1 parent 832695d commit a3cae20
Show file tree
Hide file tree
Showing 19 changed files with 660 additions and 685 deletions.
16 changes: 14 additions & 2 deletions Core/HuRocos-2024/PlayConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@ gRefConfig = {
GameStop = "STOP",
OurTimeout = "HALT",
TheirIndirectKick = "NORMALPLAY",
OurIndirectKick = "our_IndirectKick",
OurIndirectKick = function()
if ball.posX() > 3000 then
return "our_CornerKick"
elseif ball.posX() > 0 and ball.posX() < 3000 then
return "our_CenterKick"
else
return "our_FrontKick"
end
end,




TheirKickOff = "their_KickOff",
OurKickOff = "our_KickOff",
TheirBallPlacement = "their_BallPlacement",
TheirBallPlacement = "theirballPlacement",
OurBallPlacement = "our_BallPlacement",
TheirPenaltyKick = "STOP",
OurPenaltyKick = "STOP",
Expand Down
2 changes: 1 addition & 1 deletion Core/HuRocos-2024/play/STOP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ firstState = "start",
Tier = task.goCmuRush(defendpos[3],dir.playerToBall,DSS_FLAG),
Defender = task.goCmuRush(defendpos[2],dir.playerToBall,DSS_FLAG),
Goalie = task.goCmuRush(defendpos[1],dir.playerToBall),
match = "(AKS){TDG}"
match = "[AKS]{TDG}"
},

name = "STOP",
Expand Down
46 changes: 24 additions & 22 deletions Core/HuRocos-2024/play/our_BallPlacement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ local defendpos = {
CGeoPoint(-3300,-850),

}

local ballPlacementPos = function()
return function()
return ball.placementPos()
end
end

local inBallPlacementPos = function(role)
local ballPlacementLine = CGeoSegment(ball.pos(),ball.placementPos())
local playerPrj = ballPlacementLine:projection(player.pos(role))
Expand All @@ -22,7 +20,6 @@ local inBallPlacementPos = function(role)
return false
end
end

local avoidPlacementPos = function(role,WitePos)
return function()
local iWitePos = WitePos or player.pos(role)
Expand All @@ -46,13 +43,15 @@ local avoidPlacementPos = function(role,WitePos)
end
end
end


local waitPosKicker = function()
return function()
local startPos
local endPos
local KickerShootPos = Utils.PosGetShootPoint(vision, player.posX("Kicker"),player.posY("Kicker"))
-- 角球
if ball.placementPos():x() > 1000 then
if ball.placementPos():x() > 3000 then
if ball.posY() > 0 then
startPos = CGeoPoint(2600,-1250)
endPos = CGeoPoint(3000,-850)
Expand All @@ -61,13 +60,18 @@ local waitPosKicker = function()
endPos = CGeoPoint(3000,850)
end
-- 中场球
elseif ball.placementPos():x() < 1000 and ball.placementPos():x() > -1000 then
startPos = CGeoPoint(1200,2500)
endPos = CGeoPoint(2600,470)
elseif ball.placementPos():x() < 3000 and ball.placementPos():x() > 0 then
if ball.posY() < 0 then
startPos = CGeoPoint(4050,1500)
endPos = CGeoPoint(4400,800)
else
startPos = CGeoPoint(4050,-1500)
endPos = CGeoPoint(4400,-800)
end
else
-- 前场球
startPos = CGeoPoint(-3000,2100)
endPos = CGeoPoint(-1000,500)
startPos = CGeoPoint(ball.placementPos():x()+3000,1000)
endPos = CGeoPoint(ball.placementPos():x()+4000,-1000)
end
local attackPos = Utils.GetAttackPos(vision, player.num("Kicker"),KickerShootPos,startPos,endPos,130,500)
if attackPos:x() == 0 and attackPos:y() == 0 then
Expand All @@ -81,42 +85,41 @@ local waitPosKicker = function()
attackPos = player.pos("Kicker")
end
end
param.KickerWaitPlacementPos = attackPos
return attackPos
end
end


local waitPosSpecial = function()
return function()
local startPos
local endPos
local SpecialShootPos = Utils.PosGetShootPoint(vision, player.posX("Special"),player.posY("Special"))
if ball.placementPos():x() > 1000 then
if ball.placementPos():x() > 3000 then
if ball.posY() < 0 then
startPos = CGeoPoint(2400,-1100)
endPos = CGeoPoint(2900,-700)
else
startPos = CGeoPoint(2400,1100)
endPos = CGeoPoint(2900,700)
end
elseif ball.placementPos():x() < 1000 and ball.placementPos():x() > -1000 then
startPos = CGeoPoint(800,-2500)
endPos = CGeoPoint(2400,-400)
elseif ball.placementPos():x() < 3000 and ball.placementPos():x() > 0 then
if ball.posY() < 0 then
startPos = CGeoPoint(3000,-750)
endPos = CGeoPoint(3500,-1300)
else
startPos = CGeoPoint(3000,750)
endPos = CGeoPoint(3500,1300)
end
else
startPos = CGeoPoint(-1500,0)
endPos = CGeoPoint(0,-1700)
startPos = CGeoPoint(ball.placementPos():x()+1000,0)
endPos = CGeoPoint(ball.placementPos():x()+2500,-1700)
end
local attackPos = Utils.GetAttackPos(vision, player.num("Special"),SpecialShootPos,startPos,endPos,130,500)
if attackPos:x() == 0 and attackPos:y() == 0 then
attackPos = player.pos("Special")
end
param.SpecialWaitPlacementPos = attackPos
return attackPos
end
end
-- local DSS_FLAG = bit:_or(flag.allow_dss, flag.dodge_ball)

local AssisterDir = function()
if player.valid(player.num("Kicker")) then
return (player.pos("Kicker") - player.pos("Assister")):dir()
Expand All @@ -131,7 +134,6 @@ firstState = "start",
["start"] = {
switch = function()
debugEngine:gui_debug_arc(ball.pos(),500,0,360,1)

return "getball"
end,
Assister = task.stop(),
Expand Down
188 changes: 188 additions & 0 deletions Core/HuRocos-2024/play/our_CenterKick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
local DSS_FLAG = flag.allow_dss + flag.dodge_ball + flag.our_ball_placement
local pass_pos = CGeoPoint(4300,1100)
local shootPosKicker__ = CGeoPoint(0,0)
local shootPosSpecial__ = CGeoPoint(0,0)
local PassPos = function()
local KickerShootPos = Utils.PosGetShootPoint(vision, player.posX("Kicker"),player.posY("Kicker"))
if ball.posY() < 0 then
startPos = CGeoPoint(4050,1500)
endPos = CGeoPoint(4400,800)
else
startPos = CGeoPoint(4050,-1500)
endPos = CGeoPoint(4400,-800)
end
local res = Utils.GetAttackPos(vision, player.num("Kicker"),KickerShootPos,startPos,endPos,100,500)
return CGeoPoint(res:x(),res:y())
end
local toBallDir = function(role)
return function()
return player.toBallDir(role)
end
end
gPlayTable.CreatePlay {
firstState = "start",
["start"] = {
switch = function()
debugEngine:gui_debug_arc(ball.pos(),500,0,360,1)
return "ready"
end,
Assister = task.goCmuRush(function() return ball.pos() end),
Special = task.stop(),
Kicker = task.stop(),
Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "(AK)(S){TDG}"
},



["ready"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
pass_pos = CGeoPoint (param.SpecialWaitPlacementPos():x(),param.SpecialWaitPlacementPos():y())
-- 如果有挑球,无脑传bugpass
if Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),pass_pos,param.enemy_buffer) then
return "BugPass"
elseif Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),pass_pos,param.enemy_buffer) then

end
end,
Assister = task.stop(),
Kicker = task.goCmuRush(function() return param.KickerWaitPlacementPos() end,toBallDir("Kicker")),
Special = task.goCmuRush(function() return param.SpecialWaitPlacementPos() end,toBallDir("Special")),
Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "(AKS){TDG}"
},




["BugPass"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
pass_pos = CGeoPoint (param.KickerWaitPlacementPos():x(),param.KickerWaitPlacementPos():y())

if player.num("Special") ~= -1 and player.num("Special") ~= nil then
shootPosKicker__ = player.pos("Special")
shootPosSpecial__ = Utils.PosGetShootPoint(vision, player.pos("Special"):x(),player.pos("Special"):y())
else
shootPosKicker__ = Utils.PosGetShootPoint(vision, pass_pos:x(),pass_pos:y())
end

debugEngine:gui_debug_x(shootPosKicker__,3)
debugEngine:gui_debug_msg(CGeoPoint(0,0),GlobalMessage.Tick.ball.rights)
if(GlobalMessage.Tick.ball.rights == -1) then
return "exit"
end
debugEngine:gui_debug_msg(CGeoPoint(-1000,-1000),player.num("Special"),4)
if(player.kickBall("Assister"))then
if player.num("Special") == -1 or player.num("Special") == nil then
return "exit"
end
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"
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.shootKp+1,15,kick.flat),
Kicker = task.goCmuRush(function() return param.KickerWaitPlacementPos() end,function() return (player.pos("Special") - player.pos("Kicker") ):dir() end),
Special = task.goCmuRush(function() return param.SpecialWaitPlacementPos() end,function() return (shootPosSpecial__ - player.pos("Special")):dir() end),
Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "(AKS){TDG}"
},


["KickerTouch"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
if(GlobalMessage.Tick.ball.rights == -1) then
return "exit"
end
debugEngine:gui_debug_msg(CGeoPoint(-1000,-1000),tostring(player.canTouch(ball.pos(), shootPosSpecial__, param.canTouchAngle)))
if (player.kickBall("Kicker")) then
return "SpecialTouch"
-- if(player.canTouch(ball.pos(), shootPosSpecial__, param.canTouchAngle) and
-- Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),shootPosSpecial__,param.enemy_buffer)) then
-- return "SpecialTouch"

-- elseif Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),shootPosSpecial__,param.enemy_buffer) then
-- -- return "SpecialGetball"
-- else
-- return "exit"
-- end
end
debugEngine:gui_debug_x(shootPosKicker__,3)
end,
Assister = task.stop(),
Kicker = task.touchKick(function() return CGeoPoint(player.posX("Special"),player.posY("Special")) end, false, param.shootKp, kick.flat),
Special = task.goCmuRush(function() return CGeoPoint(player.posX("Special"),player.posY("Special")) end,function() return (shootPosSpecial__ - player.pos("Special")):dir() end,_,DSS_FLAG),

Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "{ASKTDG}"
},

["KickerGetball"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
if(GlobalMessage.Tick.ball.rights == -1 or player.toBallDist("Kicker") < 500) then
return "exit"
end
end,
Assister = task.stop(),
Special =task.getball(function() return pass_pos end,param.playerVel,param.getballMode),
Kicker = task.goCmuRush(function() return param.KickerWaitPlacementPos() end,toBallDir("Kicker")),
Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "{ASKTDG}"
},


["SpecialTouch"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
if(GlobalMessage.Tick.ball.rights == -1) then
return "exit"
end
if (player.kickBall("Kicker")) then
if(player.canTouch(ball.pos(), shootPosSpecial__, param.canTouchAngle) and
Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),shootPosSpecial__,param.enemy_buffer)) then
return "SpecialTouch"
elseif Utils.isValidPass(vision,CGeoPoint(ball.posX(),ball.posY()),shootPosSpecial__,param.enemy_buffer) then
-- return "SpecialGetball"
else
return "exit"
end
end
debugEngine:gui_debug_x(shootPosKicker__,3)
end,
Assister = task.stop(),
Kicker = task.stop(),
Special = task.touchKick(function() return shootPosSpecial__ end, false, 999, kick.flat),

Tier = task.stop(),
Defender = task.stop(),
Goalie = task.stop(),
match = "{ASKTDG}"
},

name = "our_CenterKick",
applicable = {
exp = "a",
a = true
},
attribute = "attack",
timeout = 99999
}
Loading

0 comments on commit a3cae20

Please sign in to comment.