Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. const int numberOfUnitTypes = 8;
  2. const int numberOfRolls = 4;
  3.  
  4. function PopulateMarketplace()
  5. {
  6. <Clear marketplace>
  7. // Each integer in this array represents the stock of a particular kind of unit
  8. int unitCounts[numberOfUnitTypes] = {0, 0, 0, 0};
  9.  
  10. for(int i = 0; i < numberOfRolls; i++)
  11. {
  12. int roll = <random number between 0..numberOfUnitTypes>
  13. unitCounts[roll]++;
  14. }
  15.  
  16. int marketplaceIndex = 0;
  17. for(int i = 0; i < numberOfUnitTypes; i++)
  18. {
  19. if(unitCounts[i] != 0)
  20. {
  21. <Add unit to marketplace at position 'marketplaceIndex' with stock equal to 'unitCounts[i]'>
  22. marketplaceIndex++;
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement