snake: attempt to move path refresh to post-regen
This commit is contained in:
		
							parent
							
								
									727e13a1c9
								
							
						
					
					
						commit
						86ef363d3b
					
				
							
								
								
									
										10
									
								
								src/snake.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/snake.ts
									
									
									
									
									
								
							| @ -255,8 +255,8 @@ class Bot { | ||||
|         return next; | ||||
|     } | ||||
| 
 | ||||
|     autoplay() { | ||||
|         if (this.path.length > 0) | ||||
|     pathRefresh() { | ||||
|         if (this.path.length !== 0) | ||||
|             return; | ||||
|         this.bfs(); | ||||
|         this.trim(); | ||||
| @ -273,14 +273,14 @@ function snakeloop() { | ||||
|     if (g_snake.gameover) | ||||
|         g_snake.reset(); | ||||
|      | ||||
|     // Input
 | ||||
|     g_snakebot.autoplay(); | ||||
| 
 | ||||
|     g_snake.simulate(); | ||||
| 
 | ||||
|     // Regenerate food if needed
 | ||||
|     g_snake.foodRegen(); | ||||
| 
 | ||||
|     // Get new path to food
 | ||||
|     g_snakebot.pathRefresh(); | ||||
| 
 | ||||
|     g_snake.draw(); | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user