AI Racing Game in JavaScript [Understanding AI - Lesson 8 / 15]

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024

Комментарии • 33

  • @juritronics
    @juritronics 6 месяцев назад +4

    I like the way you show how powerful javascript is... Keep up the good work. From Zimbabwe.🔥🔥🔥🔥🔥🔥

    • @Radu
      @Radu  6 месяцев назад

      Thanks :-) I'll try!

  • @smnomad9276
    @smnomad9276 6 месяцев назад +2

    I am so blessed to have found your channel! You have literally the best AI programming content on RUclips, no one comes close to you! You deserve at least 500k followers! Keep up the awesome work🔥🔥

    • @Radu
      @Radu  6 месяцев назад

      Thanks for watching :-)

  • @charlesukanga4835
    @charlesukanga4835 6 месяцев назад +2

    🎉radu is definitely the god of JavaScript

    • @Radu
      @Radu  6 месяцев назад

      I doubt :-D

  • @cazpfitl
    @cazpfitl 6 месяцев назад +1

    GREAT, Thank you professor. 😃

    • @Radu
      @Radu  6 месяцев назад

      You're welcome! :-)

  • @2difficult2do
    @2difficult2do 6 месяцев назад +1

    Thanks Radu, this is really interesting and usefull ☝️😼👍

    • @Radu
      @Radu  6 месяцев назад +1

      Happy to hear :-)

  • @autozone5335
    @autozone5335 6 месяцев назад +1

    Awesome !

    • @Radu
      @Radu  6 месяцев назад

      Thanks!

  • @javifontalva7752
    @javifontalva7752 7 месяцев назад +1

    This is just amazing!!!

    • @Radu
      @Radu  7 месяцев назад

      Thanks :-) it was really fun coding it!

  • @adilsonbuset738
    @adilsonbuset738 7 месяцев назад +1

    Merci, Radu.

    • @Radu
      @Radu  7 месяцев назад +1

      No problem :-)

  • @pizdaxyu
    @pizdaxyu 6 месяцев назад +1

    that was some setTimeout callback maze, my AI over-the-shoulder was fuming

    • @Radu
      @Radu  6 месяцев назад

      Haha, yeah... Not sure why I did that...
      I mean, if the countdown would have been from 10, I'm sure I would have used setInterval instead and clearInterval when reaching zero. But this was... maybe, at the limit of how deep I accept my 'callback hell' to be :-))

  • @StephanGiga99
    @StephanGiga99 6 месяцев назад +1

    Did I miss something or you didn’t implement the behavior that the car should have with traffic lights, stop markings, other cars, etc? Are you going to do it in the next videos or will you skip that part? Because I think it was pretty cool

    • @Radu
      @Radu  6 месяцев назад +2

      You didn't miss anything. I did teach the stop, and traffic lights in lesson 4, but using the playground. I also mentioned then that the logic for cars is the same as the traffic lights but with a sensor looking for cars in front and to the right.
      I also explained at the end of lesson 5 how to load a car from the playground and how to update it and the neural network to work with the speed as an extra sensor to apply the right-hand-rule. And from now on will stick with that one and focus on adding features to the racing game.
      Initially I had some lesson showing how to implement the behavior you describe, but decided to cancel it because I wanted to move to the racing scenario where those rules are not needed, so it would affect the flow of the course. I also think the techniques I've been teaching so far should make it possible for you to implement that behavior yourselves. But... you're not the only one asking this, so, one day I may make a live stream or short lesson where I teach how to do it (it would be about 15 minutes, I think).

  • @MadaraAzukar
    @MadaraAzukar 6 месяцев назад +2

    Hey Sir I'm back after a long time
    I havent watched your videos for almost 6 months
    But I have a question
    For eg i have an array of points like this [[3,4],[4,8]....]
    These are actually x and y points of racing track which has a radius
    Amd I have a car so I want just little code to achieve the pathfinding like the car stops and avoid collisions with road
    Plz help me

    • @Radu
      @Radu  6 месяцев назад

      You're describing very much the virtual world we created in phase 2 of the course.
      Maybe the 'integration' lesson from that playlist can help you out?

    • @MadaraAzukar
      @MadaraAzukar 6 месяцев назад +2

      @@RaduThanks Sir i have now downloaded tge playlist I will watch tomorrow if i have some question I will ask

  • @ChandrashekarCN
    @ChandrashekarCN 6 месяцев назад +1

    💖💖💖💖

    • @Radu
      @Radu  6 месяцев назад

      ❤️

  • @javifontalva7752
    @javifontalva7752 6 месяцев назад +1

    any idea why I can't see the target onrace.html or sim.html but I do on index.html (I don't get any error and I passed target.js and targetEditor.js

    • @Radu
      @Radu  6 месяцев назад

      Not really... because the world object and its draw method are the same... Just a guess, maybe you load a world that contains a target in index.html, but the world you load in race.html and sim.html doesn't actually contain a target?

    • @javifontalva7752
      @javifontalva7752 6 месяцев назад +1

      @@Radu it does contain a target since I console.log world.markings and I see Start and Target and I get the corridor. It is so weird but... I'm just going to leave it like that.

    • @Radu
      @Radu  6 месяцев назад

      If you could share your entire codebase somehow (like on Discord or send a github link) I can have a look.

  • @andresgardiol8111
    @andresgardiol8111 7 месяцев назад +1

    First comment!

    • @Radu
      @Radu  7 месяцев назад

      :-) yes indeed!

  • @javifontalva7752
    @javifontalva7752 6 месяцев назад +1

    I'd like to share my change in the method update in minimap to draw the cars on the map.
    ....
    // Draw cars' positions
    this.ctx.restore();
    this.ctx.arc(this.size / 2, this.size / 2, 150, 0, Math.PI * 2);
    this.ctx.strokeStyle = "transparent";
    this.ctx.clip();
    for (const car of cars) {
    const carPosition = car.getPosition();
    const scaledCarX = (carPosition.x - viewPoint.x) * scaler + this.size / 2;
    const scaledCarY = (carPosition.y - viewPoint.y) * scaler + this.size / 2;
    this.ctx.fillStyle = car.color;
    this.ctx.beginPath();
    this.ctx.arc(scaledCarX, scaledCarY, 6, 0, Math.PI * 2);
    this.ctx.fill();
    if (car.type === "KEYS") {
    this.point.draw(this.ctx, {
    color: car.color,
    fill: true,
    dash: [3, 3],
    time,
    });
    }
    I hope you like it (you need to pass cars in the minimap.update as a parameter

    • @Radu
      @Radu  6 месяцев назад

      Hi, I couldn't test because looks like you've added some more things, like a 'getPosition' method to the car among other things. But I got the idea of what you did and I think it's nice :-)