Jump to content

Which language will help be design this idea.

mitchpman13
Go to solution Solved by WanderingFool,

Just adding a bit onto what I said earlier...a prizes excel sheet would be easy.

Column A: List of PrizesColumn B: # of each item (e.g. A1: Gold B1: 10, A2: Coal B2: 5....Gold shows up 10/15 times and Coal shows up 5/15 times).  If you are more conformable with % then take a % and multiply by 100e.g. Gold at 50% = 5000Coal at 10.5% = 1050Diamond at 20.5% = 2050Topaz at 19% = 1900Column C:C1 =0C2 =B1+C1Use fill down in excel...ie just highlight from C2 down to C500 and click (ctrl-d) and it will autofill in for you.  Basically it is counting the amount of items there are up until that pointColumn D:D1 =SUM(B:B)-1Total values (-1 because later we will need a number between 0 and sum-1)Column E:E1 =RANDBETWEEN(0,D1)Picking the random item's numberColumn F:F1 =MATCH(E1,C:C)Match will keep looking for a number that is like this E1 >= CSo F1 now contains the index that will match a prizeColumn G:G1 =INDEX(A:A,F1)Display the prize

This should work (works on mine).  You should be able to easily copy and paste...and if you know a bit about excel, it should be easy to follow what is happening.  If you need any help (or just want me to give you the excel file, let me know)

Currently I'm playing on a small game and would like to design a type of lottery. I would have a list of players (200+), have 1 randomly selected. Then in a list of about 13+ different prizes, 1 selected, but the prizes have a different % of being selected. Such as a small prize would have a higher chance than a larger prize. (Ex: 1 gold has 50%, but 5 gold has 5%). I don't know much about computer languages but was wondering if I could try to learn one to make this possible.

 

This doesn't have to be added into the game. Just for me to see in cmd or whatever that player X won and they won prize X.

Link to comment
Share on other sites

Link to post
Share on other sites

you could use python

CM Storm Switch Tester MOD (In-Progress) - http://linustechtips.com/main/topic/409147-cm-storm-switch-tester-macro-mod/


       Ammo Can Speaker 02 (Completed) - http://linustechtips.com/main/topic/283826-ammo-can-speakers-02/       A/B Switch V 0.5 (Completed) - http://linustechtips.com/main/topic/362417-ab-switch-v0


     Build 01 - The Life of a Prodigy -  http://linustechtips.com/main/topic/13103-build-01-the-life-of-a-prodigy/             Build 02 - Silent Server 3000 - http://linustechtips.com/main/topic/116670-build-02-silent-server-3000/

Link to comment
Share on other sites

Link to post
Share on other sites

BASIC or Python 3

There are 10 types of people in this world, those who understand binary, and those who don't.

Link to comment
Share on other sites

Link to post
Share on other sites

Best language to design it would be English.. as for making it try Python..
Do some lessons on Codecademy and let us know how it goes.. http://www.codecademy.com

CPU: i7 4770k | GPU: Sapphire 290 Tri-X OC | RAM: Corsair Vengeance LP 2x8GB | MTB: GA-Z87X-UD5HCOOLER: Noctua NH-D14 | PSU: Corsair 760i | CASE: Corsair 550D | DISPLAY:  BenQ XL2420TE


Firestrike scores - Graphics: 10781 Physics: 9448 Combined: 4289


"Nvidia, Fuck you" - Linus Torvald

Link to comment
Share on other sites

Link to post
Share on other sites

You can probably use a variety of languages to make the game you are describing; especially if you are only requiring basic functionality in a terminal window. 

 

C++ has some great flexibility here when it comes to making games built around random numbers.  Take a look into that if you're interested, but a language like Python might be more friendly if you're very new to programming in general.

Link to comment
Share on other sites

Link to post
Share on other sites

Use python:

 

Here is your program in a nutshell if I understand it correctly...

 

You have a list of 100+ people, you need to randomly select one of them...

 

Then you need to randomly assign a prize to that person from an assortment of prizes each having a different chance to win...

 

So...

 

As a general idea of what you would want to do here ya go:

 

  • Store the names of the contestants in a file, each name on one line by itself, and only the name.
  • Read the file and store all of the names in an array (this is super easy in python)
  • Randomly generate a number less than the number of contestants (remember arrays are zero based...)
  • Choose the person in the array at the index equal to your randomly generated number.
  • Determine number ranges for your prizes that will represent their chance to win (i.e. gold = 1-50, 5 gold = 51-55, 10 gold = 56 - 65, etc... Overall range for all numbers should stay between 1-100 for percentages or the Lowest Common Multiple for raw probability)
  • Randomly generate an appropriate value (depends if using probability or percentages)
  • Grab the prize for the range the randomly generated value falls in.
  • Print the name of the randomly generated person with the randomly generated prize.

 

I understand you probably won't know what I was talking about with the quick design I gave for your program above... But hopefully once you learn a programming language (I strongly suggest python to start...) this will make a ton of sense :D

 

Also, here is a link for a fantastic python tutorial...

Link to comment
Share on other sites

Link to post
Share on other sites

Wut?

 

Either package offers database, presentation, and programming features that will greatly simplify the task. They are also much easier to learn, if not already known to the OP.

80+ ratings certify electrical efficiency. Not quality.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Either package offers database, presentation, and programming features that will greatly simplify the task. They are also much easier to learn, if not already known to the OP.

 

But that doesn't allow for any flexibility in the future, learning a real programming language like python would have far more long term benefit than something like Visual Basic inside Excel...

Link to comment
Share on other sites

Link to post
Share on other sites

But that doesn't allow for any flexibility in the future, learning a real programming language like python would have far more long term benefit than something like Visual Basic inside Excel...

 

Well then why don't you suggest assembler. After all it is the "real" programming language. /sarcasm

 

