我需要一個簡單的AI腳本來隨機制作一個殭屍對象。我使用Google和Google搜索,但我所能找到的只是數學功能「Random Walk」中的內容。也許它是相關的?隨機2D Zombie散步
我用我自己的JavaScript 2D引擎,我需要有類似:
function update() {
//Move using available physics engine stuff:
// this.position, this.rotation, this.velocity, this.torque, this.acceleration
// this.torqueAcceleration, this.drag, this.torqueDrag
}
謝謝! :)
使用隨機函數來獲得低百分比機會改變方向(反轉值)? - 請進一步解釋你的問題在這裏。 - 例如:if(Math.floor(Math.random()* 11)== 0)// 10%的機會 this.acceleration * = -1;' – Smamatti
如果你想擁有「真正的」隨機,你必須使用'Math.random()'。混合這與距離,以及所有變量。我假設你不是指人工智能? – OptimusCrime
謝謝,我並不是真正的意思是AI(我已經建立了AI),這就是爲什麼我說簡單..只是想不出一個更好的方式來描述它 - 行爲會更好 – jt78