-
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 #2 from michael-kamel/problems/examples
Finalized SaveWesteros
- Loading branch information
Showing
41 changed files
with
1,835 additions
and
143 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,145 @@ | ||
1 | ||
., O, ., ., ., | ||
O, S, O, ., W, | ||
O, W, O, ., W, | ||
W, ., ., ., ., | ||
., ., O, ., J, | ||
|
||
|
||
2 | ||
O, ., O, ., ., ., | ||
., ., W, ., W, O, | ||
., O, O, W, W, O, | ||
., O, S, ., ., ., | ||
., ., ., ., O, ., | ||
., ., O, ., ., J, | ||
|
||
|
||
3 | ||
W, ., ., ., ., ., | ||
., ., O, O, O, ., | ||
W, O, O, O, O, ., | ||
., ., ., S, O, ., | ||
., O, O, O, O, W, | ||
., ., ., ., ., J, | ||
|
||
|
||
4 | ||
W, O, ., ., ., W, | ||
O, ., O, ., ., ., | ||
W, O, O, O, O, ., | ||
., ., ., S, O, ., | ||
., O, O, O, O, W, | ||
., ., ., ., ., J, | ||
|
||
|
||
5 | ||
., ., W, ., | ||
., W, ., ., | ||
O, ., W, O, | ||
., O, S, J, | ||
|
||
|
||
6 | ||
O, O, O, ., W, ., | ||
O, O, O, ., O, ., | ||
O, O, O, ., O, ., | ||
O, O, O, W, O, ., | ||
W, O, ., W, O, S, | ||
W, W, ., W, W, J, | ||
|
||
|
||
7 | ||
O, O, O, ., ., ., | ||
O, O, O, W, O, ., | ||
O, O, O, W, O, ., | ||
O, O, O, W, O, W, | ||
O, ., ., ., O, S, | ||
O, W, ., W, W, J, | ||
|
||
|
||
8 | ||
O, O, ., ., ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, ., ., O, S, | ||
W, ., W, W, J, | ||
|
||
|
||
9 | ||
O, O, ., ., ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, ., ., O, S, | ||
W, ., W, W, J, | ||
|
||
|
||
10 | ||
O, O, ., ., ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, O, W, O, ., | ||
O, ., ., O, S, | ||
W, ., W, W, J, | ||
|
||
|
||
11 | ||
W, ., ., ., ., ., | ||
., O, O, O, O, W, | ||
., O, O, O, O, W, | ||
W, O, O, O, O, ., | ||
., ., O, O, O, S, | ||
W, ., W, W, ., J, | ||
|
||
|
||
12 | ||
S, ., ., ., ., ., | ||
., O, O, O, O, W, | ||
., O, O, O, O, W, | ||
W, O, O, O, O, ., | ||
., ., O, O, O, ., | ||
W, ., W, W, ., J, | ||
|
||
|
||
13 | ||
W, ., ., ., W, ., | ||
O, W, O, O, O, ., | ||
O, W, O, O, O, W, | ||
W, ., O, O, O, S, | ||
W, ., O, O, O, ., | ||
O, ., O, O, O, ., | ||
O, W, ., ., W, J, | ||
|
||
|
||
14 | ||
W, ., ., W, S, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., | ||
O, W, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, ., | ||
O, W, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, ., | ||
W, ., O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, ., | ||
O, ., O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, ., | ||
O, ., O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, ., | ||
O, ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., J, | ||
|
||
|
||
15 | ||
O, ., O, ., ., ., | ||
., ., W, ., W, O, | ||
., O, O, W, W, O, | ||
., O, S, ., ., ., | ||
., ., ., ., O, ., | ||
., ., O, ., ., J, | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
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 was deleted.
Oops, something went wrong.
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,48 @@ | ||
package searching.agents; | ||
|
||
import java.util.Optional; | ||
|
||
import searching.problems.SearchAction; | ||
import searching.problems.SearchState; | ||
|
||
public class SearchTreeNode<T extends SearchState, V extends SearchAction> implements Comparable<SearchTreeNode<T, V>> { | ||
private final Optional<SearchTreeNode<T, V>> parent; //Parent of node | ||
private final long cost; // Path cost from the root of the tree until this node | ||
private final T state; // The current state of the node | ||
private final Optional<V> action; // The action made to reach this node from its parent | ||
private final int depth; //depth from root to this node; root depth==0 | ||
|
||
public SearchTreeNode(Optional<SearchTreeNode<T, V>> parent, long cost, T state, Optional<V> action, int depth) { | ||
this.parent = parent; | ||
this.cost = cost; | ||
this.state = state; | ||
this.action = action; | ||
this.depth = depth; | ||
} | ||
|
||
public Optional<SearchTreeNode<T, V>> getParent() { | ||
return parent; | ||
} | ||
|
||
public long getCost() { | ||
return cost; | ||
} | ||
|
||
public T getCurrentState() { | ||
return state; | ||
} | ||
|
||
public Optional<V> getAction() { | ||
return action; | ||
} | ||
|
||
public int getDepth() { | ||
return depth; | ||
} | ||
|
||
@Override | ||
public int compareTo(SearchTreeNode<T, V> node) { | ||
return this.cost > node.cost ? 1 : this.cost == node.cost ? 0 : -1; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/searching/exceptions/GameConstructionConstraintsViolation.java
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,12 @@ | ||
package searching.exceptions; | ||
/* | ||
* used for handling _problem-specific_ constraints | ||
* */ | ||
public class GameConstructionConstraintsViolation extends SearchProblemException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public GameConstructionConstraintsViolation(String message) { | ||
super(message); | ||
} | ||
|
||
} |
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,9 @@ | ||
package searching.exceptions; | ||
|
||
public abstract class SearchProblemException extends SearchingException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public SearchProblemException(String message) { | ||
super(message); | ||
} | ||
} |
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,9 @@ | ||
package searching.exceptions; | ||
|
||
public abstract class SearchingException extends Exception { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public SearchingException(String message) { | ||
super(message); | ||
} | ||
} |
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,9 @@ | ||
package searching.exceptions; | ||
|
||
public class UnknownGameObjectException extends SearchProblemException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public UnknownGameObjectException(String message) { | ||
super(message); | ||
} | ||
} |
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,18 @@ | ||
package searching.problems; | ||
|
||
import searching.strategies.HeuristicFunction; | ||
|
||
public class HeuristicFunctions { | ||
/** | ||
* a function that calculates the dominant of two heuristic functions | ||
* @param first | ||
* @param second | ||
* @return {@link HeuristicFunction} | ||
*/ | ||
public static <T extends SearchState> HeuristicFunction<T> dominating(HeuristicFunction<T> first, | ||
HeuristicFunction<T> second) { | ||
return state -> { | ||
return Math.max(first.expectedCostToSolution(state), second.expectedCostToSolution(state)); | ||
}; | ||
} | ||
} |
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,3 @@ | ||
package searching.problems; | ||
|
||
public interface SearchAction {} |
Oops, something went wrong.