import random
# --- 設定 ---
boxes = [random.randint(0,1) for n in range(5)]
ai_brain = [5]*5
print("学習前:", ai_brain)
for _ in range(100000):
choice = random.choices([n for n in range(5)], weights=ai_brain)[0]
if boxes[choice] == 1:
ai_brain[choice] += 1
else:
ai_brain[choice] -= 1
if ai_brain[choice] < 1:
ai_brain[choice] = 1
1
print("学習後:", ai_brain)
best_box = ai_brain.index(max(ai_brain))
print(f"AIの結論: 一番当たりそうなのは {best_box+1} 番の箱です!")
To embed this project on your website, copy the following code and paste it into your website's HTML: