haxball / haxball-issues

116 stars 43 forks source link

F1 Racing Bot #1586

Closed cockerelhub closed 2 years ago

cockerelhub commented 2 years ago

I want to add the number of laps to my racing bot. Despite all my attempts, I was unsuccessful. Please help me.

thenorthstar commented 2 years ago

I want to add the number of laps to my racing bot. Despite all my attempts, I was unsuccessful. Please help me.

@cockerelhub Hello dude, I have seen your issue and made a simple F1 time trial bot for you. You can find it out on the following link: https://github.com/thenorthstar/HaxBall-Simple-F1-Racing-Bot/blob/main/js/Simple_F1_Bot.js

Here's a sample time trial: https://thehax.pl/forum/powtorki.php?nagranie=6120a5d55c5b6b97f5dfe94203427c8a

cockerelhub commented 2 years ago

Thank you so much dude <3

I want to add the number of laps to my racing bot. Despite all my attempts, I was unsuccessful. Please help me.

@cockerelhub Hello dude, I have seen your issue and made a simple F1 time trial bot for you. You can find it out on the following link: https://github.com/thenorthstar/HaxBall-Simple-F1-Racing-Bot/blob/main/Simple_F1_Bot.js

Here's a sample time trial: https://thehax.pl/forum/powtorki.php?nagranie=6120a5d55c5b6b97f5dfe94203427c8a

thenorthstar commented 2 years ago

Thank you so much dude <3

I want to add the number of laps to my racing bot. Despite all my attempts, I was unsuccessful. Please help me.

@cockerelhub Hello dude, I have seen your issue and made a simple F1 time trial bot for you. You can find it out on the following link: https://github.com/thenorthstar/HaxBall-Simple-F1-Racing-Bot/blob/main/Simple_F1_Bot.js Here's a sample time trial: https://thehax.pl/forum/powtorki.php?nagranie=6120a5d55c5b6b97f5dfe94203427c8a

@cockerelhub You're welcome.

panthundra commented 2 years ago

Hello! I was looking at the bot and I would like to know what setTimeout() is for, which are inside the checkPlayerLaps() function.

thenorthstar commented 2 years ago

Hello! I was looking at the bot and I would like to know what setTimeout() is for, which are inside the checkPlayerLaps() function.

@panthundra It's for preventing the bot to spam when a player is crossing the start/finish line. Because the function is working on room.onGameTick and has a potential to spam if used incorrectly.

panthundra commented 2 years ago

@panthundra It's for preventing the bot to spam when a player is crossing the start/finish line. Because the function is working on room.onGameTick and has a potential to spam if used incorrectly.

Yes, think so, but above you define: if(!ifInLapChangeZone(p) && playerList[p.name].lapChanged == true){ playerList[p.name].lapChanged = false; } What I see it does is that it restricts it to being executed only once when the finish line is crossed. I don't know if there's something I'm missing, or removing the setTimeout would cause more problems. I have tested it alone and it has not spammed at any time

thenorthstar commented 2 years ago

@panthundra It's for preventing the bot to spam when a player is crossing the start/finish line. Because the function is working on room.onGameTick and has a potential to spam if used incorrectly.

Yes, think so, but above you define: if(!ifInLapChangeZone(p) && playerList[p.name].lapChanged == true){ playerList[p.name].lapChanged = false; } What I see it does is that it restricts it to being executed only once when the finish line is crossed. I don't know if there's something I'm missing, or removing the setTimeout would cause more problems. I have tested it alone and it has not spammed at any time

@panthundra So did you check how did your maps change then? Was they increasing one by one or more than once in one? I had thought also on this situation but (it's my fault) I forgot to say this.

panthundra commented 2 years ago

@panthundra So did you check how did your maps change then? Was they increasing one by one or more than once in one? I had thought also on this situation but (it's my fault) I forgot to say this.

Do you mean when the race ends and the map changes? When that happens there is a spam of the message that changed the map

thenorthstar commented 2 years ago

@panthundra So did you check how did your maps change then? Was they increasing one by one or more than once in one? I had thought also on this situation but (it's my fault) I forgot to say this.

Do you mean when the race ends and the map changes? When that happens there is a spam of the message that changed the map

@panthundra I mean the increment in your maps per every cross on the finish line. Hence, also mean the map change after the last lap completed ofc.

panthundra commented 2 years ago

@panthundra I mean the increment in your maps per every cross on the finish line. Hence, also mean the map change after the last lap completed ofc.

ah, it does not perform increments more than once

thenorthstar commented 2 years ago

@panthundra I mean the increment in your maps per every cross on the finish line. Hence, also mean the map change after the last lap completed ofc.

ah, it does not perform increments more than once

@panthundra I might find a solution to keep it silent. Just set the width (or height) of the rectangular area (according to the direction of the straight of start/finish) equal to the player speed. For example, if the straight of start/finish is horizontal, then set the width of rectangle as equal to the X component player speed.

After doing this, it has just send the message once and no more but I'm not sure if it would work in the same way after I fit that code into my F1 bot.

panthundra commented 2 years ago

@panthundra I might find a solution to keep it silent. Just set the width (or height) of the rectangular area (according to the direction of the straight of start/finish) equal to the player speed. For example, if the straight of start/finish is horizontal, then set the width of rectangle as equal to the X component player speed.

After doing this, it has just send the message once and no more but I'm not sure if it would work in the same way after I fit that code into my F1 bot.

Sorry I thought I was following the conversation well but I think I missed what we're talking about. I guess it's because I have to translate this in google translate. I'm just saying that the setTimeOut doesn't seem necessary since it doesn't spam even without it.

thenorthstar commented 2 years ago

@panthundra I might find a solution to keep it silent. Just set the width (or height) of the rectangular area (according to the direction of the straight of start/finish) equal to the player speed. For example, if the straight of start/finish is horizontal, then set the width of rectangle as equal to the X component player speed. After doing this, it has just send the message once and no more but I'm not sure if it would work in the same way after I fit that code into my F1 bot.

Sorry I thought I was following the conversation well but I think I missed what we're talking about. I guess it's because I have to translate this in google translate. I'm just saying that the setTimeOut doesn't seem necessary since it doesn't spam even without it.

@panthundra Don't worry, we're not going away the topic of the conversation. Before doing that I was think of it's necessary but after I have noticed that I would be able to adjust it without setting a timeout.