-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4dc22c
commit 9b77a47
Showing
17 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default class HeuristicValue { | ||
g: number; | ||
h: number; | ||
f: number; | ||
constructor(g: number, h: number, f: number); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { State } from "../utils/state"; | ||
import { operations } from "../utils/operations"; | ||
import HeuristicValue from "./HeuristicValue"; | ||
declare class NodeInfo { | ||
evaluationFunctionValue: HeuristicValue; | ||
operation: operations; | ||
state: State; | ||
previousNode?: NodeInfo; | ||
constructor(efValue: HeuristicValue, op: operations, s: State, prev?: NodeInfo); | ||
} | ||
export { NodeInfo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { NodeInfo } from "./Node"; | ||
import SolutionItem from "./Solution"; | ||
export default class Result { | ||
pathCost: number; | ||
iterations: number; | ||
expandedNodes: number; | ||
finalNode: NodeInfo; | ||
solution?: SolutionItem[]; | ||
constructor(pathCost: number, iterations: number, expandedNodes: number, finalNode: NodeInfo, solution?: SolutionItem[]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { operations } from './../utils/operations'; | ||
import { StateAsList } from "../utils/state"; | ||
export default class SolutionItem { | ||
state: StateAsList; | ||
operation: operations; | ||
constructor(s: StateAsList, op: operations); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default class StateItemPosition { | ||
line: number; | ||
col: number; | ||
constructor(l: number, c: number); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { State } from "../utils/state"; | ||
import { NodeInfo } from "../classes/Node"; | ||
import Result from "../classes/Result"; | ||
declare function runAStarLoop(goalState: State, frontier: NodeInfo[], expandedStates: State[]): Result | undefined; | ||
export { runAStarLoop as run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { State, StateItem } from "../utils/state"; | ||
import StateItemPosition from "../classes/StateItemPosition"; | ||
declare function calcHValue(actualState: State, goalState: State): number; | ||
declare function calcDistanceOfItem(item: StateItem, itemPosition: StateItemPosition, goalState: State): number; | ||
export { calcHValue, calcDistanceOfItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { operations } from './../utils/operations'; | ||
import { NodeInfo } from "../classes/Node"; | ||
import { State } from '../utils/state'; | ||
declare function generateNodeList(node: NodeInfo, goalState: State): NodeInfo[]; | ||
declare function generateNode(state: State, op: operations, goalState: State, gValue: number, previousNode?: NodeInfo): NodeInfo; | ||
export { generateNodeList, generateNode }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { State } from "../utils/state"; | ||
import { operations } from "../utils/operations"; | ||
import StateItemPosition from "../classes/StateItemPosition"; | ||
declare function applyOperation(state: State, op: operations): State | null | undefined; | ||
declare function moveUpOperation(state: State): State | null; | ||
declare function moveRightOperation(state: State): State | null; | ||
declare function moveDownOperation(state: State): State | null; | ||
declare function moveLeftOperation(state: State): State | null; | ||
declare function getPositionOfBlankItem(state: State): StateItemPosition; | ||
export { applyOperation, moveUpOperation, moveRightOperation, moveDownOperation, moveLeftOperation, getPositionOfBlankItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { NodeInfo } from "../classes/Node"; | ||
import SolutionItem from "../classes/Solution"; | ||
declare function getSolutionFromNode(node: NodeInfo, list: SolutionItem[]): SolutionItem[]; | ||
export { getSolutionFromNode }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { State, StateAsList } from "../utils/state"; | ||
declare function areEqual(state1: State, state2: State): boolean; | ||
declare function includes(state: State, list: State[]): boolean; | ||
declare function isSolvable(state: State): boolean; | ||
declare function convertStateInArray(state: State): StateAsList; | ||
declare function convertArrayInState(stateList: StateAsList): State; | ||
export { areEqual, includes, isSolvable, convertArrayInState, convertStateInArray }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { State, StateAsList } from "./utils/state"; | ||
import { isSolvable, convertArrayInState, convertStateInArray } from './functions/state'; | ||
declare function index(state: StateAsList, finalState?: State): import("./classes/Result").default; | ||
export { index as solvePuzzle, convertArrayInState, convertStateInArray, isSolvable }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { NodeInfo } from "../classes/Node"; | ||
export declare type Frontier = NodeInfo[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export declare enum operations { | ||
up = "UP_OPERATION", | ||
right = "RIGHT_OPERATION", | ||
down = "DOWN_OPERATION", | ||
left = "LEFT_OPERATION", | ||
none = "NONE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare type StateItem = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 0; | ||
declare type State = [[StateItem, StateItem, StateItem], [StateItem, StateItem, StateItem], [StateItem, StateItem, StateItem]]; | ||
declare type StateAsList = StateItem[]; | ||
export { State, StateItem, StateAsList }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters