Skip to content

Commit

Permalink
STAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbrella167 committed May 4, 2024
1 parent a3cae20 commit 0557bb8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 110 deletions.
2 changes: 2 additions & 0 deletions Core/HuRocos-2024/play/our_BallPlacement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ firstState = "start",
["getball"] = {
switch = function()
GlobalMessage.Tick = Utils.UpdataTickMessage(vision,param.our_goalie_num,param.defend_num1,param.defend_num2)
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()) < 200 then
return "avoid"
end
Expand Down
111 changes: 7 additions & 104 deletions Core/tactics/play/TestballRightAndInfraed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local KP = 0.00000002
local defendPos = function(role)
return function()
local posdefend = enemy.pos(role) + Utils.Polar2Vector(300,(ball.pos() - enemy.pos(role)):dir())
return CGeoPoint:new_local( posdefend:x(),posdefend:y() )
return CGeoPoint:new_local(posdefend:x(),posdefend:y() )
end
end
local run_pos = CGeoPoint:new_local(0,0)
Expand All @@ -31,118 +31,21 @@ firstState = "ready1",

["ready1"] = {
switch = function()
debugEngine:gui_debug_msg(CGeoPoint(1000, 1000), player.dir("Goalie"))

GlobalMessage.Tick = Utils.UpdataTickMessage(vision,0,1,2)
-- debugEngine:gui_debug_msg(CGeoPoint(0,0),task.angleDiff((ball.pos() - player.pos("Assister")):dir(),(player.pos("Assister") - CGeoPoint(0,0)):dir()))
-- if(player.infraredCount("Assister") > 5) then
-- return "shoot"
-- end

debugEngine:gui_debug_msg(CGeoPoint(0,2800),"ballRights: " .. GlobalMessage.Tick.ball.rights)
debugEngine:gui_debug_msg(CGeoPoint(0,2600),"InfraredCount: " .. player.myinfraredCount(0),2)
debugEngine:gui_debug_msg(CGeoPoint(0,2400),"RawBallPos: " .. ball.rawPos():x() .. " " .. ball.rawPos():y() ,3)
debugEngine:gui_debug_msg(CGeoPoint(0,2200),"BallPos: " .. ball.pos():x() .. " " .. ball.pos():y() ,4)
end,

Assister = task.goCmuRush(CGeoPoint(3671,1148)),
-- Assister = task.getballV2("Assister", param.playerVel, 1, CGeoPoint(0, 0), 0),
-- Kicker = task.getball("Assister",param.playerVel,param.getballMode,CGeoPoint:new_local(0,0)),
-- Kicker = function() return task.defender_marking("Kicker",CGeoPoint(0,0)) end,
Assister = task.stop(),
match = "[A]"
},



["shoot"] = {
switch = function()
if(not bufcnt(player.infraredOn("Assister"),1)) then
return "ready1"
end
local Vy = player.rotVel("Assister")
local ToTargetDist = player.toPointDist("Assister",shoot_pos)
resPos = task.compensateAngle(Vy,shoot_pos,ToTargetDist * 0.07)

if(task.playerDirToPointDirSub("Assister",resPos) < 4) then
return "shoot1"
end


end,
-- = task.TurnRun("Assister"),
Assister = function() return (task.TurnToPointV2("Assister",function() return resPos end ,param.rotVel)) end,
-- match = "[AKS]{TDG}"
match = "[A]"
},


["shoot1"] = {
switch = function()
if(not bufcnt(player.infraredOn("Assister"),1)) then
return "ready1"
end
end,
-- = task.TurnRun("Assister"),
Assister = task.ShootdotV2(function() return resPos end,10,8,kick.flat),
-- match = "[AKS]{TDG}"
match = "[A]"
},
["dribbling"] = {
switch = function()
Utils.UpdataTickMessage(vision,1,2)
run_pos = Utils.GetShowDribblingPos(vision,CGeoPoint:new_local(player.pos("Assister"):x(),player.pos("Assister"):y()),CGeoPoint(0,0))

if(bufcnt(true,35)) then
return "ready"
end
end,
Assister = task.goCmuRush(runPos(),balldir(),800,flag.dribbling),

match = "[AKS]{TDG}"
},


