Skip to content

Commit

Permalink
update TC2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-tz committed May 17, 2024
1 parent 870b9d6 commit 81601c6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Core/tactics/play/Autoref/ZJRoboCon2024TC.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ local checkEnemyRobotInCircle = function(num, circleNum)
if not enemy.valid(num) then
return false
end
return checkInCircle(enemy.rawPos(num), circleNum, PLAYER_RADIUS)
return checkInCircle(enemy.rawPos(num), circleNum, 0)
end

local WAIT_START = true
Expand Down
6 changes: 3 additions & 3 deletions Core/tactics/play/TC/TC2024DefenseA.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local ORIGIN = CGeoPoint:new_local(0,0)
local RUN_DIST = 1200
local RUN_DIST = 1150
local RUN_POS = {
ORIGIN + Utils.Polar2Vector(RUN_DIST, 0*math.pi*2/3),
ORIGIN + Utils.Polar2Vector(RUN_DIST, 1*math.pi*2/3),
ORIGIN + Utils.Polar2Vector(RUN_DIST, 2*math.pi*2/3),
ORIGIN + Utils.Polar2Vector(RUN_DIST, 1*math.pi*2/3),
}
return {
firstState = "reset",
Expand All @@ -26,7 +26,7 @@ firstState = "reset",
switch = function()
return gSubPlay.getState("TC") == "run" and "run" or "wait"
end,
a = task.runMultiPos(RUN_POS,true,30,0),
a = task.runMultiPos(RUN_POS,true,60,0),
match = "(a)"
},
name = "TC2024DefenseA",
Expand Down
47 changes: 38 additions & 9 deletions Core/tactics/play/TC/TC2024DefenseB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ local checkFarthest = function(pos)
end

local update = function()
local ball = ball.rawPos()
area, minDist = checkClosest(ball)
farArea, farDist = checkFarthest(ball)
local b = ball.rawPos()
area, minDist = checkClosest(b)
farArea, farDist = checkFarthest(b)
debugEngine:gui_debug_msg(CGeoPoint(0,0),"".. ball.velMod())
end

local dynPos = function()
Expand All @@ -54,28 +55,55 @@ local dynDir = function()
return (ORIGIN - WAIT_POS[area]):dir() + math.pi/2
end

local CHECK_POS = {
ORIGIN + Utils.Polar2Vector(RUN_DIST, 0*math.pi*2/3),
ORIGIN + Utils.Polar2Vector(RUN_DIST, 1*math.pi*2/3),
ORIGIN + Utils.Polar2Vector(RUN_DIST, 2*math.pi*2/3),
}

local RUSH_TASK = function()
local POS = player.rawPos("a")
local DIR = player.dir("a")
local ballVel = ball.vel()
local ball = ball.pos()
local targetPos = ball
local minTimePos = ball
local minTime = 99999
for dist = 0, 1000, 50 do
for dist = 50, 500, 50 do
local targetPos = ball + Utils.Polar2Vector(dist, ballVel:dir())
local t1 = world:predictRunTime(player.instance("a"), targetPos, CVector(0,0))
local t2 = ballModel:timeForDist(dist)
if t1 < t2 then
debugEngine:gui_debug_msg(CGeoPoint(100,100),"11111111")
return task.goCmuRush(targetPos,DIR)
end
for i=1,3 do
if (targetPos - WAIT_POS[i]):mod() < CIRCLE_RADIUS then
break
end
end
if t1 < minTime then
minTime = t1
minTimePos = targetPos
end
end
local ref = -1
local ref_dist = 99999
for i=1,3 do
if (CHECK_POS[i]-ball):mod() < ref_dist then
ref_dist = (CHECK_POS[i]-ball):mod()
ref = i
end
end
local interLine = CGeoLine(CHECK_POS[ref],CGeoPoint(0,0))


-- local runPos = minTimePos
local runPos = CGeoLine(ball, minTimePos):projection(player.pos("a"))
local ballLine = CGeoLine(ball, minTimePos)
local runPos = CGeoLineLineIntersection(interLine,ballLine):IntersectPoint()
-- local runPos = ballLine:projection(player.pos("a"))
local runDir = (runPos - player.pos("a")):dir()
debugEngine:gui_debug_msg(CGeoPoint(100,100),"2222222")
return task.goCmuRush(runPos,DIR,_,_,Utils.Polar2Vector(2000,runDir))
end

Expand All @@ -100,10 +128,10 @@ firstState = "reset",
["run"] = {
switch = function()
update()
if not gSubPlay.getState("TC") == "run" then
if gSubPlay.getState("TC") ~= "run" then
return "wait"
end
if minDist > CIRCLE_RADIUS then
if ball.velMod() > 800 then
return "rush"
end
end,
Expand All @@ -114,10 +142,11 @@ firstState = "reset",
['rush'] = {
switch = function()
update()
if not gSubPlay.getState("TC") == "run" then
debugEngine:gui_debug_msg(CGeoPoint(0,0),"!!!!!!!!" .. gSubPlay.getState("TC"))
if gSubPlay.getState("TC") ~= "run" then
return "wait"
end
if minDist < CIRCLE_RADIUS then
if minDist < CIRCLE_RADIUS and ball.velMod() < 800 then
return "run"
end
end,
Expand Down

0 comments on commit 81601c6

Please sign in to comment.