日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ChinaOpenSSL系列笔记足球机器人

發布時間:2024/1/1 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ChinaOpenSSL系列笔记足球机器人 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

觀察一下:? ? ? ? TestDribbleAndKick(吸球射門)

語義

FPS 幀率

DeviceMsg? ? ? ? //黃一排

DrawObst? ? ? ? ? //障礙物信息

快捷鍵:ctrl+p打開
配置一個play:? 在???config.lua
簡單框架

local testPos = {CGeoPoint:new_local(0,0) }gPlayTable.CreatePlay{firstState = "run1",["run1"] = {switch = function() //是否要切換狀態 end,Kicker = task.goCmuRush(testPos[1],0),match = "" },name = "MyTestRun", applicable ={exp = "a",a = true }, attribute = "attack", timeout = 99999 }

?報錯

語法沒問題,語義有問題,報錯會在其他地方

一、如何使用switch函數

player.lua

enemy.lua? ? ? ? //針對敵方

ball.lua? ? ? ? //球速、球的位置、球的朝向

pos.lua? ? ? ? //位置相關

bufcnt.lua

...

1、!!延長時間(bufcnt.lua)

bufcnt(cond,buf,cnt)?

if bufcnt(true,200) then? ? ? ? //當true條件持續滿足200幀再執行

? ? ? ? return "run2"

2、player.lua(升級)

if bufcnt(player.toTargetDist('Kicker')<10,10) then? ? ? ?

????????return "run2"

二、match? ? ? ? 就近匹配? ? ?

{ } :不匹配,維持狀態

[ ] :實時匹配

( ) :每當進行一次states的切換時進行一次匹配

機器人名字:

Assister? ? ? ? Special? ? ? ? Defender? ? ? ? Middle

Leader? ? ? ? ? Breaker? ? ? ?Fronter? ? ? ? ? ?Center? ? ? ? ...abcd...

task.lua

框架

task function - skill.lua - skill from c++

task function 中的內容只執行一遍

Play 調試

錄制????????第四欄中的? ? ? ? DeviceMsg? ? ? ? ;點擊第三欄中的文件夾

查看

FRAREDOFF

FRAREDON? ? ? ? 吸球吸了多久

CHIPKICK

FLATKICK

INFRARED? ? ? ? 紅外觸發變1

?來回跳動的簡單框架

local testPos = {CGeoPoint:new_local(0,0)CGeoPoint:new_local(1000,1000) }local DEBUG_SWITCH = true;gPlayTable.CreatePlay{firstState = "run1",["run1"] = {switch = function() if bufcnt(player.toTargetDist("Leader")<5,time) thenreturn "run2"end end,Leader = task.goCmuRush(testPos[1],0),match = "{L}" },["run2"] = {switch = function() if DEBUG_SWITCH thenendif bufcnt(player.toTargetDist("Leader")<5,time) thenreturn "run1"end end,Leader = task.goCmuRush(testPos[2],0),match = "{L}" },name = "MyTestRun", applicable ={exp = "a",a = true }, attribute = "attack", timeout = 99999 }

debugEngine.pkg? ? ? ? //連接lua和c++

?: 表示隱式指針

debugEngine:gui_debug_x(CGeoPoint:new_local(1000,1000))

Yourplay.lua/task.lua/play.lua

小車繞球旋轉代碼實現?

local testPos = {CGeoPoint:new_local(0,0), } local TOTAL = 4 local speed = 1/4.0 local angle = 0 local radius = 500local p = function(n,TOTAL)return function()local centerX = ball.posX()local centerY = ball.posY()return CGeoPoint:new_local(centerX + radius * math.cos(angle + n*math.pi*2/TOTAL)end end gPlayTable.CreatPlay{ fristStates = "tun", ["run"] = {switch = function()angle = angle +math.pi*2/60*speedend,Leader = task.goCmuRush(p(1,TOTAL)),Assister = task.goCmuRush(p(2,TOTAL)),Middle = task.goCmuRush(p(3,TOTAL)),Special = task.goCmuRush(p(4,TOTAL)),math = "{LAMS}" },name = "MyRun", applicable = {exp = "a",a = true }, attribute = "attack", timeout = 99999 }

繞敵對機器人旋轉代碼片段實現

local enemeyPos = function(num)return function()return enemy.pos(num)end end local p = function(n,TOTAL,pos)return function()ipos = posif type(pos) == 'function' thenipos = pos()elseipos = posendlocal centerX = ipos:x()local centerY = ipos:y()return CGeoPoint:new_local(centerX + radius*math.cos(angle + n*math.pi*2/TOTAL)end end gPlayTable.CreatePlay{ firstState = "run", ["run"] = {switch = function()angle = angle +math.pi*2/60*speedend,Leader = task.goCmuRush(p(1,2,enemyPos(1))),Assister = task.goCmuRush(p(2,2,enemyPos(1))),Middle = task.goCmuRush(p(1,2,enemyPos(0))),Special = task.goCmuRush(p(2,2,enemyPos(0))),match = "(LA)(MS)" }, ...

?Task.lua? 的封裝

TestSkill.lua

gPlayTable.CreatePlay{ fristState = "test", ["test"] = {switch = function()end,Leader = task.marking(-3500,0,-2000,2000),match = "{L}" },name = "TestSkill", applicable = {exp = "a",a = true }, attribute = "attack", timeout = 99999 }

test.lua?

function marking(xmin,xmax,ymin,ymax)local num = 0local ourGoal = CGeoPoint:new_local(-param.pitchLength/2.0,0)local drawDebug = function()local p1 = CGeoPoint:new_local(xmin,ymin)local p2 = CGeoPoint:new_local(xmin,ymax)local p3 = CGeoPoint:new_local(xmax,ymin)local p4 = CGeoPoint:new_local(xmax,ymax)debugEngine:gui_debug_line(p1,p2,4)debugEngine:gui_debug_line(p2,p4,4)debugEngine:gui_debug_line(p3,p4,4)debugEngine:gui_debug_line(p1,p3,4)endlocal checkNum = function()local between = function(a,min,max)if a>min and a<max thenreturn trueendreturn falseendlocal num = -1for i=0,param.maxPlayer-1 doif enemy.valid(i) and between(enemy.posX(i),xmin,xmax) and between(enemy.posY(i),ymin,ymax)return iendreturn numendlocal ipos = function()local num =checkNum()local enemyPos = enemy.pos(num)if num < 0 thenenemyPos=CGeoPoint:new_local((xmin+xmax)/2.0,(ymin+ymax)/2.0)endlocal reslocal l = (outGoal - enemy.pos(num)):mod()*0.3res = enemy.pos(num) + Util.Polar2Vector(l,(ourGoal - enemy.pos(num)):dir())return resendlocal idir = function(runner)local num = checkNum()local enemyPos = enemy.pos(num)if num < 0 thenenemyPos=CGeoPoint:new_local((xmin+xmax)/2.0,(ymin+ymax)/2.0)endlocal resres = (enemyPos - ourGoal):dir()return resendlocal mexe,mpos = GoCmuRush{pos = ipos,dir = idir,acc = a,flag = f,rec =return {mexe,mpos} end

?盯防配合代碼簡單實現(需修改)

function waitForAttack()local checkAttacker = function(runner)for i=0,param.maxPlayer-1 dolocal dis = (ball.pos() - player.pos(i)):modif player.valid(i) and dis <1000 and i~= runner thendebugEngine:gui_debug_msg(CGeoPoint:new_local(0,i*200),i..(player.valid(i) and 'T' or 'F')..dis)rerurn iendendreturn -1endlocal ipos = function(runner)local num = checkAttacker(runner)local x = player.posX(num)local y = player.posY(num)local length = param.pitchLength/2return CGeoPoint:new_local(length - x ,-y)endlocal idir = function(runner)return player.toTheiGoalDir(runner)endlocal mexe,mpos = GoCmuRush{pos = ipos,dir = idir ,acc = a,flag=f,rec=r,vel=v}return {mexe,mpos} end

除了switch、match的,和機器人名稱有關的才是table

task有8個參數,

if roleNum ~= -1 then

????????if task[3] ~= nil then

? ? ? ????????? local mkick = task[3](roleNum)? ? ? ? //踢球模式

? ? ? ? ????????local mdir = task[4](roleNum)? ? ? ? //踢球方向

? ? ? ? ? ? ? ? local mpre = task[5](roleNum)? ? ? ? //踢球精度

? ? ? ? ? ? ? ? local mkp =?task[6](roleNum)? ? ? ? //平射力度

? ? ? ? ? ? ? ? local mcp =?task[7](roleNum)? ? ? ? //挑射力度

? ? ? ? ? ? ? ? local mflag = task[8]????????

? ? ? ? ? ? ? ? local isDirOk = world :KickDirArrived(vision:getCycle(),mdir,mpre...

kick.flat 平射

function speed (vx,vy,vdir)

//function speed(vx,vy,vdir,p,f)

? ? ? ? local ikick = kick.flat

//local ikick = kick.none

? ? ? ? local idir = dir.specified(0)

? ? ? ? local ipre = pre.specified(10)

? ? ? ? local ikp = kp.specified(2000)

//local ikp = kp.specified(p)

? ? ? ? local icp = cp.specified(1000)

? ? ? ? local iflag = flag.nothing

? ? ? ? local spdX = function()

? ? ? ? ? ? ? ? return vx

? ? ? ? local spdY = function()

? ? ? ? ? ? ? ? return vy

? ? ? ? local spdW = function()

? ? ? ? ? ? ? ? return vdir

? ? ? ? end

????????

? ? ? ? local mexe,mpos = Speed{speedX = spdX,

? ? ? ? return {mexe,mpos,ikick,idir,ipre,ikp,icp,iflag,

end

機器人控制對比

隊伍? ? ? ? ? ? ??路徑? ? ? ? ? ? ? ? ? ?避障? ? ? ? ? ? ? 速度? ? ? ? ? ? ? ? 性能? ? ? ? ???性能

ZJUNlict????????RRT* ????????????????DSS ?????????????Bangbang ????????3 ????????????????1

Tigers????????????Topo+Bspline? ?capsule? ????????2D-Bang? ? ? ? ? ?1 ????????????????2

Immortals? ? ? NOK-RRT???????? DSS ??????????????-? ? ? ? ? ? ? ? ? ? ? ? 1? ? ? ? ?????????3

ER-Force ??????RRT ????????????????- ????????????????????2D-Bang

?Other.lua? ? ? ? 對手配置

gOppoConfig = {

? ? ? ? CornerKick = {1},

? ? ? ? ...

? ? ? ? KickOff = "..."? ? ? ? //開球腳本

? ? ? ? ...? ? ? ? //防守

? ? ? ? ...? ? ? ? //撿球

? ? ? ? ...? ? ? ? //點球

}

?lua的流程? ? ? ? selectPlay.lua選出當前需要的play

?

總結

以上是生活随笔為你收集整理的ChinaOpenSSL系列笔记足球机器人的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。