Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 07-28-2013, 08:00 PM   #1
Beta Member
Join Date: Jul 2013
Location: US
Posts: 2
Default Help With A Simple Program

Hello all!
I'm looking for help with a program that is presumably (I haven't enough programming experience to say with certainty) easy to write.

It will help me with a little game I'm working on. Basically, the premise is as follows:
I will provide a list of numbers.
The program must choose numbers from this list.
Each entry will have one number, from 1 to infinity, and another, explained below.
The lowest possible number (second number of an entry) will be 0.01. These numbers can be infinite and continuous (that is, .01, .02, .03 ... 10.00, 10.01 ... 699.99, 700.00, 700.01...)
Secondary numbers with higher values will be favored over numbers of lesser value.
Although greater values are favored, all values must have some probability of being chosen.

Basically, it's something like a lottery. An entry number comes in (say, 54) along with its value that is being judged (perhaps, 3.04). If 3.04 is among the highest values of all entries, and is chosen, the program should simply notify me that entry 54 has been chosen.

Hopefully I explained that with some clarity... Also, I'm not sure if it is proper for me to request a program as I am new to this forum.

As far as programming languages go, I haven't a preference except whatever would be the easiest for me to run.

Any questions, or if this thread needs to be moved, let me know!
Thanks! (irrelevant but humorous)

VictorEremita is offline   Reply With Quote
Old 07-29-2013, 01:30 AM   #2
In Runtime
Join Date: Feb 2013
Location: UK
Posts: 156
Default Re: Help With A Simple Program

A few general points to note with this:

1) You can't have an infinite list, as that would require infinite memory (or disk space depending on your implementation)
2) If you're saying that you will have a finite sized list but with values of infinite range - again this is not possible due to the maximum limit of 2^32 for unsigned integers on 32 bit machines and 2^64 on 64 bit machines (yes the latter is a very large number, but still not infinite). As for floating point / double precision numbers such as your 700.01 etc. these also have limited ranges.

I don't quite follow the premise of the lottery game described in your central paragraph so I can't provide much further detail at this stage. Essentially my only point thus far is be careful with terminology, programmers (rightly so) take specifications very literally and therefore requirements need to be carefully thought-out.

_michaelm is offline   Reply With Quote
Old 07-29-2013, 01:47 AM   #3
Daemon Poster
dale's Avatar
Join Date: Mar 2012
Location: Taiwan
Posts: 1,008
Default Re: Help With A Simple Program

What I've gathered so far:
  • Entry number assigned as serial integers, in increment of 1
  • Each entry is given a random value, down to two decimal places, from 0.01 to an undecided number
  • A comparison of value is used to determine the winner, the highest win -- what to do when values equal to each other is undecided
  • Winner is identified by his entry number

As for language, any language can do this really. You just need to decide on what to do with the undecided details mentioned above.
distrACT -- an open community
● It helps to ask questions effectively
● Please join Server admins social group if you are into servers
dale is offline   Reply With Quote
Old 07-29-2013, 07:41 PM   #4
Beta Member
Join Date: Jul 2013
Location: US
Posts: 2
Default Re: Help With A Simple Program

Unfortunately, upon further thought I have realized that there are some more factors that will need to be included in this script and I am not able to fully provide the necessary information at this point. Once I have worked out the additional components of the script I'll re-post (this may take some time).

Anyway, thanks for the replies!
VictorEremita is offline   Reply With Quote
Old 10-30-2013, 10:39 PM   #5
Solid State Member
Join Date: Oct 2013
Location: England, UK
Posts: 6
Default Re: Help With A Simple Program

Are you wanting a weighted random number generator? The simplest way I know to weight random numbers is to take two random numbers where the first result becomes the upper limit of the second. Like this: rnd(rnd(x))
Let x = 3 and the possible results are as follows: 0,0,0,0,1,1,1,2,2,3
Libervurto is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:39 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0