• CHANGELOG.md
• Installing
• Versions
• 48

# shuffle #

A library that shows off shuffling decks of cards for visualization purposes.

## Usage #

A simple usage example:

``````import 'dart:math';

import 'package:shuffle/shuffle.dart';

main() {
ShuffleIteration noShuffle = (List<int> deck, Random r) {
return deck;
};

ShuffleIteration pickup = (List<int> deck, Random r) {
List<int> next = [];
for (int i = 0; i < 52; i++) {
}

return next;
};

ShuffleIteration overhand = (List<int> deck, Random r) {
// number of cards left in hand before shuffle ends
int threshold = 5;
int length = 52;
int split = (length / 2).floor() + r.nextInt(10);

while (length > threshold) {
List<int> list1 = deck.sublist(0, split);
List<int> list2 = deck.sublist(split, length);

deck.setRange(0, length, list2 + list1);
length = split;
split = (length / 2).floor() + r.nextInt((length / 5).ceil());
}
return deck;
};

ShuffleIteration ruffle = (List<int> deck, Random r) {
int length = 52;
int split = (length / 2).floor() + r.nextInt(2);

int i1 = 0;
int i2 = split;

List<int> temp = [];

while (i2 < 52 || i1 < split) {
int stand = r.nextInt(3) + 1;
if (i1 + stand < split) {
temp += deck.sublist(i1, i1 + stand);
i1 += stand;
} else if (i1 < split) {
temp += deck.sublist(i1, split);
i1 = split;
} else {
temp += deck.sublist(i2, 52);
i2 = 52;
}

stand = r.nextInt(3) + 1;

if (i2 + stand < 52) {
temp += deck.sublist(i2, i2 + stand);
i2 += stand;
} else if (i2 < 52) {
temp += deck.sublist(i2, 52);
i2 = 52;
} else {
temp += deck.sublist(i1, split);
i1 = split;
}
}
return temp;
};

int decks = 100;

Map<String, List<ShuffleStrategy>> shuffles = {
"Initial Deck": [ShuffleStrategy(1, noShuffle)],
"Random": [
ShuffleStrategy(1, pickup),
ShuffleStrategy(3, pickup),
ShuffleStrategy(6, pickup),
],
"Overhand": [
ShuffleStrategy(1, overhand),
ShuffleStrategy(3, overhand),
ShuffleStrategy(6, overhand),
ShuffleStrategy(10, overhand),
],
"Ruffle": [
ShuffleStrategy(1, ruffle),
ShuffleStrategy(3, ruffle),
ShuffleStrategy(6, ruffle),
ShuffleStrategy(10, ruffle),
],
};

for (MapEntry<String, List<ShuffleStrategy>> e in shuffles.entries) {
String name = e.key;
List<ShuffleStrategy> list = e.value;

for (ShuffleStrategy strategy in list) {
for(int i=0; i < decks; i++){
print(
"\$name, \${strategy.iterations}: \${Deck.defaultDeck(i)..shuffle(strategy)}");
}
}
}
}
``````

## Features and bugs #

Please file feature requests and bugs at the issue tracker.

## 1.0.0 #

• Initial version, created by Stagehand

## Use this package as a library

### 1. Depend on it

``````
dependencies:
toaster_shuffle: ^1.0.1

``````

### 2. Install it

You can install packages from the command line:

with pub:

``````
\$ pub get

``````

with Flutter:

``````
\$ flutter packages get

``````

Alternatively, your editor might support `pub get` or `flutter packages get`. Check the docs for your editor to learn more.

### 3. Import it

Now in your Dart code, you can use:

``````
import 'package:toaster_shuffle/shuffle.dart';
``````
1.0.1 Aug 3, 2018
1.0.0 Aug 3, 2018
 Popularity: Describes how popular the package is relative to other packages. [more] 0 Health: Code health derived from static analysis. [more] 100 Maintenance: Reflects how tidy and up-to-date the package is. [more] 92 Overall: Weighted score of the above. [more] 48

We analyzed this package on Apr 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

• Dart: 2.2.0
• pana: 0.12.14

#### Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

#### Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the `description` field of `pubspec.yaml`. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's `example/` directory matches known example patterns.

Common filename patterns include `main.dart`, `example.dart`, and `toaster_shuffle.dart`. Packages with multiple examples should provide `example/README.md`.