Skip to content

Commit

Permalink
NORMALPLAY add touch
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed May 14, 2024
1 parent c36fbb7 commit 9336b34
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 38 deletions.
26 changes: 11 additions & 15 deletions Core/HuRocos-2024/play/NORMALPLAY.lua
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,17 @@ firstState = "Init",
switch = function()
UpdataTickMessage(our_goalie_num,defend_num1,defend_num2) -- 更新帧信息
local State = getState()
if param.shootPos:x() == param.pitchLength / 2 then
shoot_kp = 10000
else
shoot_kp = param.shootKp
end

return State
if(GlobalMessage.Tick().ball.rights == -1 or not player.canTouch(player.pos("Assister"),shoot_pos,param.canTouchAngle)) then
return State
end
end,
Assister = task.touchKick(function() return shoot_pos end, false, function() return shoot_kp end, kick.flat),
Kicker = task.goCmuRush(function() return KickerRUNPos end,closures_dir_ball("Kicker"),_,DSS_FLAG),
Special = task.goCmuRush(function() return SpecialRUNPos end,closures_dir_ball("Special"),_,DSS_FLAG),
Tier = gSubPlay.roleTask("Defender", "Tier"),
Defender = gSubPlay.roleTask("Defender", "Defender"),
Goalie = gSubPlay.roleTask("Goalie", "Goalie"),
match = "{AKSTDG}"
match = "[AKS]{TDG}"
},
-- 接球
["Getball"] = {
Expand All @@ -313,13 +309,13 @@ firstState = "Init",
if State ~= "Getball" then
return State
end
-- local AssisterPos = CGeoPoint(player.posX("Assister"),player.posY("Assister"))
-- local ballLine = CGeoSegment(ball.pos(),ball.pos() + Utils.Polar2Vector(9999,ball.velDir()))
-- local playerPrjPos = ballLine:projection(player.pos("Assister"))
-- local onBallLine = ballLine:IsPointOnLineOnSegment(playerPrjPos)
-- if Utils.isValidPass(vision,AssisterPos,shoot_pos,param.enemy_buffer) and player.canTouch(AssisterPos,shoot_pos,param.canTouchAngle) and Utils.isValidPass(vision,AssisterPos,CGeoPoint(ball.posX(),ball.posY()),param.enemy_buffer) and ball.velMod() > 500 and onBallLine then
-- return "Touch"
-- end
local AssisterPos = CGeoPoint(player.posX("Assister"),player.posY("Assister"))
local ballLine = CGeoSegment(ball.pos(),ball.pos() + Utils.Polar2Vector(9999,ball.velDir()))
local playerPrjPos = ballLine:projection(player.pos("Assister"))
local onBallLine = ballLine:IsPointOnLineOnSegment(playerPrjPos)
if Utils.isValidPass(vision,AssisterPos,shoot_pos,param.enemy_buffer) and player.canTouch(AssisterPos,shoot_pos,param.canTouchAngle) and Utils.isValidPass(vision,AssisterPos,CGeoPoint(ball.posX(),ball.posY()),param.enemy_buffer)then
return "Touch"
end
end,
Assister = task.getball(function() return shoot_pos end,playerVel,getballMode),
Kicker = task.goCmuRush(function() return KickerRUNPos end,closures_dir_ball("Kicker"),_,DSS_FLAG),
Expand Down
20 changes: 10 additions & 10 deletions Core/tactics/skill/Getball.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function Getball(task)
local qflag = inter_flag or 0
local playerPos = CGeoPoint:new_local(player.pos(runner):x(),player.pos(runner):y())
local inter_pos = Utils.GetBestInterPos(vision,playerPos,param.playerVel,minter_flag,0,param.V_DECAY_RATE,param.distRate)
debugEngine:gui_debug_msg(CGeoPoint(0,0),minter_flag)
local ballLine = CGeoSegment(ball.pos(),ball.pos() + Utils.Polar2Vector(-param.INF,ball.velDir()))
local playerPrj = ballLine:projection(player.pos(runner))
local canGetBall = ballLine:IsPointOnLineOnSegment(playerPrj)
local toballdist = player.toBallDist(runner)
-- debugEngine:gui_debug_msg(CGeoPoint(0,0),minter_flag)
-- local ballLine = CGeoSegment(ball.pos(),ball.pos() + Utils.Polar2Vector(-param.INF,ball.velDir()))
-- local playerPrj = ballLine:projection(player.pos(runner))
-- local canGetBall = ballLine:IsPointOnLineOnSegment(playerPrj)
-- local toballdist = player.toBallDist(runner)

-- -- 敌方球权的情况
-- if GlobalMessage.Tick().ball.rights == -1 or GlobalMessage.Tick().ball.rights == 2 then
Expand Down Expand Up @@ -145,11 +145,11 @@ function Getball(task)
debugError = debugError .. " INF "
end
-- 解决敌人过近的问题
if GlobalMessage.Tick().ball.rights == -1 or GlobalMessage.Tick().ball.rights == 2 then
-- if GlobalMessage.Tick().ball.rights == -1 or GlobalMessage.Tick().ball.rights == 2 then
local minEnemyDistNum = {}
for i = 0 ,param.maxPlayer -1 do
if enemy.valid(i) then
if enemy.pos(i):dist(ball.pos()) < 300 then
if enemy.pos(i):dist(ball.pos()) < 200 then
table.insert(minEnemyDistNum,i)
end
end
Expand All @@ -158,12 +158,12 @@ function Getball(task)
local toballDir = (ball.pos() - enemy.pos(GlobalMessage.Tick().their.dribbling_num)):dir()
local playerDir = player.dir(runner)
local Subdir =Utils.angleDiff(toballDir,playerDir) * 180/math.pi
local dist_ = param.playerFrontToCenter + 150
local dist_ = param.playerFrontToCenter + 100
local theirDribblingPlayerPos = enemy.pos(GlobalMessage.Tick().their.dribbling_num)
inter_pos = ball.pos() + Utils.Polar2Vector(dist_,(player.pos(runner) - theirDribblingPlayerPos):dir())
inter_pos = ball.pos() + Utils.Polar2Vector(dist_,(ball.pos() - theirDribblingPlayerPos):dir())
debugError = debugError .. Subdir .."Enemy "
end
end
-- end
endVel = Utils.Polar2Vector(endVelMod,idir)

param.lastInterPos = inter_pos
Expand Down
6 changes: 3 additions & 3 deletions Core/tactics/skill/Touch.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function Touch(task)
local mpos
local useInter = task.useInter or false
matchPos = function()
return ball.pos()
matchPos = function(runner)
local inter_pos = Utils.GetBestInterPos(vision,player.pos(runner),param.playerVel,param.getballMode,0,param.V_DECAY_RATE,param.distRate)
return _c(inter_pos)
end

execute = function(runner)
mpos = _c(task.pos,runner)
task_param = TaskT:new_local()
Expand Down
3 changes: 1 addition & 2 deletions ZBin/lua_scripts/RoleMatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ gRolePos = {

}

gRolePriority = { "Goalie","Defender","Tier"}

gRolePriority = { "Goalie","Defender","Tier","Leader"}

gOurExistNum = {} --为了使车号统一从0开始,强行给gOurExistNum[0]赋值,但table自身接口全都无法使用了

Expand Down
4 changes: 2 additions & 2 deletions ZBin/lua_scripts/worldmodel/param.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ ourButtomGoalPos = CGeoPoint:new_local(-pitchLength / 2, -goalRadius)


-- 是否为真实场地
isReality = true
isReality = false
Team = "ONE"
-- Team = "TWO"
-----------------------------------------------|
-- Getball参数 --|
-----------------------------------------------|
playerVel = 2.5 -- 机器人速度
playerVel = 1.5 -- 机器人速度
getballMode = 1 -- [0[激进模式], 1[保守模式], 2[middle]]
-- local V_DECAY_RATE_Reality = 700 -- 场地摩擦
local V_DECAY_RATE_Reality = 800 -- 场地摩擦
Expand Down
3 changes: 2 additions & 1 deletion ZBin/lua_scripts/worldmodel/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ end


function pos(role)
return instance(role):Pos()
local p = instance(role):Pos()
return CGeoPoint(p:x(),p:y())
end

function posX(role)
Expand Down
12 changes: 7 additions & 5 deletions ZBin/lua_scripts/worldmodel/task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ end
function getball(shootPos_,playerVel, inter_flag, permissions)
return function()
-- 解决敌人过近的问题
if GlobalMessage.Tick().ball.rights == -1 or GlobalMessage.Tick().ball.rights == 2 then
-- if GlobalMessage.Tick().ball.rights == -1 or GlobalMessage.Tick().ball.rights == 2 then
local minEnemyDistNum1 = {}
for i = 0 ,param.maxPlayer -1 do
if enemy.valid(i) then
if enemy.pos(i):dist(ball.pos()) < 300 then
if enemy.pos(i):dist(ball.pos()) < 200 then
table.insert(minEnemyDistNum1,i)
end
if #minEnemyDistNum1 == 2 then
Expand All @@ -167,14 +167,16 @@ function getball(shootPos_,playerVel, inter_flag, permissions)
local Subdir = Utils.angleDiff(toballDir,playerDir) * 180/math.pi
local dist_ = param.playerFrontToCenter - 10
local theirDribblingPlayerPos = enemy.pos(GlobalMessage.Tick().their.dribbling_num)

if math.abs(Subdir) > 165 then
local inter_pos = ball.pos() + Utils.Polar2Vector(dist_,(ball.pos() - theirDribblingPlayerPos):dir())
local idir = 0
local inter_pos = ball.pos() + Utils.Polar2Vector(dist_,(theirDribblingPlayerPos - ball.pos()):dir())
local idir = (theirDribblingPlayerPos - ball.pos()):dir()
local iflag = flag.dribbling
local mexe, mpos = SimpleGoto { pos = inter_pos, dir = idir, flag = iflag }
return { mexe, mpos }
end
end
end
-- end



Expand Down

0 comments on commit 9336b34

Please sign in to comment.