local
tbMap = {
[1] = { 2, 4 },
[2] = { 1, 3, 5 },
[3] = { 2, 6 },
[4] = { 1, 5, 7 },
[5] = { 2, 4, 6, 8 },
[6] = { 3, 5, 9 },
[7] = { 4, 8 },
[8] = { 5, 7, 9 },
[9] = { 6, 8 },
}
function
FindNextPos(nCurPos)
local
tbNext = tbMap[nCurPos]
local
tbPos = {}
for
k,
v
in
pairs(tbNext)
do
table.insert(tbPos,
v
)
end
local
nNext = tbPos[math.random(
#tbPos)] or 0
return
nNext
end
function
tst_roll_analyze(nRoll)
local
tbResult = {}
local
nCurPos = 5
for
i = 1, nRoll
do
nCurPos = FindNextPos(nCurPos)
tbResult[nCurPos] = tbResult[nCurPos] or 0
tbResult[nCurPos] = tbResult[nCurPos] + 1
end
for
i = 1,
#tbResult do
print(tbResult[i])
end
end
tst_roll_analyze(100000)