TheDcoder

A simple random number generator based on "Middle Square" method.

5 posts in this topic

#1 ·  Posted (edited)

Hello! :bye:

After watching a whole day of "Journey into cryptography" at Khan Academy, I have got to know the secrets behind some sneaky things! :P. This is one of em', A PRNG (Pseudo Random Number Generator). Its features (atleast what I believe) are:

  1. Simple, short and crappy.
  2. Great for beginners who are baffled by the mechanics of random number generation in computers!
  3. Support for custom seeds! :P
  4. EIGHT DIGITS OF RANDOMNESS!!! :shocked:
  5. Unlike all other PRNGs, This one is predictable :sorcerer:
  6. 1000 possible PRNs when using @MSEC as the seed.
  7. No option for min or max, the min is 10000000 and the max is 99999999.
  8. The Unlicensed 196px-PD-icon.svg.png.
#cs LICENSE
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
#ce LICENSE

; #FUNCTION# ====================================================================================================================
; Name ..........: MiddleSquareRandom
; Description ...: Pseudo-random number generator based on the infamous "Middle Sqaure" method.
; Syntax ........: MiddleSquareRandom([$iSeed = @MSEC])
; Parameters ....: $iSeed               - [optional] A seed for generation of the random number. Default is @MSEC.
; Return values .: A pseudorandom 8 digit integer.
; Author ........: John von Neumann
; Modified ......: Damon Harris (TheDcoder) - Conversion into AutoIt and simplification + further crappification.
; Remarks .......: Fun Fact - The output is based on the $iSeed passed, Same $iSeed = Same pseudo-random number.
; Related .......: Random()
; Link ..........: https://en.wikipedia.org/wiki/Middle-square_method
; Example .......: ConsoleWrite(MiddleSquareRandom() & @CRLF)
; ===============================================================================================================================
Func MiddleSquareRandom($iSeed = @MSEC)
    Local Const $TURNS = 8
    Local $sRandomNumber, $sSeed
    For $iTurn = 1 To $TURNS
        $iSeed = $iSeed * 2
        $sSeed = String($iSeed)
        $sRandomNumber &= StringMid($sSeed, Ceiling(StringLen($iSeed) / 2), 1)
    Next
    Return Int($sRandomNumber)
EndFunc

 

Enjoy your numbers, TD ;).

P.S NEVER USE THIS FUNCTION IN A REAL WORLD IMPLEMENTATION OF SOMETHING WHICH USES RANDOM NUMBERS!!! THIS ONE IS VERY UNSUITABLE FOR THAT PURPOSE! READ THE POSTS BELOW FOR MORE INFORMATION.

Edited by TheDcoder
Added P.S
1 person likes this

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That is flawed and terribly weak. Your algorithm isn't even midddle square but middle n*256.

Read up this botleg extract from TAOCP about PRNGs: https://vk.com/doc10903696_194276164?hash=1fc65ed563521b76e6&dl=ebca64d98d089930e0

BTW all serious PRNG are predictable in that there is nothing random in their code. This is even a requirement to assess anything about the algorithm. You'd have a fairly hard time to prove its pseudo-randomness usefulness: when you say it produces 8 random digits (here you mean pseudo-...) at each invokation, realize that this is a bold statement you just can't prove anyhow. Assertion #7 is also plain wrong.

#include <Array.au3>

Local $a[100]
For $i = 0 To UBound($a) - 1
    $a[$i] = MiddleSquareRandom($i)
Next
_ArrayDisplay(_Array1DToHistogram($a))

Func MiddleSquareRandom($iSeed = @MSEC)
    Local Const $TURNS = 8
    Local $sRandomNumber, $sSeed
    For $iTurn = 1 To $TURNS
        $iSeed = $iSeed * 2
        $sSeed = String($iSeed)
        $sRandomNumber &= StringMid($sSeed, Ceiling(StringLen($sSeed) / 2), 1)
    Next
    Return Int($sRandomNumber)
EndFunc

 

