[virtualcommons-svn] commit/foraging: 2 new changesets
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-02-27 05:32:25
|
2 new commits in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/562c122bd77c/ changeset: 562c122bd77c user: alllee date: 2012-02-27 06:29:51 summary: keeping track of client movements and adding chat targets to all data processor - fixes issue #35 affected #: 1 file diff -r 366a904a852bcf0916fe60507c6d20f7408b4d8a -r 562c122bd77c3f71ed175a22b33ba947c5df4c35 src/main/java/edu/asu/commons/foraging/data/AllDataProcessor.java --- a/src/main/java/edu/asu/commons/foraging/data/AllDataProcessor.java +++ b/src/main/java/edu/asu/commons/foraging/data/AllDataProcessor.java @@ -22,6 +22,7 @@ import edu.asu.commons.foraging.model.GroupDataModel; import edu.asu.commons.foraging.model.Resource; import edu.asu.commons.foraging.model.ServerDataModel; +import edu.asu.commons.foraging.ui.Circle; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Utils; @@ -53,15 +54,18 @@ } private void processData2d(SavedRoundData savedRoundData, PrintWriter writer) { - // RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); + RoundConfiguration roundConfiguration = (RoundConfiguration) savedRoundData.getRoundParameters(); SortedSet<PersistableEvent> actions = savedRoundData.getActions(); - ServerDataModel model = (ServerDataModel) savedRoundData.getDataModel(); - Map<Identifier, ClientMovementTokenCount> clientMovementTokenCounts = ClientMovementTokenCount.createMap(model); -// List<GroupDataModel> groups = new ArrayList<GroupDataModel>(model.getGroups()); - Map<Identifier, ClientData> clientDataMap = model.getClientDataMap(); + ServerDataModel dataModel = (ServerDataModel) savedRoundData.getDataModel(); + Map<Identifier, ClientMovementTokenCount> clientMovementTokenCounts = ClientMovementTokenCount.createMap(dataModel); + Map<Identifier, ClientData> clientDataMap = dataModel.getClientDataMap(); + boolean restrictedVisibility = roundConfiguration.isSubjectsFieldOfVisionEnabled(); + int radius = roundConfiguration.getViewSubjectsRadius(); + dataModel.reinitialize(); for (PersistableEvent event: actions) { if (event instanceof MovementEvent) { MovementEvent movementEvent = (MovementEvent) event; + dataModel.apply(movementEvent); ClientData clientData = clientDataMap.get(event.getId()); ClientMovementTokenCount client = clientMovementTokenCounts.get(event.getId()); client.moves++; @@ -101,9 +105,26 @@ else if (event instanceof ChatRequest) { ChatRequest request = (ChatRequest) event; Identifier sourceId = request.getSource(); - Identifier targetId = request.getTarget(); + StringBuilder targetStringBuilder = new StringBuilder(); String message = request.toString(); - String line = String.format("%s, %s, %s, %s", savedRoundData.toSecondString(event), sourceId, targetId, message); + if (restrictedVisibility) { + ClientData clientData = clientDataMap.get(event.getId()); + GroupDataModel group = clientData.getGroupDataModel(); + Circle circle = new Circle(clientData.getPoint(), radius); + targetStringBuilder.append('['); + for (Map.Entry<Identifier, Point> entry: group.getClientPositions().entrySet()) { + Identifier id = entry.getKey(); + Point position = entry.getValue(); + if (circle.contains(position)) { + targetStringBuilder.append(id).append(','); + } + } + targetStringBuilder.setCharAt(targetStringBuilder.length() - 1, ']'); + } + else { + targetStringBuilder.append(request.getTarget()); + } + String line = String.format("%s, %s, %s, %s", savedRoundData.toSecondString(event), sourceId, targetStringBuilder.toString(), message); System.err.println(line); writer.println(line); } https://bitbucket.org/virtualcommons/foraging/changeset/3ad91de30e0e/ changeset: 3ad91de30e0e user: alllee date: 2012-02-27 06:32:09 summary: commentary affected #: 2 files diff -r 562c122bd77c3f71ed175a22b33ba947c5df4c35 -r 3ad91de30e0e6db2b91cac8144404b2b9d53c117 src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java @@ -177,6 +177,10 @@ return getBooleanProperty("subjects-field-of-vision", false); } + /** + * FIXME: rename for consistency, getSubjectsFieldOfVisionRadius() + * @return + */ public int getViewSubjectsRadius() { if (isSubjectsFieldOfVisionEnabled()) { return getIntProperty("view-subjects-radius", 6); diff -r 562c122bd77c3f71ed175a22b33ba947c5df4c35 -r 3ad91de30e0e6db2b91cac8144404b2b9d53c117 src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java --- a/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/model/ServerDataModel.java @@ -334,11 +334,6 @@ } } - /** - * Resets this server data model by performing the following: - * - * 1. Sets event channel to a no-op event channel. - */ public void setNullEventChannel() { super.channel = new EventTypeChannel() { public void handle(Event event) { } @@ -350,7 +345,15 @@ group.resetResourceDistribution(); } } - + /** + * Reinitializes this server data model in preparation for a replay by: + * <ol> + * <li> Sets event channel to a no-op event channel.</li> + * <li> resets all group resource distributions </li> + * <li> reinitializes all client positions </li> + * </ol> + * FIXME: may be safer to return a clone() instead? + */ public void reinitialize() { setNullEventChannel(); resetGroupResourceDistributions(); Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |