Skip to content

Commit

Permalink
more WIP incrementally computing metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisSoemers committed Jun 17, 2024
1 parent 4bfeb09 commit ac26f87
Show file tree
Hide file tree
Showing 38 changed files with 255 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/Metric.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public MultiMetricValue multiMetricValue()
*/
public abstract void startNewTrial(final Context context, final Trial fullTrial);

/**
* Observe the next state for incrementally computing metrics.
* @param context
*/
public abstract void observeNextState(final Context context);

//-------------------------------------------------------------------------

}
Expand Down
5 changes: 4 additions & 1 deletion Evaluation/src/metrics/MetricsTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public void startNewTrial(final Context context, final Trial fullTrial)
*/
public void observeNextState(final Context context)
{
// TODO
for (final Metric metric : metrics)
{
metric.observeNextState(context);
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/designer/IdealDuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
System.err.println("Incrementally computing metric not yet implemented for IdealDuration.");
}

@Override
public void observeNextState(final Context context)
{
System.err.println("Incrementally computing metric not yet implemented for IdealDuration.");
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/designer/SkillTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
System.err.println("Incrementally computing metric not yet implemented for SkillTrace.");
}

@Override
public void observeNextState(final Context context)
{
System.err.println("Incrementally computing metric not yet implemented for SkillTrace.");
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
currValueList.add(Double.valueOf(Double.valueOf(Utils.boardDefaultSitesCovered(context).size()).doubleValue() / numberDefaultBoardSites));
}

@Override
public void observeNextState(final Context context)
{
currValueList.add(Double.valueOf(Double.valueOf(Utils.boardDefaultSitesCovered(context).size()).doubleValue() / numberDefaultBoardSites));
}

//-------------------------------------------------------------------------


Expand Down
8 changes: 8 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/BranchingFactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public Double[] getMetricValueList(final Evaluation evaluation, final Trial tria
public void startNewTrial(final Context context, final Trial fullTrial)
{
currValueList = new ArrayList<Double>();
currValueList.add(Double.valueOf(context.game().moves(context).moves().size()));
}

@Override
public void observeNextState(final Context context)
{
if (!context.trial().over())
currValueList.add(Double.valueOf(context.game().moves(context).moves().size()));
}

//-------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/DecisionFactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public Double[] getMetricValueList(final Evaluation evaluation, final Trial tria
public void startNewTrial(final Context context, final Trial fullTrial)
{
currValueList = new ArrayList<Double>();

if (context.game().moves(context).moves().size() > 1)
currValueList.add(Double.valueOf(context.game().moves(context).moves().size()));
}

@Override
public void observeNextState(final Context context)
{
if (!context.trial().over() && context.game().moves(context).moves().size() > 1)
currValueList.add(Double.valueOf(context.game().moves(context).moves().size()));
}

//-------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/Drama.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
System.err.println("Incrementally computing metric not yet implemented for Drama.");
}

@Override
public void observeNextState(final Context context)
{
System.err.println("Incrementally computing metric not yet implemented for Drama.");
}

//-------------------------------------------------------------------------

}
22 changes: 22 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/MoveDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ public void startNewTrial(final Context context, final Trial fullTrial)
currValueList = new ArrayList<Double>();
}

@Override
public void observeNextState(final Context context)
{
final Move m = context.trial().lastMove();

final SiteType moveType = m.fromType();

if
(
m.fromType() == m.toType()
&&
m.from() < boardTopology.numSites(moveType)
&&
m.to() < boardTopology.numSites(moveType)
&&
m.from() != m.to()
)
{
currValueList.add(Double.valueOf(boardTopology.distancesToOtherSite(moveType)[m.from()][m.to()]));
}
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/MoveEvaluation.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
System.err.println("Incrementally computing metric not yet implemented for MoveEvaluation.");
}

@Override
public void observeNextState(final Context context)
{
System.err.println("Incrementally computing metric not yet implemented for MoveEvaluation.");
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/PieceNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
currValueList.add(Double.valueOf(Utils.numPieces(context)));
}

@Override
public void observeNextState(final Context context)
{
currValueList.add(Double.valueOf(Utils.numPieces(context)));
}

//-------------------------------------------------------------------------


Expand Down
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/multiple/metrics/ScoreDifference.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
currValueList.add(Double.valueOf(getScoreDiscrepancy(context)));
}

@Override
public void observeNextState(final Context context)
{
currValueList.add(Double.valueOf(getScoreDiscrepancy(context)));
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
System.err.println("Incrementally computing metric not yet implemented for StateEvaluationDifference.");
}

@Override
public void observeNextState(final Context context)
{
System.err.println("Incrementally computing metric not yet implemented for StateEvaluationDifference.");
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
sitesCovered.addAll(Utils.boardDefaultSitesCovered(context));
}

@Override
public void observeNextState(final Context context)
{
sitesCovered.addAll(Utils.boardDefaultSitesCovered(context));
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
sitesCovered.addAll(Utils.boardAllSitesCovered(context));
}

@Override
public void observeNextState(final Context context)
{
sitesCovered.addAll(Utils.boardAllSitesCovered(context));
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
sitesCovered.addAll(Utils.boardUsedSitesCovered(context));
}

@Override
public void observeNextState(final Context context)
{
sitesCovered.addAll(Utils.boardUsedSitesCovered(context));
}

//-------------------------------------------------------------------------

}
7 changes: 7 additions & 0 deletions Evaluation/src/metrics/single/complexity/DecisionMoves.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public void startNewTrial(final Context context, final Trial fullTrial)
numDecisionMoves += 1.0;
}

@Override
public void observeNextState(final Context context)
{
if (!context.trial().over() && context.game().moves(context).moves().size() > 1)
numDecisionMoves += 1.0;
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public void startNewTrial(final Context context, final Trial fullTrial)
branchingFactor += ((double) context.game().moves(context).moves().size()) / numFullTrialMoves;
}

@Override
public void observeNextState(final Context context)
{
if (!context.trial().over())
branchingFactor += ((double) context.game().moves(context).moves().size()) / numFullTrialMoves;
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
11 changes: 11 additions & 0 deletions Evaluation/src/metrics/single/duration/DurationActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*/
public class DurationActions extends Metric
{

//-------------------------------------------------------------------------

/** For incremental computation */
protected double actionTally = 0.0;

//-------------------------------------------------------------------------

Expand Down Expand Up @@ -64,6 +69,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
actionTally += context.trial().lastMove().actions().size();
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/single/duration/DurationMoves.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/single/duration/DurationTurns.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/single/outcome/AdvantageP1.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/single/outcome/Balance.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
6 changes: 6 additions & 0 deletions Evaluation/src/metrics/single/outcome/Completion.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void startNewTrial(final Context context, final Trial fullTrial)
// Do nothing
}

@Override
public void observeNextState(final Context context)
{
// Do nothing
}

//-------------------------------------------------------------------------

}
Loading

0 comments on commit ac26f87

Please sign in to comment.