File tree Expand file tree Collapse file tree 1 file changed +5
-27
lines changed Expand file tree Collapse file tree 1 file changed +5
-27
lines changed Original file line number Diff line number Diff line change @@ -363,42 +363,20 @@ void run_hand(ArrayList<Deck_Card> hand) {
363363 if (this .equation .evaluate (hand )) {
364364 this .count .incrementAndGet ();
365365 }
366+ reset_hand (hand );
366367 }
367368 }
368369
369370 final List <ScenarioCount > forestCount = FOREST .stream ().map (ScenarioCount ::new ).collect (Collectors .toList ());
370-
371- /*
372- Minimalist Strategy
373- Only create a single thread for each drawn hand, and have each hand test all scenarios
374- */
375- class HandGenerator implements Supplier <ArrayList <Deck_Card >> {
376- @ Override
377- public ArrayList <Deck_Card > get () {
378- synchronized (DECK ) {
379- return Deck_Card .deep_copy (draw_hand (HAND_SIZE , DECK ));
380- }
381- }
382- }
383-
384- class HandTester implements Consumer <ArrayList <Deck_Card >> {
385- @ Override
386- public void accept (ArrayList <Deck_Card > hand ) {
387- for (ScenarioCount sc : forestCount ) {
388- sc .run_hand (hand );
389- reset_hand (hand );
390- }
391- }
392- }
393-
394-
395371 final long START_TIME ; //simulation start time in milliseconds
396372
397373 synchronized (Simulation .PARALLEL_SIMULATION_LOCK ) {
398374 START_TIME = System .currentTimeMillis ();
399375
400- Stream <ArrayList <Deck_Card >> random_hands = Stream .generate (new HandGenerator ());
401- random_hands .parallel ().limit (TEST_HAND_COUNT ).forEach (new HandTester ());
376+ Stream .generate (() -> Deck_Card .deep_copy (draw_hand (HAND_SIZE , DECK )))
377+ .parallel ()
378+ .limit (TEST_HAND_COUNT )
379+ .forEach (hand -> forestCount .forEach (fc -> fc .run_hand (hand )));
402380
403381 AtomicInteger [] HITS = forestCount .stream ().map (a -> a .count ).toArray (AtomicInteger []::new );
404382
You can’t perform that action at this time.
0 commit comments