• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re(2): Random number generator without duplicates? - RANDOM-ISH
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re(2): Random number generator without duplicates? - RANDOM-ISH


  • Subject: Re(2): Random number generator without duplicates? - RANDOM-ISH
  • From: "Arthur Cormack" <email@hidden>
  • Date: Wed, 18 Apr 2001 12:26:14 -0400

I can't believe how much controversy can arise over a simple semantic
issue.
without further adieu, i would like to introduce a new word that I
have become quite fond of: "randomish."

it' a versatile word, which I put to good use in a shockwave game
that I made recently: alphabet goop -
http://www.tvokids.com/thenook/alphabetgoop_game.html

I bring this up for two reasons. First to demonstrate the use of a
randomish guessing system. If you play it a few times, you will see
that there are no repeats of letters, or objects in a certain letter
category until, all other possible letters have been chosen, and all
other objects in a certain letter category have been picked.

Th second thing i wanted to point out is how similar appleScript is
to Director's Lingo (which this game was authored with)
I am wondering -
Do these two languages share a common origin? How many appleScripters
are also lingo coders?


Regards,


arthur cormack
_________________________
producer, interactive
the online group, TVOntario
W:416.484.2600.2010 C: 416.453.4369
E: email@hidden



If you are interested in seeing how similar the syntax is, look below
Here are the methods that alphabet goop uses to guess "randomishly":

-----------------------------------------------------------
on guessTwoNewLettersThatAreAvailable me
--New and Available

--only guess letters that have media in them
put "guessTwoLetters"
set thisLetterCandidateRoster = []
set inElligibleAlphabet = []
repeat with i = 1 to count(alphabetSet)
set thisLetterSet = getAt(alphabetSet, i)
if count(thisLetterSet.objectList) > 0 then
add(thisLetterCandidateRoster, getPropAt(alphabetSet, i) )
else
add(inElligibleAlphabet, getPropAt(alphabetSet, i))
end if
end repeat
--now check to see if they have loaded yet, or if they have been
solved
repeat with j = 1 to count(thisLetterCandidateRoster)
set thisCandidate = getAt(thisLetterCandidateRoster, j) --this is
a property
if thisCandidate.loadedYet = 0 or thisCandidate.solved = 1 then
deleteAt(thisLetterCandidateRoster, j)
end repeat

set thisDuo = []
--only guess letters that have media associated with them
--first test to see if there is a minimum of two letters that have
media, if not then send a message, complaining and exit
alphabetMediaCount = 0
repeat with k = 1 to count(alphabetSet)
set thisLetterSet = getAt(alphabetSet, k)
if count(thisLetterSet.objectList) > 0 then
alphabetMediaCount = alphabetMediaCount + 1
end if
end repeat
if alphabetMediaCount < 2 then
put "alphabetMediaCount < 2 ... so forget it."
exit
end if
set thisFirstGuessNum = random( count(thisLetterCandidateRoster) )
add(thisDuo, getAt(thisLetterCandidateRoster, thisFirstGuessNum) )
deleteAt(thisLetterCandidateRoster, thisFirstGuessNum)
set thisSecondGuessNum = random( count(thisLetterCandidateRoster) )
add(thisDuo, getAt(thisLetterCandidateRoster, thisSecondGuessNum) )
put "thisDuo ="&&thisDuo
return thisDuo


end


---and here are the methods that it uses to guess objects within a
letter category ...

on pickAnObject me, whichLetterCatagory
--
set eligibleObjects = []
set thisLetterSet = getProp(alphabetSet,
whichLetterCatagory).objectList
repeat with i = 1 to count(thisLetterSet)
set thisObject = getAt(thisLetterSet, i)
if thisObject.loadedYet = 1 then add(eligibleObjects,
getPropAt(thisLetterSet, i) )
end repeat
--next find out which objects in this eligibleObjects have the
lowest "solved" values
--first find the min value for solved
set thisMin = 10000
repeat with j = 1 to count(eligibleObjects)
set thisObjectName = getAt(eligibleObjects, j)
if getProp(thisLetterSet, thisObjectName).solved < thisMin then
set thisMin = getProp(thisLetterSet, thisObjectName).solved
end repeat
--next see what places that min value occurs at ...
set thisNewEligibleObjects = []
repeat with k = 1 to count(eligibleObjects)
set thisObjectName = getAt(eligibleObjects, k)
if getProp(thisLetterSet, thisObjectName).solved = thisMin then
add(thisNewEligibleObjects, thisObjectName)
end repeat
eligibleObjects = thisNewEligibleObjects
set thisGuessedObject = getAt(eligibleObjects, random(
count(eligibleObjects) ) )
return thisGuessedObject
end

on pickTwoObjects me, whichLetterCat
set eligibleObjects = []
set thisLetterSet = getProp(alphabetSet, whichLetterCat).objectList
repeat with i = 1 to count(thisLetterSet)
set thisObject = getAt(thisLetterSet, i)
if thisObject.loadedYet = 1 then add(eligibleObjects,
getPropAt(thisLetterSet, i) )
end repeat
--next find out which objects in this eligibleObjects have the
lowest "solved" values
--first find the min value for solved
set thisMin = 10000
repeat with j = 1 to count(eligibleObjects)
set thisObjectName = getAt(eligibleObjects, j)
if getProp(thisLetterSet, thisObjectName).solved < thisMin then
set thisMin = getProp(thisLetterSet, thisObjectName).solved
end repeat
--next see what places that min value occurs at ...
set thisNewEligibleObjects = []
repeat with k = 1 to count(eligibleObjects)
set thisObjectName = getAt(eligibleObjects, k)
if getProp(thisLetterSet, thisObjectName).solved = thisMin then
add(thisNewEligibleObjects, thisObjectName)
end repeat
eligibleObjects = thisNewEligibleObjects
set theseTwoObjects = []
set thisGuessedObjectPosition = random( count(eligibleObjects) )
set thisGuessedObject = getAt(eligibleObjects,
thisGuessedObjectPosition )
add(theseTwoObjects, thisGuessedObject)
deleteAt(eligibleObjects, thisGuessedObjectPosition)
set thisGuessedObjectPosition = random( count(eligibleObjects) )
set thisGuessedObject = getAt(eligibleObjects,
thisGuessedObjectPosition )
add(theseTwoObjects, thisGuessedObject)
return theseTwoObjects
end


References: 
 >Re: Random number generator without duplicates? (From: Doug McNutt <email@hidden>)

  • Prev by Date: Re: Random number generator without duplicates?
  • Next by Date: Simultaneous Folder Actions?
  • Previous by thread: Re: Random number generator without duplicates?
  • Next by thread: Re: Random number generator without duplicates?
  • Index(es):
    • Date
    • Thread