mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 22:57:09 +00:00
use mini a star for all pathfinding
This commit is contained in:
@@ -42,8 +42,8 @@ export class MiniAStar implements AStar {
|
||||
function upscalePath(path: Cell[], scaleFactor: number = 2): Cell[] {
|
||||
// Scale up each point
|
||||
const scaledPath = path.map(point => (new Cell(
|
||||
point.x * scaleFactor,
|
||||
point.y * scaleFactor
|
||||
point.x * scaleFactor,
|
||||
point.y * scaleFactor
|
||||
)));
|
||||
|
||||
const smoothPath: Cell[] = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Cell, Game, Tile } from "../game/Game";
|
||||
import { manhattanDist } from "../Util";
|
||||
import { AStar, PathFindResultType, TileResult } from "./AStar";
|
||||
import { AStar, PathFindResultType, SearchNode, TileResult } from "./AStar";
|
||||
import { ParallelAStar, WorkerClient } from "../worker/WorkerClient";
|
||||
import { SerialAStar } from "./SerialAStar";
|
||||
import { MiniAStar } from "./MiniAStar";
|
||||
@@ -19,7 +19,7 @@ export class PathFinder {
|
||||
) { }
|
||||
|
||||
|
||||
public static Mini(game: Game, iterations: number, canMove: (t: Tile) => boolean, maxTries: number = 20) {
|
||||
public static Mini(game: Game, iterations: number, canMove: (s: SearchNode) => boolean, maxTries: number = 20) {
|
||||
return new PathFinder(
|
||||
game,
|
||||
(curr: Tile, dst: Tile) => {
|
||||
|
||||
Reference in New Issue
Block a user