Skip to content

Commit c769f9c

Browse files
committed
Event data generation: register kick-off match phase transition
1 parent 5230a79 commit c769f9c

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/main/java/org/mpn/Statement.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public String toString() {
6767
return teamKey + ": " + initialState + " -> "
6868
+ (this.isPossessionChanged() ? "!" : "")
6969
+ endState
70-
+ (this.goalAttemptOutcome != null ? " => " + this.goalAttemptOutcome : "");
70+
+ (this.goalAttemptOutcome != null ? " => " + this.goalAttemptOutcome : "")
71+
+ ", Duration: " + this.getDuration();
7172
}
7273

7374
public void setEndTime(Time endTime) {

src/main/java/org/openengine/mpn/MatchEventDataGeneration.java

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package org.openengine.mpn;
22

3-
import org.mpn.Dataset;
4-
import org.mpn.MatchModel;
5-
import org.mpn.Processable;
3+
import org.mpn.*;
64

5+
import java.util.ArrayList;
6+
import java.util.List;
77
import java.util.Random;
88

99
public class MatchEventDataGeneration {
1010

11+
private static final int DURATION = 60 * 45; // duration in seconds
12+
1113
private Dataset seedMatchEvents;
1214
private Dataset generatedMatchEvents;
1315

16+
private List<ProcessUnit> matchEventsBuffer = new ArrayList<>();
17+
1418
private Random rnd = new Random();
1519

1620
private Team homeTeam;
@@ -33,14 +37,37 @@ public static void main(String[] args) {
3337
}
3438

3539
public void out() {
36-
System.out.println(possessionTeam);
40+
this.generatedMatchEvents = new Dataset(matchEventsBuffer, true);
41+
this.generatedMatchEvents.getData().forEach(System.out::println);
3742
}
3843

3944
public void generate() {
4045
// TODO implement generating of match events
4146
// refactoring of the start() method of MatchEngine class
4247

4348
tossCoin();
49+
playTimePeriod(DURATION);
50+
}
51+
52+
private void registerTransition(MatchPhaseTransition transition) {
53+
this.matchEventsBuffer.add((Statement) transition);
54+
}
55+
56+
private void playTimePeriod(int duration) {
57+
MatchPhaseTransition currentTransition = getKickOffPhaseTransition();
58+
registerTransition(currentTransition);
59+
// processTransition(currentTransition);
60+
/*
61+
while (currentTime < duration) {
62+
currentTransition = getNextTransition(currentTransition);
63+
processTransition(currentTransition);
64+
}
65+
*/
66+
}
67+
68+
private MatchPhaseTransition getKickOffPhaseTransition() {
69+
Dataset potentialTransitions = possessionTeam.getActionsByState(State.KICK_OFF);
70+
return potentialTransitions.getAny();
4471
}
4572

4673
private void tossCoin() {

0 commit comments

Comments
 (0)