SGF file parser work in progress.
This commit is contained in:
@@ -6,5 +6,6 @@
|
||||
<classpathentry kind="lib" path="lib/junit-4.10.jar"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
|
||||
<classpathentry kind="lib" path="lib/kgsGtp.jar"/>
|
||||
<classpathentry kind="lib" path="lib/antlrworks-1.4.3.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
BIN
lib/antlrworks-1.4.3.jar
Normal file
BIN
lib/antlrworks-1.4.3.jar
Normal file
Binary file not shown.
@@ -111,7 +111,7 @@ public class GoGame implements Runnable {
|
||||
} else if ("alphabeta".equals(policyName)) {
|
||||
return new AlphaBeta();
|
||||
} else if ("montecarlo".equals(policyName)) {
|
||||
return new MonteCarloUCT(new RandomMovePolicy(), 10000L);
|
||||
return new MonteCarloUCT(new RandomMovePolicy(), 3000L);
|
||||
} else {
|
||||
LOGGER.info("Unable to create Policy for unsupported name: " + policyName);
|
||||
System.exit(INVALID_MOVE_GENERATOR);
|
||||
|
||||
@@ -65,9 +65,9 @@ public abstract class MonteCarlo implements Policy {
|
||||
}
|
||||
|
||||
elapsedTime = System.currentTimeMillis() - startTime;
|
||||
//} while (elapsedTime < searchTimeLimit);
|
||||
} while (elapsedTime < searchTimeLimit);
|
||||
//TODO: for debugging, temporarily specify the number of state evaluations rather than time limit
|
||||
} while (numStateEvaluations < searchTimeLimit);
|
||||
//} while (numStateEvaluations < searchTimeLimit);
|
||||
|
||||
return getBestAction(rootNode);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ public class MonteCarloUCT extends MonteCarlo {
|
||||
double bestScore = Double.NEGATIVE_INFINITY;
|
||||
GameTreeNode<MonteCarloProperties> bestNode = node;
|
||||
|
||||
//TODO: WHAT TO DO if the optimum leaf node is actually a terminal node?
|
||||
//from Kocsis and Szepesvari, the value of an actual terminal node is 0, unless estimated by rollout
|
||||
//What if the optimum leaf node is actually a terminal node?
|
||||
//Grom Kocsis and Szepesvari, the value of an actual terminal node is 0, so it will never be grown.
|
||||
|
||||
double nodeVisits = node.getProperties().getVisits();
|
||||
|
||||
for (Action action : node.getActions()) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
(;FF[4]GM[1]SZ[19]CA[UTF-8]SO[gokifu.com]BC[kr]WC[cn]EV[]PB[Lee Sedol]BR[9p]PW[Gu Li]WR[9p]KM[7.5]
|
||||
DT[2012-09-16]RE[W+R];B[qd];W[dc];B[dq];W[do];B[pp];W[cq];B[de];W[cg];B[cc];W[gc];B[gd];W[hd];B[fc]
|
||||
;W[fd];B[ge];W[fb];B[hc];W[ec];B[gb];W[fc];B[id];W[cd];B[he];W[oc];B[pe];W[qk];B[qi];W[qn];B[qo]
|
||||
;W[pn];B[np];W[oj];B[oi];W[ni];B[nj];W[pi];B[oh];W[pj];B[ph];W[qh];B[qg];W[rh];B[ri];W[rg];B[rf]
|
||||
;W[oo];B[op];W[mj];B[mc];W[nk];B[cr];W[cp];B[gq];W[md];B[nc];W[qf];B[sh];W[pg];B[sg];W[od];B[nd]
|
||||
;W[oe];B[ne];W[nf];B[qg];W[og];B[nh];W[mh];B[mg];W[ng];B[qh];W[mf];B[lg];W[lf];B[ld];W[qc];B[rc]
|
||||
;W[pb];B[rb];W[kg];B[lh];W[mi];B[dl];W[br];B[ce];W[bd];B[dg];W[dh];B[be];W[eg];B[fe];W[dd];B[df]
|
||||
;W[ci];B[gl];W[fh];B[ad];W[bc];B[dr];W[dm];B[em];W[cm];B[gg];W[gh];B[jq];W[fo];B[il];W[hg];B[ho]
|
||||
;W[lo];B[lq];W[kp];B[kq];W[ee];B[ef];W[ff];B[ed];W[gp];B[hq];W[ee];B[pf];W[of];B[ed];W[gn];B[ei]
|
||||
;W[eh];B[ii];W[kd];B[kc];W[ke];B[nb];W[fl];B[fk];W[ek];B[fj];W[dj];B[gf];W[gm];B[kh];W[jh];B[jg]
|
||||
;W[ig];B[jf];W[jd];B[je];W[kf];B[ki];W[jc];B[kb];W[jb];B[ib];W[ja];B[ob];W[ic];B[ih];W[ha];B[hb]
|
||||
;W[ga];B[ma];W[hh];B[hk];W[kl];B[kk];W[jk];B[jj];W[lk];B[bg];W[bh];B[cf];W[ch];B[ag];W[ac];B[el]
|
||||
;W[fm];B[ae];W[rn];B[ro];W[fq];B[fr];W[so];B[sp];W[sn];B[rp];W[gj];B[hj];W[ej];B[fi];W[gi];B[gk]
|
||||
;W[bj];B[jl];W[kj];B[ik];W[fg];B[ee];W[eq];B[er];W[km];B[bs];W[ar];B[rk];W[rl];B[qj];W[no];B[mp]
|
||||
;W[ql];B[qb];W[ia];B[hd];W[pc];B[pa];W[jo];B[hm];W[dp])
|
||||
13
src/net/woodyfolsom/msproj/sgf/CoordValue.java
Normal file
13
src/net/woodyfolsom/msproj/sgf/CoordValue.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class CoordValue extends StrValue {
|
||||
public final char column;
|
||||
public final char row;
|
||||
|
||||
public CoordValue(String coord) {
|
||||
super(coord);
|
||||
|
||||
column = coord.charAt(0);
|
||||
row = coord.charAt(1);
|
||||
}
|
||||
}
|
||||
35
src/net/woodyfolsom/msproj/sgf/GameTree.java
Normal file
35
src/net/woodyfolsom/msproj/sgf/GameTree.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GameTree {
|
||||
private List<Node> nodeSequence = new ArrayList<Node>();
|
||||
private List<GameTree> subTrees = new ArrayList<GameTree>();
|
||||
|
||||
|
||||
public int getNodeCount() {
|
||||
return nodeSequence.size();
|
||||
}
|
||||
|
||||
public List<Node> getNodeSequence() {
|
||||
return Collections.unmodifiableList(nodeSequence);
|
||||
}
|
||||
|
||||
public void setNodeSequence(List<Node> nodeSequence) {
|
||||
this.nodeSequence.clear();
|
||||
|
||||
for(Node node : nodeSequence) {
|
||||
this.nodeSequence.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSubTree(GameTree subTree) {
|
||||
subTrees.add(subTree);
|
||||
}
|
||||
|
||||
public int getSubTreeCount() {
|
||||
return subTrees.size();
|
||||
}
|
||||
}
|
||||
16
src/net/woodyfolsom/msproj/sgf/Node.java
Normal file
16
src/net/woodyfolsom/msproj/sgf/Node.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Node {
|
||||
private List<SGFProperty> properties = new ArrayList<SGFProperty>();
|
||||
|
||||
public void addProperty(SGFProperty property) {
|
||||
properties.add(property);
|
||||
}
|
||||
|
||||
public int getPropertyCount() {
|
||||
return properties.size();
|
||||
}
|
||||
}
|
||||
25
src/net/woodyfolsom/msproj/sgf/NodeCollection.java
Normal file
25
src/net/woodyfolsom/msproj/sgf/NodeCollection.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NodeCollection {
|
||||
private List<GameTree> gameTrees = new ArrayList<GameTree>();
|
||||
|
||||
public void add(GameTree gameTree) {
|
||||
gameTrees.add(gameTree);
|
||||
}
|
||||
|
||||
public GameTree getGameTree(int index) {
|
||||
return gameTrees.get(index);
|
||||
}
|
||||
|
||||
public int getGameTreeCount() {
|
||||
return gameTrees.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "foo";
|
||||
}
|
||||
}
|
||||
7
src/net/woodyfolsom/msproj/sgf/PlayerIdent.java
Normal file
7
src/net/woodyfolsom/msproj/sgf/PlayerIdent.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class PlayerIdent extends StrIdent {
|
||||
public PlayerIdent(String player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
7
src/net/woodyfolsom/msproj/sgf/ResultValue.java
Normal file
7
src/net/woodyfolsom/msproj/sgf/ResultValue.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class ResultValue extends StrValue {
|
||||
public ResultValue(String result) {
|
||||
super(result);
|
||||
}
|
||||
}
|
||||
57
src/net/woodyfolsom/msproj/sgf/SGF.tokens
Normal file
57
src/net/woodyfolsom/msproj/sgf/SGF.tokens
Normal file
@@ -0,0 +1,57 @@
|
||||
T__19=19
|
||||
T__20=20
|
||||
T__21=21
|
||||
T__22=22
|
||||
T__23=23
|
||||
T__24=24
|
||||
T__25=25
|
||||
T__26=26
|
||||
T__27=27
|
||||
T__28=28
|
||||
T__29=29
|
||||
T__30=30
|
||||
T__31=31
|
||||
T__32=32
|
||||
T__33=33
|
||||
T__34=34
|
||||
T__35=35
|
||||
T__36=36
|
||||
T__37=37
|
||||
T__38=38
|
||||
T__39=39
|
||||
COLON=4
|
||||
COMMA=5
|
||||
DIGIT=6
|
||||
LBRACKET=7
|
||||
LCLETTER=8
|
||||
LPAREN=9
|
||||
MINUS=10
|
||||
PERIOD=11
|
||||
PLUS=12
|
||||
RBRACKET=13
|
||||
RPAREN=14
|
||||
SEMICOLON=15
|
||||
SLASH=16
|
||||
SPACE=17
|
||||
UCLETTER=18
|
||||
'AB'=19
|
||||
'AP'=20
|
||||
'BC'=21
|
||||
'BR'=22
|
||||
'CA'=23
|
||||
'CP'=24
|
||||
'EV'=25
|
||||
'FF'=26
|
||||
'GM'=27
|
||||
'KM'=28
|
||||
'PB'=29
|
||||
'PC'=30
|
||||
'PW'=31
|
||||
'RE'=32
|
||||
'RU'=33
|
||||
'SO'=34
|
||||
'SZ'=35
|
||||
'TM'=36
|
||||
'US'=37
|
||||
'WC'=38
|
||||
'WR'=39
|
||||
1526
src/net/woodyfolsom/msproj/sgf/SGFLexer.java
Normal file
1526
src/net/woodyfolsom/msproj/sgf/SGFLexer.java
Normal file
File diff suppressed because it is too large
Load Diff
2325
src/net/woodyfolsom/msproj/sgf/SGFParser.java
Normal file
2325
src/net/woodyfolsom/msproj/sgf/SGFParser.java
Normal file
File diff suppressed because it is too large
Load Diff
22
src/net/woodyfolsom/msproj/sgf/SGFProperty.java
Normal file
22
src/net/woodyfolsom/msproj/sgf/SGFProperty.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class SGFProperty {
|
||||
private StrIdent ident;
|
||||
private StrValue value;
|
||||
|
||||
public StrIdent getIdent() {
|
||||
return ident;
|
||||
}
|
||||
|
||||
public StrValue getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setIdent(StrIdent ident) {
|
||||
this.ident = ident;
|
||||
}
|
||||
|
||||
public void setValue(StrValue value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
5
src/net/woodyfolsom/msproj/sgf/SGFReader.java
Normal file
5
src/net/woodyfolsom/msproj/sgf/SGFReader.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class SGFReader {
|
||||
|
||||
}
|
||||
5
src/net/woodyfolsom/msproj/sgf/SGFWriter.java
Normal file
5
src/net/woodyfolsom/msproj/sgf/SGFWriter.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class SGFWriter {
|
||||
|
||||
}
|
||||
9
src/net/woodyfolsom/msproj/sgf/StrIdent.java
Normal file
9
src/net/woodyfolsom/msproj/sgf/StrIdent.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class StrIdent {
|
||||
public final String value;
|
||||
|
||||
public StrIdent(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
9
src/net/woodyfolsom/msproj/sgf/StrValue.java
Normal file
9
src/net/woodyfolsom/msproj/sgf/StrValue.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.woodyfolsom.msproj.sgf;
|
||||
|
||||
public class StrValue {
|
||||
public final String value;
|
||||
|
||||
public StrValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user