The entire point of a programming language is to facilitate the creation of correct solutions. For the problem described and the experience level of the asker, the fastest route to an error free solution is something like Excel. As to "flexibility", the suggestion that Excel is not sufficiently flexible indicates a real lack of appreciation for the capabilities of the product.

 

Besides which, the OP did not ask what would be a good language to learn. He/she asked for a language most suitable to solve a particular small problem.

 

You may disagree, but it is my opinion that Excel provides the UI, database, math, and logical functionality needed to rapidly and with little effort solve the problem posed.

80+ ratings certify electrical efficiency. Not quality.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Well then why don't you suggest assembler. After all it is the "real" programming language. /sarcasm

 

The entire point of a programming language is to facilitate the creation of correct solutions. For the problem described and the experience level of the asker, the fastest route to an error free solution is something like Excel. As to "flexibility", the suggestion that Excel is not sufficiently flexible indicates a real lack of appreciation for the capabilities of the product.

 

Besides which, the OP did not ask what would be a good language to learn. He/she asked for a language most suitable to solve a particular small problem.

 

You may disagree, but it is my opinion that Excel provides the UI, database, math, and logical functionality needed to rapidly and with little effort solve the problem posed.

 

There literally is the same amount of learning involved to do the program he is asking about in python and to do the visual basic... python is incredibly easy, incredibly user friendly, and learning an actual programming language rather than a macro environment will always be more beneficial...

Link to comment
Share on other sites

Link to post
Share on other sites

There literally is the same amount of learning involved to do the program he is asking about in python and to do the visual basic... python is incredibly easy, incredibly user friendly, and learning an actual programming language rather than a macro environment will always be more beneficial...

 

So you figure it's as easy and quick to write a UI to add, edit, remove & store several hundred names with associated data., collect, edit, remove, and store a list of prizes with their frequency, and perform a prize award periodically, with nicely formatted, printable, and sortable lists, etc. in Python?

 

As to what is beneficial. Learning a programming language is a good thing. But I'm willing to bet that more people get hired for their expertise using Excel than get hired to write in Python.

80+ ratings certify electrical efficiency. Not quality.

 

Link to comment
Share on other sites

Link to post
Share on other sites

There literally is the same amount of learning involved to do the program he is asking about in python and to do the visual basic... python is incredibly easy, incredibly user friendly, and learning an actual programming language rather than a macro environment will always be more beneficial...

I highly disagree...I am going to side with @brob on this one.  Excel is very visual in approaching the problem, and even someone with nearly 0 experience can understand what is happening....actually I will prove it by showing an bit of the answer in excel.

 

If you don't know much about programming excel is an excellent way to do what you are asking for @mitchpman13

 

In column A put in the names

B1 =COUNTA(A:A)

C1 =RANDBETWEEN(1,B1)

D1 =INDEX(A:A, C1)

 

D1 will now have a name in it (Hitting F9 will refresh the random number and thus pick a new person)

 

See to me this is by far easier than learning a language.  Although I do think it is important to learn programming languages, learning excel can save time.  While I know how to program, certain simple tasks are just quicker in excel...and opening up the excel page means you can easily add or remove people while not having to look at code or remembering how to format a text file.

 

Mitch if you still need help with the prizes I could do another example for excel....I still feel that excel is the easier method for someone who doesn't know languages...and it can come in handy in real life (not everyone will have compilers, but almost everyone has excel)

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

So you figure it's as easy and quick to write a UI to add, edit, remove & store several hundred names with associated data., collect, edit, remove, and store a list of prizes with their frequency, and perform a prize award periodically, with nicely formatted, printable, and sortable lists, etc. in Python?

 

As to what is beneficial. Learning a programming language is a good thing. But I'm willing to bet that more people get hired for their expertise using Excel than get hired to write in Python.

 

Not sure what it is with people and requiring a UI to do everything... and yes, text editors already allow the user to add, edit, remove, and store several hundred names and associated data...

 

As for formatting of outputs, no of course not... no dynamic/scripting language such as Python and Perl have ever represented data in a pleasing manner lol...

 

 

 

I don't know much about computer languages but was wondering if I could try to learn one to make this possible.

 

Excel is not a programming language... Python, Perl, Java, C, C++, etc... those are...

Link to comment
Share on other sites

Link to post
Share on other sites

Just adding a bit onto what I said earlier...a prizes excel sheet would be easy.

Column A: List of PrizesColumn B: # of each item (e.g. A1: Gold B1: 10, A2: Coal B2: 5....Gold shows up 10/15 times and Coal shows up 5/15 times).  If you are more conformable with % then take a % and multiply by 100e.g. Gold at 50% = 5000Coal at 10.5% = 1050Diamond at 20.5% = 2050Topaz at 19% = 1900Column C:C1 =0C2 =B1+C1Use fill down in excel...ie just highlight from C2 down to C500 and click (ctrl-d) and it will autofill in for you.  Basically it is counting the amount of items there are up until that pointColumn D:D1 =SUM(B:B)-1Total values (-1 because later we will need a number between 0 and sum-1)Column E:E1 =RANDBETWEEN(0,D1)Picking the random item's numberColumn F:F1 =MATCH(E1,C:C)Match will keep looking for a number that is like this E1 >= CSo F1 now contains the index that will match a prizeColumn G:G1 =INDEX(A:A,F1)Display the prize

This should work (works on mine).  You should be able to easily copy and paste...and if you know a bit about excel, it should be easy to follow what is happening.  If you need any help (or just want me to give you the excel file, let me know)

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Sorry been busy and almost forgot about the thread. Didn't think I'd get so many replies. :lol: I'll probably try to learn python incase anything like this would come up again. This worked perfecly for me. Thanks everyone for all the info.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×