Edited by jchd
3 people like this

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Hmm... Yes, you are correct. That code is flawed and is not even middle square method... As I have expected, I am not good at this!

I will try to wrap my brain around this again, so expect a retouch to the code soon...


Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Please don't take this bad: I aint bashing you personally, just trying to put facts straight. Take the time to read from the link provided, you'll learn a lot!

Coming up with a robust PRNG is very hard and even brilliant professionnals have been bitten by their invention. Analyzing a PRNG for plausible randomness requires a very strong background in number theory and analysis. Proving anything in this area is utterly difficult and subtle. Cryptographically secure PRNGs are few and the exclusive domain of seasonned specialists.

My best advice is too rely only on methods proven correct (so far) by a large community of mathematicians, just like the implementation of Random() that AutoIt offers. I'm not saying that nobody is entitled to experiment new things, but please don't publish raw code as Example, along with bold, unproven or false statements. And submit your homebrew PRNG to a decent series of standard randomness tests before believing/claiming anything.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
1 minute ago, jchd said:

Please don't take this bad: I aint bashing you personally, just trying to put facts straight.

No worries :D, I always appreciate input no matter how its presented to me :).

3 minutes ago, jchd said:

Take the time to read from the link provided, you'll learn a lot!

Thanks for the link! but I am not really very serious about this implementation of a PRNG :(, I only did this as an exercise...

I know that this PRNG is highly unsuitable for any real world use... and I am not planning to make it a PRNG which can be used in Cryptographic operations!! I know that its VERY HARD :shocked:. I just submitted this piece of code for someone who is looking to get started.

I have decided to add a big red WARNING message near the code :).


Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


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

  • Similar Content

    • ZeroByDevide
      variables
      By ZeroByDevide
      i have this code running but it just would not start the code:
      Local $rndSleep = Int (Random(180000,240000,1000))
      MsgBox($MB_SYSTEMMODAL, "NaaaNuuu", "This message box will show the sleeptime after closing the tabs, you got " & $rndSleep & " seconds left.", $rndSleep)
       
      here is the error it shows me:
      "C:\Users\numan\Desktop\scipiie.au3" (23) : ==> Variable used without being declared.:
      MsgBox($MB_SYSTEMMODAL, "NaaaNuuu", "This message box will show the sleeptime after closing the tabs, you got " & $rndSleep & " seconds left.", $rndSleep)
      MsgBox(^ ERROR
    • Echbiahn
      Random Name Generator
      By Echbiahn
      Hi everyone!
      It's been a long time since I wrote anything in AutoIt, but I wanted to get back into it. Here's a simple UDF that generates random sword names to use in a game. Enjoy 
       
      ; #FUNCTION# ==================================================================================================================== ; Name...........: _GenSword ; Description ...: Generates random RPG sword names ; Parameters ....: $Type - The type of name to generate ; $Amount - [optional] value to be used for generating more names (default: 1) ; Return values .: Success - Return Value of the name generated or an array of names generated with index[0] = number of names ; Failure - Return Value 0, @error set to 1 ; Author ........: Echibahn ; Modified.......: ; Details .......: You can select one or multiple generator types by separating the types with a semi-colon. ; When selecting the amount of names to gen, the number reflects how many of a selected type will gen. This means ; selecting multiple types will generate the amount of names per type. ; Type 1 = Single Generator #1 ; Type 2 = Single Generator #2 ; Type 3 = Double Generator #1 ; Type 4 = Double Generator #2 ; Type 5 = Double Generator #3 ; Type 6 = Triple Generator #1 ; Type 7 = Triple Generator #2 ; ; Example .......; _GenSword(1) ; _GenSword("2;4") ; _GenSword("1;5;6", 2) ; _GenSword("1;2;3;4;5;6", 10) ; =============================================================================================================================== #include-once #include <Array.au3> Global $nm1[] = ["Shadowfang","Azurewrath","Assurance","ForgetMeNot","Red Obsidian","Abyssal Shard","Aetherius","Agatha","Alpha","Amnesia","Anduril","Anger’s Tear","Apocalypse","Armageddon","Arondite","Ashrune","Betrayal","Betrayer","Blackest Heart","Blackout","Blade of a Thousand Cuts","Blade of the Grave","Blazefury","Blazeguard","Blight's Plight","Blind Justice","Blinkstrike","Bloodquench","Bloodweep","Broken Promise","Brutality","Cataclysm","Catastrophe","Celeste","Chaos","Cometfell","Convergence","Corruption","Darkheart","Darkness","Dawn","Dawn of Ruins","Dawnbreaker","Deathbringer","Deathraze","Decimation","Desolation","Despair","Destiny's Song","Devine","Devourer","Dirge","Divine Light","Doomblade","Doombringer","Draughtbane","Due Diligence","Early Retirement","Echo","Piece Maker","Eclipse","Endbringer","Epilogue","Espada","Eternal Harmony","Eternal Rest","Extinction","Faithkeeper","Fallen Champion","Fate","Final Achievement","Fleshrender","Florance","Frenzy","Fury","Ghost Reaver","Ghostwalker","Gladius","Glimmer","Godslayer","Grasscutter","Grieving Blade","Gutrender","Hatred's Bite","Heartseeker","Heartstriker","Hell's Scream","Hellfire","Hellreaver","Hollow Silence","Honor's Call","Hope's End","Infamy","Interrogator","Justice","Justifier","King's Defender","King's Legacy","Kinslayer","Klinge","Knight's Fall","Knightfall","Lament","Last Rites","Last Words","Lazarus","Life's Limit","Lifedrinker","Light's Bane","Lightbane","Lightbringer","Lightning","Limbo","Loyalty","Malice","Mangler","Massacre","Mercy","Misery's End","Morbid Doom","Morbid Will","Mournblade","Narcoleptic","Needle","Nethersbane","Night's Edge","Night's Fall","Nightbane","Nightcrackle","Nightfall","Nirvana","Oathbreaker","Oathkeeper","Oblivion","Omega","Orenmir","Peacekeeper","Perfect Storm","Persuasion","Prick","Purifier","Rage","Ragespike","Ragnarok","Reaper","Reaper's Toll","Reckoning","Reign of Misery","Remorse","Requiem","Requiem of the Lost","Retirement","Righteous Might","Rigormortis","Savagery","Scalpel","Scar","Seethe","Severance","Shadow Strike","Shadowsteel","Silence","Silencer","Silver Saber","Silverlight","Skullcrusher","Slice of Life","Soul Reaper","Soulblade","Soulrapier","Spada","Spike","Spineripper","Spiteblade","Stalker","Starshatterer","Sting","Stinger","Storm","Storm Breaker","Stormbringer","Stormcaller","Storm-Weaver","Striker","Sun Strike","Suspension","Swan Song","The Ambassador","The Black Blade","The End","The Facelifter","The Light","The Oculus","The Stake","The Untamed","The Unyielding","The Void","Thorn","Thunder","Toothpick","Tranquility","Treachery","Trinity","Tyrhung","Unending Tyranny","Unholy Might","Valkyrie","Vanquisher","Vengeance","Venom","Venomshank","Warmonger","Widow Maker","Willbreaker","Winterthorn","Wit's End","Witherbrand","Wolf","Worldbreaker","Worldslayer"]; Global $nm2[] = ["Massive","Military","Amber Infused","Ancient","Anguish","Annihilation","Antique","Arcane","Arched","Assassination","Atuned","Oathkeeper's","Bandit's","Baneful","Banished","Barbarian","Barbaric","Battleworn","Blazefury","Blood Infused","Blood-Forged","Bloodcursed","Bloodied","Bloodlord's","Bloodsurge","Bloodvenom","Bone Crushing","Bonecarvin","Brutal","Brutality","Burnished","Captain's","Cataclysm","Cataclysmic","Cold-Forged","Corroded","Corrupted","Crazed","Crying","Cursed","Curved","Dancing","Decapitating","Defiled","Demonic","Deserted","Desire's","Desolation","Destiny's","Dire","Doom","Doom's","Dragon's","Dragonbreath","Ebon","Eerie","Enchanted","Engraved","Eternal","Executing","Exiled","Extinction","Faith's","Faithful","Fancy","Fearful","Feral","Fierce","Fiery","Fire Infused","Fireguard","Firesoul","Firestorm","Flaming","Flimsy","Forsaken","Fortune's","Fragile","Frail","Frenzied","Frost","Frozen","Furious","Fusion","Ghastly","Ghost-Forged","Ghostly","Gladiator","Gladiator's","Gleaming","Glinting","Greedy","Grieving","Guard's","Guardian's","Hailstorm","Hateful","Haunted","Heartless","Hollow","Holy","Honed","Honor's","Hope's","Hopeless","Howling","Hungering","Improved","Incarnated","Infused","Inherited","Isolated","Jade Infused","Judgement","Knightly","Legionnaire's","Liar's","Lich","Lightning","Lonely","Loyal","Lustful","Lusting","Mage's","Malevolent","Malicious","Malignant","Mended","Mercenary","Misfortune's","Misty","Moonlit","Mourning","Nightmare","Ominous","Peacekeeper","Phantom","Polished","Possessed","Pride's","Prideful","Primitive","Promised","Protector's","Deluded","Proud","Recruit's","Reforged","Reincarnated","Relentless","Remorseful","Renewed","Renovated","Replica","Restored","Retribution","Ritual","Roaring","Ruby Infused","Rune-Forged","Rusty","Sailor's","Sapphire Infused","Savage","Shadow","Sharpened","Silent","Singed","Singing","Sinister","Skullforge","Skyfall","Smooth","Solitude's","Sorrow's","Soul","Soul Infused","Soul-Forged","Soulcursed","Soulless","Spectral","Spectral-Forged","Spiteful","Storm","Storm-Forged","Stormfury","Stormguard","Terror","Thirsting","Thirsty","Thunder","Thunder-Forged","Thunderfury","Thunderguard","Thundersoul","Thunderstorm","Timeworn","Tormented","Trainee's","Treachery's","Twilight","Twilight's","Twisted","Tyrannical","Undead","Unholy","Vengeance","Vengeful","Venom","Vicious","Vindication","Vindictive","Void","Volcanic","Vowed","War-Forged","Warlord's","Warp","Warped","Whistling","Wicked","Wind's","Wind-Forged","Windsong","Woeful","Wrathful","Wretched","Yearning","Zealous"]; Global $nm3[] = ["Adamantite","Bronze","Copper","Diamond","Glass","Gold","Iron","Mithril","Obsidian","Silver","Skeletal","Steel"]; Global $nm4[] = ["Blade","Broadsword","Claymore","Defender","Deflector","Doomblade","Greatsword","Guardian","Katana","Longsword","Mageblade","Protector","Quickblade","Rapier","Reaver","Sabre","Scimitar","Shortsword","Slicer","Spellblade","Swiftblade","Sword","Warblade","Skewer","Carver","Etcher","Sculptor","Razor","Crusader"]; Global $nm5[] = ["Annihilation","Betrayer","Blade","Blessed Blade","Blood Blade","Bond","Boon","Breaker","Bringer","Broadsword","Butcher","Call","Carver","Champion","Claymore","Conqueror","Crusader","Cry","Cunning","Dark Blade","Dawn","Defender","Defiler","Deflector","Destroyer","Doomblade","Edge","Ender","Etcher","Executioner","Favor","Ferocity","Foe","Gift","Glory","Greatsword","Guardian","Heirloom","Hope","Incarnation","Jaws","Katana","Last Hope","Last Stand","Legacy","Longblade","Longsword","Mageblade","Memory","Might","Oath","Pact","Pledge","Promise","Protector","Quickblade","Rapier","Ravager","Razor","Reach","Reaper","Reaver","Runed Blade","Saber","Sabre","Savagery","Scimitar","Sculptor","Secret","Shortsword","Skewer","Slayer","Slicer","Soul","Spellblade","Spine","Swiftblade","Sword","Terror","Token","Tribute","Vengeance","Voice","Warblade","Warglaive","Whisper","Wit"]; Global $nm6[] = ["of Agony","of Ancient Power","of Anguish","of Ashes","of Assassins","of Black Magic","of Blessed Fortune","of Blessings","of Blight","of Blood","of Bloodlust","of Broken Bones","of Broken Dreams","of Broken Families","of Burdens","of Chaos","of Closing Eyes","of Conquered Worlds","of Corruption","of Cruelty","of Cunning","of Dark Magic","of Dark Souls","of Darkness","of Decay","of Deception","of Degradation","of Delusions","of Denial","of Desecration","of Diligence","of Dismay","of Dragonsouls","of Due Diligence","of Echoes","of Ended Dreams","of Ending Hope","of Ending Misery","of Eternal Bloodlust","of Eternal Damnation","of Eternal Glory","of Eternal Justice","of Eternal Rest","of Eternal Sorrow","of Eternal Struggles","of Eternity","of Executions","of Faded Memories","of Fallen Souls","of Fools","of Frost","of Frozen Hells","of Fury","of Giants","of Giantslaying","of Grace","of Grieving Widows","of Hate","of Hatred","of Hell's Games","of Hellish Torment","of Heroes","of Holy Might","of Honor","of Hope","of Horrid Dreams","of Horrors","of Illuminated Dreams","of Illumination","of Immortality","of Inception","of Infinite Trials","of Insanity","of Invocation","of Justice","of Light's Hope","of Lost Comrades","of Lost Hope","of Lost Voices","of Lost Worlds","of Magic","of Mercy","of Misery","of Mountains","of Mourning","of Mystery","of Necromancy","of Nightmares","of Oblivion","of Perdition","of Phantoms","of Power","of Pride","of Pride's Fall","of Putrefaction","of Reckoning","of Redemption","of Regret","of Riddles","of Secrecy","of Secrets","of Shadow Strikes","of Shadows","of Shifting Sands","of Shifting Worlds","of Silence","of Slaughter","of Souls","of Stealth","of Storms","of Subtlety","of Suffering","of Suffering's End","of Summoning","of Terror","of Thunder","of Time-Lost Memories","of Timeless Battles","of Titans","of Torment","of Traitors","of Trembling Hands","of Trials","of Truth","of Twilight's End","of Twisted Visions","of Unholy Blight","of Unholy Might","of Vengeance","of Visions","of Wasted Time","of Widows","of Wizardry","of Woe","of Wraiths","of Zeal","of the Ancients","of the Banished","of the Basilisk","of the Beast","of the Blessed","of the Breaking Storm","of the Brotherhood","of the Burning Sun","of the Caged Mind","of the Cataclysm","of the Champion","of the Claw","of the Corrupted","of the Covenant","of the Crown","of the Damned","of the Daywalker","of the Dead","of the Depth","of the Dreadlord","of the Earth","of the East","of the Emperor","of the Empty Void","of the End","of the Enigma","of the Fallen","of the Falling Sky","of the Flame","of the Forest","of the Forgotten","of the Forsaken","of the Gladiator","of the Harvest","of the Immortal","of the Incoming Storm","of the Insane","of the King","of the Lasting Night","of the Leviathan","of the Light","of the Lion","of the Lionheart","of the Lone Victor","of the Lone Wolf","of the Lost","of the Moon","of the Moonwalker","of the Night Sky","of the Night","of the Nightstalker","of the North","of the Occult","of the Oracle","of the Phoenix","of the Plague","of the Prince","of the Protector","of the Queen","of the Serpent","of the Setting Sun","of the Shadows","of the Sky","of the South","of the Stars","of the Storm","of the Summoner","of the Sun","of the Sunwalker","of the Talon","of the Undying","of the Victor","of the Void","of the West","of the Whispers","of the Wicked","of the Wind","of the Wolf","of the World","of the Wretched"]; Global $nm7[] = ["Aetherius","Agatha","Alpha","Amnesia","Anduril","Apocalypse","Armageddon","Arondite","Ashrune","Betrayal","Betrayer","Blackout","Blazefury","Blazeguard","Blinkstrike","Bloodquench","Bloodweep","Brutality","Celeste","Chaos","Cometfell","Convergence","Darkheart","Dawn","Dawnbreaker","Deathbringer","Deathraze","Decimation","Desolation","Destiny's Song","Dirge","Doomblade","Doombringer","Draughtbane","Due Diligence","Echo","Eclipse","Endbringer","Epilogue","Espada","Extinction","Faithkeeper","Fate","Fleshrender","Florance","Frenzy","Fury","Ghost Reaver","Ghostwalker","Gladius","Glimmer","Godslayer","Grasscutter","Gutrender","Hatred's Bite","Heartseeker","Heartstriker","Hell's Scream","Hellfire","Piece Maker","Hellreaver","Honor's Call","Hope's End","Infamy","Interrogator","Justifier","Kinslayer","Klinge","Knightfall","Lament","Lazarus","Lifedrinker","Light's Bane","Lightbane","Lightbringer","Lightning","Limbo","Loyalty","Malice","Mangler","Massacre","Mercy","Misery","Mournblade","Narcoleptic","Needle","Nethersbane","Night's Edge","Night's Fall","Nightbane","Nightcrackle","Nightfall","Nirvana","Oathbreaker","Oathkeeper","Oblivion","Omega","Orenmir","Peacekeeper","Persuasion","Prick","Purifier","Rage","Ragespike","Ragnarok","Reckoning","Reign","Remorse","Requiem","Retirement","Rigormortis","Savagery","Scalpel","Scar","Seethe","Severance","Shadow Strike","Shadowsteel","Silence","Silencer","Silver Saber","Silverlight","Skullcrusher","Slice of Life","Soul Reaper","Soulblade","Soulrapier","Spada","Spike","Spineripper","Spiteblade","Stalker","Starshatterer","Sting","Stinger","Storm","Storm Breaker","Stormbringer","Stormcaller","Story-Weaver","Striker","Sun Strike","Suspension","Swan Song","The Ambassador","The Black Blade","The End","The Facelifter","The Light","The Oculus","The Stake","The Untamed","The Unyielding","The Void","Thorn","Thunder","Toothpick","Tranquility","Treachery","Trinity","Tyrhung","Unending Tyranny","Unholy Might","Valkyrie","Vanquisher","Vengeance","Venom","Venomshank","Warmonger","Widow Maker","Willbreaker","Winterthorn","Wit's End","Witherbrand","Wolf","Worldbreaker","Worldslayer"]; MsgBox(0, "Name Gen", _GenSword(4)) $Gen = _GenSword("1;2;3;4;5;6;7", 3) _ArrayDisplay($Gen) Func _GenSword($Type, $Amount = 1) If StringInStr($Type, ";") Then;Run multiple $String = StringSplit($Type, ";") Local $Size = $String[0] * $Amount Dim $Name[$Size+1] $x = 1 $z = 1 $Name[0] = $Size While $x <= $String[0] $String[$x] = Int($String[$x]) Switch $String[$x] Case 1 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $Name[$z] = $nm1[$r1] If ($z + 1) <= $Size Then $z += 1 Next Case 2 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $Name[$z] = $nm7[$r7] If ($z + 1) <= $Size Then $z += 1 Next Case 3 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r4 = Floor(Random(0, UBound($nm4))) $Name[$z] = $nm2[$r2] & " " & $nm4[$r4] If ($z + 1) <= $Size Then $z += 1 Next Case 4 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $r6 = Floor(Random(0, UBound($nm6))) $Name[$z] = $nm1[$r1] & " " & $nm6[$r6] If ($z + 1) <= $Size Then $z += 1 Next Case 5 For $i = 1 To $Amount $r3 = Floor(Random(0, UBound($nm3))) $r5 = Floor(Random(0, UBound($nm5))) $Name[$z] = $nm3[$r3] & " " & $nm5[$r5] If ($z + 1) <= $Size Then $z += 1 Next Case 6 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r3 = Floor(Random(0, UBound($nm3))) $r4 = Floor(Random(0, UBound($nm4))) $Name[$z] = $nm2[$r2] & " " & $nm3[$r3] & " " & $nm4[$r4] If ($z + 1) <= $Size Then $z += 1 Next Case 7 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $r5 = Floor(Random(0, UBound($nm5))) $r6 = Floor(Random(0, UBound($nm6))) $Name[$z] = $nm7[$r7] & " " & $nm5[$r5] & " " & $nm6[$r6] If ($z + 1) <= $Size Then $z += 1 Next EndSwitch $x += 1 WEnd Return $Name ElseIf IsInt($Type) And $Type >= 1 And $Type <= 6 Then;Run Single Local $Name = "" Switch $Type Case 1 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $Name = $Name & $nm1[$r1] & @CRLF Next Case 2 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm1))) $Name = $Name & $nm7[$r7] & @CRLF Next Case 3 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r4 = Floor(Random(0, UBound($nm4))) $Name = $Name & $nm2[$r2] & " " & $nm4[$r4] & @CRLF Next Case 4 For $i = 1 To $Amount $r1 = Floor(Random(0, UBound($nm1))) $r6 = Floor(Random(0, UBound($nm6))) $Name = $Name & $nm1[$r1] & " " & $nm6[$r6] & @CRLF Next Case 5 For $i = 1 To $Amount $r3 = Floor(Random(0, UBound($nm3))) $r5 = Floor(Random(0, UBound($nm5))) $Name = $Name & $nm3[$r3] & " " & $nm5[$r5] & @CRLF Next Case 6 For $i = 1 To $Amount $r2 = Floor(Random(0, UBound($nm2))) $r3 = Floor(Random(0, UBound($nm3))) $r4 = Floor(Random(0, UBound($nm4))) $Name = $Name & $nm2[$r2] & " " & $nm3[$r3] & " " & $nm4[$r4] & @CRLF Next Case 7 For $i = 1 To $Amount $r7 = Floor(Random(0, UBound($nm7))) $r5 = Floor(Random(0, UBound($nm5))) $r6 = Floor(Random(0, UBound($nm6))) $Name = $Name & $nm7[$r7] & " " & $nm5[$r5] & " " & $nm6[$r6] & @CRLF Next EndSwitch Return $Name Else SetError(1) Return 0 EndIf EndFunc  
    • cookiemonster
      Shuffle string
      By cookiemonster
      Hoping for some guidance, I have a string like:
      $string='vXx2586578£&' How can I go abouts shuffling the contents of the string?
    • Katie_Deely
      Autoit and huge numbers
      By Katie_Deely
      Hey there
      I'm thinking about making a program that will calculate with huge numbers. Well above 1*10^18 probably. Can autoit deal with that? If not, how can I make it work?
      Thanks!
    • afallenhope
      Rocket League GOOAAL Rando Playback
      By afallenhope
      Hello all! In celebration of Rocket League supporting cross platform play with the XBone I wanted to finally create a script to accompany my game winning goals!
      Currently I have a switch where one button will play this soccer.mp3 while the other cuts the audio in case someone skips the replay during the game. I have a collection of mp3 files that I would like to use from "C:\Rocket" folder and I would like to play a random file from that directory so "C:\Rocket\*.mp3".
       
      I am having trouble understanding the random() function and hot to integrate it. Or would I need to create an array before being able to use the random function? Also for note I am trying to use about 20 mp3 files.
      #include <MsgBoxConstants.au3> Global $g_bPaused = False HotKeySet("{8}", "HotKeyPressed") HotKeySet("{5}", "HotKeyPressed") Func HotKeyPressed() Switch @HotKeyPressed Case "{8}" SoundPlay("") Case "{5}" SoundPlay("C:\Rocket\Soccer.mp3") EndSwitch EndFunc The recordings are newscasters similar to this. Thought that it would have been nice for this to have been in the game to begin with lol Thanks Everyone!