UE4 Tarray & Shuffle
http://api.unrealengine.com/KOR/Programming/UnrealArchitecture/TArrays/
https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
int32 Put00[] = { 1,2,3 };
int32 Put01[] = { 4,5,6 };
int32 Put02[] = { 7,8,9,10 };
int32 PutIDX[] = { 1,2,3 };
Shuffle(PutIDX, 3);
Shuffle(Put00, 3);
Shuffle(Put01, 3);
Shuffle(Put02, 3);
void AML_MainCtrl::Shuffle(int deck[], int len) {
int temp = 0;
int randomIdx = 0;
for (int i = 0; i < len; i++) {
randomIdx = rand() % len;
temp = deck[i];
deck[i] = deck[randomIdx];
deck[randomIdx] = temp;
}
}
https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
int32 Put00[] = { 1,2,3 };
int32 Put01[] = { 4,5,6 };
int32 Put02[] = { 7,8,9,10 };
int32 PutIDX[] = { 1,2,3 };
Shuffle(PutIDX, 3);
Shuffle(Put00, 3);
Shuffle(Put01, 3);
Shuffle(Put02, 3);
void AML_MainCtrl::Shuffle(int deck[], int len) {
int temp = 0;
int randomIdx = 0;
for (int i = 0; i < len; i++) {
randomIdx = rand() % len;
temp = deck[i];
deck[i] = deck[randomIdx];
deck[randomIdx] = temp;
}
}
댓글
댓글 쓰기