@Test public void testPlay() { Slush p1 = new Slush(new Slush.SlushParameters(120, 5, 7, 4.0 / 7.0, nb, nl)); p1.play(); }
void play() { String desc = ""; StatsHelper.StatsGetter stats = new StatsHelper.StatsGetter() { final List<String> fields = List.of("avg"); @Override public List<String> fields() { return fields; } @Override public StatsHelper.Stat get(List<? extends Node> liveNodes) { int[] colors = getDominantColor(liveNodes); System.out.println( "Colored nodes by the numbers: " + colors[0] + " remain uncolored " + colors[1] + " are red " + colors[2] + " are blue."); return StatsHelper.getStatsOn(liveNodes, n -> colors[((SlushNode) n).myColor]); } }; ProgressPerTime ppt = new ProgressPerTime( this, desc, "Number of y-Colored Nodes", stats, 10, null, 10, TimeUnit.MILLISECONDS); Predicate<Protocol> contIf = p1 -> { int[] colors; for (Node n : p1.network().allNodes) { SlushNode gn = (SlushNode) n; colors = getDominantColor(p1.network().allNodes); if ((gn.round < this.params.M && colors[1] != 100) || (gn.round < this.params.M && colors[2] != 100)) { return true; } } return false; }; ppt.run(contIf); }
Slush implements Protocol { void play() { String desc = ""; StatsHelper.StatsGetter stats = new StatsHelper.StatsGetter() { final List<String> fields = List.of("avg"); @Override public List<String> fields() { return fields; } @Override public StatsHelper.Stat get(List<? extends Node> liveNodes) { int[] colors = getDominantColor(liveNodes); System.out.println( "Colored nodes by the numbers: " + colors[0] + " remain uncolored " + colors[1] + " are red " + colors[2] + " are blue."); return StatsHelper.getStatsOn(liveNodes, n -> colors[((SlushNode) n).myColor]); } }; ProgressPerTime ppt = new ProgressPerTime( this, desc, "Number of y-Colored Nodes", stats, 10, null, 10, TimeUnit.MILLISECONDS); Predicate<Protocol> contIf = p1 -> { int[] colors; for (Node n : p1.network().allNodes) { SlushNode gn = (SlushNode) n; colors = getDominantColor(p1.network().allNodes); if ((gn.round < this.params.M && colors[1] != 100) || (gn.round < this.params.M && colors[2] != 100)) { return true; } } return false; }; ppt.run(contIf); } }
Slush implements Protocol { void play() { String desc = ""; StatsHelper.StatsGetter stats = new StatsHelper.StatsGetter() { final List<String> fields = List.of("avg"); @Override public List<String> fields() { return fields; } @Override public StatsHelper.Stat get(List<? extends Node> liveNodes) { int[] colors = getDominantColor(liveNodes); System.out.println( "Colored nodes by the numbers: " + colors[0] + " remain uncolored " + colors[1] + " are red " + colors[2] + " are blue."); return StatsHelper.getStatsOn(liveNodes, n -> colors[((SlushNode) n).myColor]); } }; ProgressPerTime ppt = new ProgressPerTime( this, desc, "Number of y-Colored Nodes", stats, 10, null, 10, TimeUnit.MILLISECONDS); Predicate<Protocol> contIf = p1 -> { int[] colors; for (Node n : p1.network().allNodes) { SlushNode gn = (SlushNode) n; colors = getDominantColor(p1.network().allNodes); if ((gn.round < this.params.M && colors[1] != 100) || (gn.round < this.params.M && colors[2] != 100)) { return true; } } return false; }; ppt.run(contIf); } Slush(SlushParameters params); }
Slush implements Protocol { void play() { String desc = ""; StatsHelper.StatsGetter stats = new StatsHelper.StatsGetter() { final List<String> fields = List.of("avg"); @Override public List<String> fields() { return fields; } @Override public StatsHelper.Stat get(List<? extends Node> liveNodes) { int[] colors = getDominantColor(liveNodes); System.out.println( "Colored nodes by the numbers: " + colors[0] + " remain uncolored " + colors[1] + " are red " + colors[2] + " are blue."); return StatsHelper.getStatsOn(liveNodes, n -> colors[((SlushNode) n).myColor]); } }; ProgressPerTime ppt = new ProgressPerTime( this, desc, "Number of y-Colored Nodes", stats, 10, null, 10, TimeUnit.MILLISECONDS); Predicate<Protocol> contIf = p1 -> { int[] colors; for (Node n : p1.network().allNodes) { SlushNode gn = (SlushNode) n; colors = getDominantColor(p1.network().allNodes); if ((gn.round < this.params.M && colors[1] != 100) || (gn.round < this.params.M && colors[2] != 100)) { return true; } } return false; }; ppt.run(contIf); } Slush(SlushParameters params); @Override void init(); @Override Network<SlushNode> network(); @Override Slush copy(); @Override String toString(); static void main(String... args); }
Slush implements Protocol { void play() { String desc = ""; StatsHelper.StatsGetter stats = new StatsHelper.StatsGetter() { final List<String> fields = List.of("avg"); @Override public List<String> fields() { return fields; } @Override public StatsHelper.Stat get(List<? extends Node> liveNodes) { int[] colors = getDominantColor(liveNodes); System.out.println( "Colored nodes by the numbers: " + colors[0] + " remain uncolored " + colors[1] + " are red " + colors[2] + " are blue."); return StatsHelper.getStatsOn(liveNodes, n -> colors[((SlushNode) n).myColor]); } }; ProgressPerTime ppt = new ProgressPerTime( this, desc, "Number of y-Colored Nodes", stats, 10, null, 10, TimeUnit.MILLISECONDS); Predicate<Protocol> contIf = p1 -> { int[] colors; for (Node n : p1.network().allNodes) { SlushNode gn = (SlushNode) n; colors = getDominantColor(p1.network().allNodes); if ((gn.round < this.params.M && colors[1] != 100) || (gn.round < this.params.M && colors[2] != 100)) { return true; } } return false; }; ppt.run(contIf); } Slush(SlushParameters params); @Override void init(); @Override Network<SlushNode> network(); @Override Slush copy(); @Override String toString(); static void main(String... args);  }