-- ["touch"] = {
-- switch = function()
-- -- Utils.UpdataTickMessage(vision,1,2)
-- -- Utils.GlobalComputingPos(vision)

-- end,
-- Assister = task.touchKick("Assister",CGeoPoint(4500,0)),

-- match = "[AKS]{TDG}"
-- },

-- ["readyShoot"] = {
-- switch = function()
-- Utils.GetTouchPos(vision,CGeoPoint:new_local(ball.posX(),ball.posY()))
-- -- local pos1 = Utils.GetBestInterPos(vision,playerPos(),4,2)
-- -- debugEngine:gui_debug_x(pos1,3)
-- -- debugEngine:gui_debug_msg(CGeoPoint:new_local(0,0),pos1:x() .. " " .. pos1:y())
-- -- Utils.UpdataTickMessage(vision,1,2)
-- -- Utils.GlobalComputingPos(vision)
-- -- aa = player.canTouch("Assister",CGeoPoint:new_local(4500,0))
-- -- debugEngine:gui_debug_msg(CGeoPoint:new_local(0,0),tostring(aa))
-- -- if(player.infraredCount("Assister") > 30) then
-- -- return "Shoot"
-- -- end
-- end,
-- Assister = task.goCmuRush(defendPOs(4)),--task.touchKick(_,_,500,kick.flat);--task.getball("Assister",6,2),--task.GetBallV2("Assister",CGeoPoint(4500,0)),
-- Kicker = task.goCmuRush(defendPOs(5)),

-- match = "(AK)"
-- },
-- ["Shoot"] = {
-- switch = function()
-- -- Utils.UpdataTickMessage(vision,1,2)
-- -- Utils.GlobalComputingPos(vision)
-- if(player.kickBall("Assister")) then
-- return "readyShoot"
-- end
-- end,
-- Assister = task.ShootdotV2(CGeoPoint(4500,0),KP,error_dir,kick.flat),

-- match = "[AKS]{TDG}"
-- },


name = "testSkill",
name = "TestballRightAndInfraed",
applicable ={
exp = "a",
a = true
Expand Down
11 changes: 10 additions & 1 deletion ZBin/lua_scripts/worldmodel/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,16 @@ end
function myinfraredCount(role)
local robotNum = num(role)
if robotNum ~= -1 then
return GlobalMessage.Tick.task[robotNum].infrared_count
local OfficalInfraredCount = world:InfraredOnCount(robotNum)
local MyInfraredCount = GlobalMessage.Tick.task[robotNum].infrared_count
if OfficalInfraredCount ~= 0 then
if OfficalInfraredCount > MyInfraredCount then
return OfficalInfraredCount
else
return MyInfraredCount
end
end
return MyInfraredCount
else
return 0
end
Expand Down
5 changes: 1 addition & 4 deletions ZBin/lua_scripts/worldmodel/task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module(..., package.seeall)

--- /// /// --- /// /// --- /// /// --- /// /// --- /// /// ---



function getBall_BallPlacement(role)
return function()
local ballPos = GlobalMessage.Tick.ball.pos
Expand Down Expand Up @@ -36,12 +34,11 @@ function getBall_BallPlacement(role)
end
else
-- debugEngine:gui_debug_msg(CGeoPoint(100,1000),player.myinfraredCount(role))

if player.myinfraredCount(role) < 20 then

local toballDir = math.abs((ball.rawPos() - player.rawPos(role)):dir() * 57.3)
local playerDir = math.abs((player.pos(role) - ballPlacementPos):dir()) * 57.3
local Subdir = math.abs(toballDir-playerDir)

if bufcnt( Subdir < 18 and player.toBallDist(role) < 200,60) then
debugEngine:gui_debug_msg(CGeoPoint(0,0),"3")
placementflag = flag.our_ball_placement + flag.dribbling
Expand Down
3 changes: 2 additions & 1 deletion share/staticparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ namespace PARAM {
const int playerFrontToCenter = 76; // 机器人圆心到嘴的距离
const int playerRadiusr = 90; // 机器人半径
const int playerBuffer = 100; // 检测敌人是否在某直线上的缓冲值
const double playerBallRightsBuffer = 95; // 球权判断缓冲值
const double playerBallRightsBuffer = 102; // 球权判断缓冲值

const int playerTouchAngle = 60;
}
namespace Tick{
Expand Down

0 comments on commit 0557bb8

Please sign in to comment.