我目前正試圖編輯下面的代碼在Java中用靜態數字來顯示一個範圍內的數字(這段代碼顯示了塊中某個點的距離,我需要很難找到塊):在一個範圍內的多個加權隨機數
int R = getBlockTypeDistance(event.getClickedBlock().getLocation(), stid);
if (R == -1){
player.sendMessage(ChatColor.BLUE + plugin.getConfig().getString("text.very_cold"));
} else if(R < 12) {
player.sendMessage(ChatColor.RED + plugin.getConfig().getString("text.very_hot"));
} else if(R < 18){
player.sendMessage(ChatColor.RED + plugin.getConfig().getString("text.hot"));
} else if(R < 27){
player.sendMessage(ChatColor.GOLD + plugin.getConfig().getString("text.warm"));
}
我尋找隨機生成的數字爲每個其他if語句與在以下範圍:
相反ř< 12,在0和15
之間的範圍而不是R < 18,範圍15
相反ř< 27之間和22,範圍22和30
之間的所有範圍應具有「權重」(90%獲得高於75%的數中的機會範圍)
任何幫助表示感謝,謝謝。
可能的重複:http://stackoverflow.com/q/363681/2081889 –
他正在嘗試對範圍進行加權,提高出現的數字的概率。絕對不一樣。 –