把概率改到50%

This commit is contained in:
james 2024-08-05 11:29:09 +08:00
parent 5db946f9db
commit 48ce5126c8
1 changed files with 2 additions and 2 deletions

View File

@ -57,8 +57,8 @@ void snake_entry(void *parameter)
{
if (!snake_pressed)
{
//80%的概率保持当前方向20%的概率随机改变方向
if (rand() % 100 < 20)
//50%的概率保持当前方向20%的概率随机改变方向
if (rand() % 100 < 50)
{
new_direction = rand() % 3;
now_direction = (now_direction + 3 + new_direction) % 4; // 防止反向,走回头路