-
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.
Merge pull request #8 from rormartin/develop
Develop
- Loading branch information
Showing
5 changed files
with
100 additions
and
69 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
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,62 @@ | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package search | ||
|
||
// State is a basic state represtation for search algorithms | ||
type State interface { | ||
|
||
// For and input action, the function generates a new state with | ||
// the new action included | ||
ApplyAction(action Action) State | ||
|
||
// Returns the list of actions applied to the state to research the | ||
// actual state | ||
GetPartialSolution() []Action | ||
|
||
// Returns the sum of all the costs for all the actions applied | ||
// to the actual state | ||
GetSolutionCost() float64 | ||
|
||
// For a given action, the funcion determinate if is possible to | ||
// apply that action to the state | ||
// isValidAction(action Action) bool | ||
|
||
// Method that generate a list of all the possible applicable actions | ||
// for the current state | ||
GetApplicableActions() []Action | ||
|
||
// Returns if the actual state is a solution state | ||
IsSolution() bool | ||
|
||
// Compare two states | ||
Equal(second State) bool | ||
|
||
// Add the action to the current state | ||
// addActionToSolution(action Action) | ||
|
||
// Returns the depth in the search tree of the current state | ||
GetStateLevel() int | ||
|
||
// the heuristic evaluation for a state | ||
Heuristic() float64 | ||
|
||
// Default string representation (mainly for debug) | ||
String() string | ||
} | ||
|
||
// Action interface to represent the cost of an action | ||
type Action interface { | ||
// represents the float cost for an Action | ||
Cost() float64 | ||
} |
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,38 @@ | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package search | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
||
// Statistics information about the state space explored by the search | ||
type Statistics struct { | ||
NodesExplored int | ||
NodesDuplicated int | ||
MaxDepth int | ||
Solutions int | ||
} | ||
|
||
// Basic string default representation for the Statistics | ||
func (stats Statistics) String() string { | ||
|
||
return "[" + | ||
"NodesExplored: " + strconv.Itoa(stats.NodesExplored) + ", " + | ||
"NodesDuplicated: " + strconv.Itoa(stats.NodesDuplicated) + ", " + | ||
"MaxDepth: " + strconv.Itoa(stats.MaxDepth) + ", " + | ||
"Solutions: " + strconv.Itoa(stats.Solutions) + | ||
"]" | ||
|
||
} |
File renamed without changes.
File renamed without changes.