function [ cards, golden ] = createpack( trimult )
nrarities = 4;
packsize = 5;
odds = [0.7165, 0.2284, 0.0442, 0.0110];
godds = [0.0206, 0.0554, 0.0452, 0.0731];
ncards = [46, 33, 27, 17];
tricards = [3,3,0,3];
offset = [0,49, 85,112];
if nargin < 1
trimult = 3;
end
golden = zeros(packsize,1);
cards = zeros(packsize,1);
raritydraw = randsample(nrarities, packsize, true, odds);
for i = 1:packsize
r = raritydraw(i);
golden(i) = randsample(2,1,true,[1-godds(r), godds(r)]);
probs = [repmat(trimult,1,tricards(r)), ones(1,ncards(r))];
cards(i) = randsample(ncards(r)+tricards(r), 1, true, probs) + offset(r);
end
end
%CREATEPACK Creates a random pack according to simplified rules
% Not every pack is guaranteed one rare, but on average, the percentage of
% rares will be the same as in the game.
% Odds are compiled from http://hearthstone.gamepedia.com/Card_pack_statistics
%ncards are the number of cards of each rarity
%in the set. NOT including the tricards
%ntricards are the number of cards of each rarity of the tricard classes
%trimult is how much more likely tricards are than regular cards
%the output is a list of numbers saying which card it is.
%for example, if you have 10 commons and 5 rares, then the output could be
%[2,4,2,9,13], [0,0,0,1,0] which means you got 4 commons, one of which is
%golden, and a duplicate common, and one rare.
%the tricards come first, so if for example there were 2 common tricards,
%then the 2 would be a tricard, the 4 would not be
% Not every pack is guaranteed one rare, but on average, the percentage of
% rares will be the same as in the game.
% Odds are compiled from http://hearthstone.gamepedia.com/Card_pack_statistics
%ncards are the number of cards of each rarity
%in the set. NOT including the tricards
%ntricards are the number of cards of each rarity of the tricard classes
%trimult is how much more likely tricards are than regular cards
%the output is a list of numbers saying which card it is.
%for example, if you have 10 commons and 5 rares, then the output could be
%[2,4,2,9,13], [0,0,0,1,0] which means you got 4 commons, one of which is
%golden, and a duplicate common, and one rare.
%the tricards come first, so if for example there were 2 common tricards,
%then the 2 would be a tricard, the 4 would not be
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.