# Help with car AI

**URL:** https://forum.makecode.com/t/help-with-car-ai/15037
**Category:** Help
**Tags:** graphics-and-math, game
**Created:** [August 22, 2022, 4:25pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037 "2022-08-22T16:25:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Sonicblaston](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sonicblaston/32/19164_2.png) [@Sonicblaston](https://forum.makecode.com/u/Sonicblaston)
#### Post date: [August 22, 2022, 4:25pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/1 "2022-08-22T16:25:36Z")

</div>

I got an adventure game where there are cars driving on the road behind your house. I am trying to make the car randomly choose between directions when it comes to an intersection. I’m using a variable for directions and a math block that chooses a random number between the two directions you can move. The problem is that the car doesn’t change directions. It just goes straight forward. So it would be nice if someone could help  
Here’s the game

> **[Adventure Game - BETA](https://arcade.makecode.com/62242-85763-46244-01542)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [March 28, 2023, 9:58pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/2 "2023-03-28T21:58:48Z")

</div>

scene.onOverlapTile(SpriteKind.Player, assets.tile`"Tile of choice"`, function (sprite, location) {  
if (Math.percentChance(50)) {  
mySprite.vx = 0  
mySprite.vy = -100  
} else {  
mySprite.vx = 100  
mySprite.vy = 0  
}  
})

---

<div class="post-metadata">

### Author: ![Sonicblaston](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sonicblaston/32/19164_2.png) [@Sonicblaston](https://forum.makecode.com/u/Sonicblaston)
#### Post date: [March 29, 2023, 6:21pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/3 "2023-03-29T18:21:36Z")

</div>

Thanks! I just had to wait for 7 months before I got any help with this. And btw im coding in blocks so that doesn’t really help me. Thanks anyway.

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [March 30, 2023, 8:09pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/4 "2023-03-30T20:09:17Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/edf7a46846ed7d575b9f50807980440c321527d9.png)

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [March 30, 2023, 8:09pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/5 "2023-03-30T20:09:24Z")

</div>

and “AI” is not a good word to use for this  
its more like “random Direction” no neural network needed

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [March 30, 2023, 8:09pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/6 "2023-03-30T20:09:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3d977d024a04f1ee7dc2a8b82faad8015e21c05f.png)  
This works for your code

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [March 30, 2023, 10:13pm UTC](https://forum.makecode.com/t/help-with-car-ai/15037/7 "2023-03-30T22:13:39Z")

</div>

If ever you need more help come

> **Here**
>
> [help with pixel art end math issue's](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809)
