From 88a610a48efa8e5eba25e3bf6e231fc4d2a020b4 Mon Sep 17 00:00:00 2001 From: dinzhen12 <1770224907@qq.com> Date: Thu, 16 May 2024 18:06:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=A2=E4=BD=93=E8=A7=92=E7=90=83=E9=98=B2?= =?UTF-8?q?=E5=AE=88=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/HuRocos-2024/play/indirectDefend.lua | 174 +++++++++++++++++ Core/HuRocos-2024/play/indirectDefend_New.lua | 176 ++++++++++++++++++ 2 files changed, 350 insertions(+) create mode 100644 Core/HuRocos-2024/play/indirectDefend.lua create mode 100644 Core/HuRocos-2024/play/indirectDefend_New.lua diff --git a/Core/HuRocos-2024/play/indirectDefend.lua b/Core/HuRocos-2024/play/indirectDefend.lua new file mode 100644 index 0000000..3ea8a9f --- /dev/null +++ b/Core/HuRocos-2024/play/indirectDefend.lua @@ -0,0 +1,174 @@ +local balldir = function () + return function() + return player.toBallDir("Assister") + end +end +-- table.insert(jj,XX) +local depart =0 + +-- 0 = unlocked +-- 1 = locked +Locked_Enemy={ + --0 + --0 + +} + +function Tdebug() + for i = 0,#Locked_Enemy-1 do + debugEngine:gui_debug_msg(CGeoPoint(-2000, 2000-150*i), "i: "..i.." ".."EnemyState: "..Locked_Enemy[i]) + end +end +--获取球位置 +local ballpos = ball.pos() +KeepDis = 100 +--获取敌人车号 +local enemy_num =0 +local LockdefendNum = function(role) + + local KeepEnemyNum = enemy.closestBall() + local j =KeepEnemyNum + Locked_Enemy[j] = 1 + for i = 0,param.maxPlayer -1 do + if enemy.valid(i) and Locked_Enemy[i] ~= 1 then + enemy_num = i + Locked_Enemy[i] = 1 + break + end + end + + return enemy_num +end + +local EnemyPos =function (role) + -- local enemynum = LockdefendNum(role) + local enemynum = 0 + + + + local enemypos = enemy.pos(enemynum) + return enemypos +end + +local DenfendPosFront = function (role) + ballpos = ball.pos() + local denfendPosfront = EnemyPos(role) + Utils.Polar2Vector(KeepDis,(EnemyPos(role)- ballpos):dir() + math.pi / 3) + return denfendPosfront +end + +local DenfendPosCenter = function (role) + ballpos = ball.pos() + local denfendPoscenter = EnemyPos(role) + Utils.Polar2Vector(KeepDis,(EnemyPos(role)- ballpos):dir() + math.pi / 3) + return denfendPoscenter +end +------------------------------------------------------------------------------------------------- +return { + + __init__ = function(name, args) + print("in __init__ func : ",name, args) + end, + + +firstState = "Init", + +["Init"] = { + switch = function () + for i = 0,param.maxPlayer -1 do + if enemy.valid(i) then + Locked_Enemy[i] = -1 + else + Locked_Enemy[i] = -2 + end + end + + + local ballpos = ball.pos() + local enemy_num =0 + local KeepEnemyNum = enemy.closestBall() + local j = KeepEnemyNum + Tdebug() + if ball.posX() < depart then + return"front" + else + return"center" + end + end, + Assister = function () return (task.goCmuRush(DenfendPosFront("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(DenfendPosFront("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(DenfendPosFront("Special"),balldir("Special"),DSS_FLAG)) end, + match = "[AKS]" +}, + + +["front"] = { + switch = function() + --[[local enemypos_1 = enemy.pos(defendNum("Tier")) + local enemypos_2 = enemy.pos(defendNum("Defender"))--]] + local ballpos = ball.pos() + local enemy_num =0 + local KeepEnemyNum = enemy.closestBall() + local ballpos = ball.pos() + if ball.velMod() > 500 then + return "exit" + end + Tdebug() + end, + Assister = function () return (task.goCmuRush(DenfendPosFront("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(DenfendPosFront("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(DenfendPosFront("Special"),balldir("Special"),DSS_FLAG)) end, + + match = "[AKS]" +} , +["center"] = { + switch = function() + --[[local enemypos_1 = enemy.pos(defendNum("Tier")) + local enemypos_2 = enemy.pos(defendNum("Defender"))--]] + + + -- if (LockdefendNum("Assister") == 0 and LockdefendNum("Kicker") == 0)then + -- Locked_Enemy={ + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- 0, + -- } + -- end + debugEngine:gui_debug_msg(CGeoPoint(0,0),LockdefendNum("Assister"),5) + debugEngine:gui_debug_msg(CGeoPoint(0,200),LockdefendNum("Kicker"),5) + debugEngine:gui_debug_msg(CGeoPoint(0,400),LockdefendNum("Special"),5) + local ballpos = ball.pos() + local enemy_num =0 + local KeepEnemyNum = enemy.closestBall() + local ballpos = ball.pos() + if ball.velMod() > 500 then + return "exit" + end + Tdebug() + end, + Assister = function () return (task.goCmuRush(DenfendPosCenter("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(DenfendPosCenter("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(DenfendPosCenter("Special"),balldir("Special"),DSS_FLAG)) end, + match = "[AKS]" +} , + + +name = "IndirectDefend", + applicable = { + exp = "a", + a = true + }, + attribute = "attack", + timeout = 99999 +} \ No newline at end of file diff --git a/Core/HuRocos-2024/play/indirectDefend_New.lua b/Core/HuRocos-2024/play/indirectDefend_New.lua new file mode 100644 index 0000000..5c61dd6 --- /dev/null +++ b/Core/HuRocos-2024/play/indirectDefend_New.lua @@ -0,0 +1,176 @@ +local balldir = function () + return function() + return player.toBallDir("Assister") + end +end +-- table.insert(jj,XX) +local depart = 0 + +Free_Enemy={} +Free_Player={} + +Match = {} +function Tdebug() + for i = 0,#Locked_Enemy-1 do + debugEngine:gui_debug_msg(CGeoPoint(-2000, 2000-150*i), "i: "..i.." ".."EnemyState: "..Locked_Enemy[i]) + end +end +--获取球位置 +local ballpos = ball.pos() +KeepDis = 100 + +--获取敌人车号 +-- local LockdefendNum = function() +-- if enemy.valid(j) and Locked_Enemy[j] ==-1 then +-- local enemy_num =0 +-- enemy_num = j +-- Locked_Enemy[j] = -2 +-- end +-- return enemy_num +-- end + + +local DenfendPosFront = function (role) + -- debugEngine:gui_debug_msg(CGeoPoint(0,0), player.num(role)) + -- for i =1, #Free_Player do + -- debugEngine:gui_debug_msg(CGeoPoint(0,150+i*150), Free_Player[i]) + -- end + + ballpos = ball.pos() + local denfendPosfront = enemy.pos(Match[player.num(role)]) + Utils.Polar2Vector(KeepDis, (enemy.pos(Match[player.num(role)]) - ballpos):dir() + math.pi / 3) + return denfendPosfront +end + +local DenfendPosCenter = function (role) + -- debugEngine:gui_debug_msg(CGeoPoint(0,0), player.num(role)) + -- for i =1, #Free_Player do + -- debugEngine:gui_debug_msg(CGeoPoint(0,150+i*150), Free_Player[i]) + -- end + + ballpos = ball.pos() + local denfendPoscenter = enemy.pos(Match[player.num(role)]) + Utils.Polar2Vector(KeepDis, (enemy.pos(Match[player.num(role)]) - ballpos):dir() + math.pi / 3) + return denfendPoscenter +end + +------------------------------------------------------------------------------------------------- +return { + + __init__ = function(name, args) + print("in __init__ func : ",name, args) + end, + + +firstState = "Init", + +["Init"] = { + switch = function () + -- 预处理,导入所有车辆 + local Free_Enemy_Len = 1 + for i = 0, param.maxPlayer - 1 do + if enemy.valid(i) then + Free_Enemy[Free_Enemy_Len] = i + Free_Enemy_Len = Free_Enemy_Len + 1 + end + end + + local Free_Player_Len = 1 + for i = 0, param.maxPlayer - 1 do + if player.valid(i) then + Free_Player[Free_Player_Len] = i + Free_Player_Len = Free_Player_Len + 1 + end + end + + -- 排除最近的机器人并且移出队列 + for i = 1, #Free_Enemy do + if Free_Enemy[i] == enemy.closestBall() then + Free_Enemy[i] = Free_Enemy[#Free_Enemy] + end + end + + -- 一人一防 + for i = 1, #Free_Enemy do -- E == P + if i > #Free_Player then -- E > P + break + end + Match[Free_Player[i]] = Free_Enemy[(i + #Free_Enemy - 1) % #Free_Enemy + 1] -- E < P + + -- debugEngine:gui_debug_msg(CGeoPoint(0,300 + 150 * i), Free_Player[i].." "..Match[Free_Player[i]].." "..((i + #Free_Enemy - 1) % #Free_Enemy + 1)) + -- debugEngine:gui_debug_msg(CGeoPoint(0,300 + 150 * i), Free_Player[i].." "..Match[Free_Player[i]]) + end + + if(bufcnt(true, 5)) then + Tdebug() + if ball.posX() < depart then + return "front" + else + return "center" + end + end + end, + + Assister = function () return (task.goCmuRush(player.pos("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(player.pos("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(player.pos("Special"),balldir("Special"),DSS_FLAG)) end, + + -- Assister = task.stop(), + -- Kicker = task.stop(), + -- Special = task.stop(), + + match = "[AKS]" +}, + +["N"] = { + switch = function () + + end, + + Assister = function () return (task.goCmuRush(player.pos("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(player.pos("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(player.pos("Special"),balldir("Special"),DSS_FLAG)) end, + + match = "[AKS]" +}, + +["front"] = { + switch = function() + + local ballpos = ball.pos() + if ball.velMod() > 500 then + return "exit" + end + Tdebug() + end, + Assister = function () return (task.goCmuRush(DenfendPosFront("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(DenfendPosFront("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(DenfendPosFront("Special"),balldir("Special"),DSS_FLAG)) end, + + match = "[AKS]" +} , +["center"] = { + switch = function() + + -- debugEngine:gui_debug_msg(CGeoPoint(0,0),LockdefendNum("Assister"),5) + -- debugEngine:gui_debug_msg(CGeoPoint(0,200),LockdefendNum("Kicker"),5) + -- debugEngine:gui_debug_msg(CGeoPoint(0,400),LockdefendNum("Special"),5) + local ballpos = ball.pos() + if ball.velMod() > 500 then + return "exit" + end + Tdebug() + end, + Assister = function () return (task.goCmuRush(DenfendPosCenter("Assister"),balldir("Assister"),DSS_FLAG)) end, + Kicker = function () return (task.goCmuRush(DenfendPosCenter("Kicker"),balldir("Kicker"),DSS_FLAG)) end, + Special = function () return (task.goCmuRush(DenfendPosCenter("Special"),balldir("Special"),DSS_FLAG)) end, + match = "[AKS]" +} , + + +name = "IndirectDefend_New", + applicable = { + exp = "a", + a = true + }, + attribute = "attack", + timeout = 99999 +} \ No newline at end of file