【3D】釘に細工がしてある場合。
1 4方向
Option Explicit Sub game() Dim i As Long, j As Long Dim p_x As Integer, p_y As Integer, c As Integer, k_x As Integer, k_y As Integer For i = 1 To 1000 p_x = 0 p_y = 0 k_x = 0 k_y = 0 For j = 1 To 50 c = 0 Randomize c = Int(100 * Rnd + 1) If c <= (25 + k_x) Then p_x = p_x + 1 ElseIf (25 + k_x) < c And c <= 50 Then p_x = p_x - 1 ElseIf 50 < c And c <= (75 + k_y) Then p_y = p_y + 1 Else p_y = p_y - 1 End If If p_x * 5 > 25 Then k_x = 25 ElseIf p_x * 5 < -25 Then k_x = -25 Else k_x = p_x * 5 End If If p_y * 5 > 25 Then k_y = 25 ElseIf p_y * 5 < -25 Then k_y = -25 Else k_y = p_y * 5 End If Next j Cells(i, 1) = p_x Cells(i, 2) = p_y Next i End Sub
(1)確率が(釘の位置の1倍)%増加する場合
(2)確率が(釘の位置の2倍)%増加する場合
(3)確率が(釘の位置の5倍)%増加する場合
2 8方向
Option Explicit Sub game() Dim i As Long, j As Long Dim p_x As Integer, p_y As Integer, c As Integer, k_x As Integer, k_y As Integer, k_xy As Integer, k_yx As Integer For i = 1 To 1000 p_x = 0 p_y = 0 k_x = 0 k_y = 0 k_xy = 0 k_yx = 0 For j = 1 To 50 c = 0 Randomize c = Int(1000 * Rnd + 1) If c <= (125 + k_x) Then p_x = p_x + 1 ElseIf (125 + k_x) < c And c <= 250 Then p_x = p_x - 1 ElseIf 250 < c And c <= (375 + k_y) Then p_y = p_y + 1 ElseIf (375 + k_y) < c And c <= 500 Then p_y = p_y - 1 ElseIf 500 < c And c <= (625 + k_xy) Then p_x = p_x + 1 p_y = p_y + 1 j = j + 1 ElseIf (625 + k_xy) < c And c <= 750 Then p_x = p_x - 1 p_y = p_y - 1 j = j + 1 ElseIf 750 < c And c <= (875 + k_yx) Then p_x = p_x + 1 p_y = p_y - 1 j = j + 1 Else p_x = p_x - 1 p_y = p_y + 1 j = j + 1 End If If p_x * 50 > 125 Then k_x = 125 ElseIf p_x * 50 < -125 Then k_x = -125 Else k_x = p_x * 50 End If If p_y * 50 > 125 Then k_y = 125 ElseIf p_y * 50 < -125 Then k_y = -125 Else k_y = p_y * 50 End If If (p_x * p_y) >= 0 Then If ((p_x + p_y) / 2) * 50 > 125 Then k_xy = 125 ElseIf ((p_x + p_y) / 2) * 50 < -125 Then k_xy = -125 Else k_xy = ((p_x + p_y) / 2) * 50 End If End If If (p_x * p_y) < 0 Then If ((p_x - p_y) / 2) * 50 > 125 Then k_yx = 125 ElseIf ((p_x - p_y) / 2) * 50 < -125 Then k_yx = -125 Else k_yx = ((p_x - p_y) / 2) * 50 End If End If Next j Cells(i, 1) = p_x Cells(i, 2) = p_y Next i End Sub
(1)確率が(釘の位置の0.5倍)%増加する場合
(4)確率が(釘の位置の5倍)%増加する場合
・パチンコ玉と釘の確率・統計(まとめ記事)に戻る。