1. Adversial Search= alogritma yang digunakan untuk mendapatkan

advertisement
1. Adversial Search= alogritma yang digunakan untuk mendapatkan tujuan dengan semaksimal mungkin
dengan resiko yang paling kecil dan bila di dalam permainan tujuannya berarti memenangkan
permainan dan resiko dalam permainan berarti kalah dari permainan
Terdiri dari Mini-Max, Alpha Beta Pruning, ImperfectReal-Time Decisions
Contoh permainan: chess, checkers,go,Othello,backgammon,monopoly,bridge,poker,scrabble
Constraint Satisfaction Problems= penyelesaian suatu masalah secara optimal dan menuruti aturanaturan yang dimiliki
Contoh permainan: The n-Queen problem, A crossword puzzle, A cryptography problem, A map coloring
problem
2.Propotional logic= Suatu logika yang sangat simple
Standard Logic Symbols
 = semua
 = beberapa
 = implikasi
 = equivalen
 = Negasi
 = atau; disjunction
 = dan ; conjunction
Komunikatif:
Contoh:
Siapapun yang menyukai semua binatang pasti disukai seseorang
3.A search dan A* search
A node(java):
import java.util.List;
public abstract class AStarNode implements Comparable {
AStarNode pathParent;
float costFromStart;
float estimatedCostToGoal;
public float getCost() {
return costFromStart + estimatedCostToGoal;
}
public int compareTo(Object other) {
float thisValue = this.getCost();
float otherValue = ((AStarNode)other).getCost();
float v = thisValue - otherValue;
return (v>0)?1:(v<0)?-1:0; // sign function
}
public abstract float getCost(AStarNode node);
public abstract float getEstimatedCost(AStarNode node);
public abstract List getNeighbors();
}
A star(Java):
import java.util.*;
public class AStarSearch {
public static class PriorityList extends LinkedList {
public void add(Comparable object) {
for (int i=0; i<size(); i++) {
if (object.compareTo(get(i)) <= 0) {
add(i, object);
return;
}
}
addLast(object);
}
}
protected List constructPath(AStarNode node) {
LinkedList path = new LinkedList();
while (node.pathParent != null) {
path.addFirst(node);
node = node.pathParent;
}
return path;
}
public List findPath(AStarNode startNode, AStarNode goalNode) {
PriorityList openList = new PriorityList();
LinkedList closedList = new LinkedList();
startNode.costFromStart = 0;
startNode.estimatedCostToGoal =
startNode.getEstimatedCost(goalNode);
startNode.pathParent = null;
openList.add(startNode);
while (!openList.isEmpty()) {
AStarNode node = (AStarNode)openList.removeFirst();
if (node == goalNode) {
return constructPath(goalNode);
}
List neighbors = node.getNeighbors();
for (int i=0; i<neighbors.size(); i++) {
AStarNode neighborNode =
(AStarNode)neighbors.get(i);
boolean isOpen = openList.contains(neighborNode);
boolean isClosed =
closedList.contains(neighborNode);
float costFromStart = node.costFromStart +
node.getCost(neighborNode);
if ((!isOpen && !isClosed) ||
costFromStart < neighborNode.costFromStart)
{
neighborNode.pathParent = node;
neighborNode.costFromStart = costFromStart;
neighborNode.estimatedCostToGoal =
neighborNode.getEstimatedCost(goalNode);
if (isClosed) {
closedList.remove(neighborNode);
}
if (!isOpen) {
openList.add(neighborNode);
}
}
}
closedList.add(node);
}
return null;
}
}
Sumber : Materi intelegesia semu binus
http://eric_rollins.home.mindspring.com/search/adversarialSearch.htm
http://www.peachpit.com/articles/article.aspx?p=101142&seqNum=2
Download