mirror of
https://github.com/wassname/metacar.git
synced 2026-09-12 12:21:03 +08:00
Reset total on reset
This commit is contained in:
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+3
-3
File diff suppressed because one or more lines are too long
@@ -125,7 +125,7 @@ export class AssetManger {
|
||||
road.obstacle = false;
|
||||
road.mapId = MAP.ROAD;
|
||||
road.orientation = ASSETS.ROADS[info.type].orientation;
|
||||
road.setCarPosition = (car: any, line: number) => this.setCarOnRoad(road, car, line);
|
||||
road.setCarPosition = (car: any, line: number, force: boolean=false) => this.setCarOnRoad(road, car, line, force);
|
||||
road.cars = [];
|
||||
road.mx = info.mx; // Map x
|
||||
road.my = info.my; // Map y
|
||||
@@ -133,7 +133,7 @@ export class AssetManger {
|
||||
this.level.addRoad(road);
|
||||
}
|
||||
|
||||
setCarOnRoad(road: RoadSprite, car: any, line: number){
|
||||
setCarOnRoad(road: RoadSprite, car: any, line: number, force: boolean=false){
|
||||
/*
|
||||
@road: (Obejct) road to position the car on
|
||||
@car: (Object) car object to position
|
||||
@@ -142,13 +142,9 @@ export class AssetManger {
|
||||
if (line == undefined)
|
||||
line = 0;
|
||||
let carById = this.level.findCarById(road.cars[0]);
|
||||
if (road.cars.length >= 1 && carById && carById.core.line == line){
|
||||
if (!force && road.cars.length >= 1 && carById && carById.core.line == line){
|
||||
line = line == 0 ? 1:0;
|
||||
}
|
||||
if (road.cars.length >= 2){
|
||||
car.is_valid = false;
|
||||
return;
|
||||
}
|
||||
car.line = line;
|
||||
|
||||
// Set the car on the road
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ export class Car {
|
||||
this.core.my = this.info.my;
|
||||
let road = this.level.getRoad(this.core.my, this.core.mx);
|
||||
if (road){ // If the car is on a road
|
||||
road.setCarPosition(this.core, this.info.line);
|
||||
road.setCarPosition(this.core, this.info.line, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,9 @@ export class Level extends World {
|
||||
useless collisions.
|
||||
*/
|
||||
this.agent.reset();
|
||||
for (var c = 0; c < this.cars.length; c++) {
|
||||
this.cars[c].reset();
|
||||
}
|
||||
}
|
||||
|
||||
setReward(agent_col: any, on_road: any, action: any){
|
||||
|
||||
Reference in New Issue
Block a user