'=========================================================================== ' Subject: RANDOM WORD GENERATOR Date: 01-28-98 (10:22) ' Author: David A. Wicker Code: QB, QBasic, PDS ' Origin: pyramax@fastlane.net Packet: MISC.ABC '=========================================================================== DEFINT A-Z '$DYNAMIC ' Random Word Generator v0.1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ' Written by David A. Wicker ' pyramax@fastlane.net ' http://www.fastlane.net/~pyramax ' --------------------------------------------------------------------------- ' As always, if you borrow anything from any source code for your ' shareware projects, please give credit to the original author! ' --------------------------------------------------------------------------- ' DEFINT A-Z and '$DYNAMIC as the first two lines of every QBasic program ' ensure maximum speed and maximum memory capability. ' They are chiseled in every single program I write. DEF FNO$ (A$) = LEFT$(A$, 1) ' Easy way to pluck out the very first character in string A$ DEF FNC$ (A$, A) = MID$(A$, A, 1) ' Convenient way to pluck out a single character from string A$ DEF FNR (A) = INT(RND * A) + 1 RANDOMIZE TIMER ' RANDOMIZE TIMER is needed or the values would be the same every time it ' is run, which may or may not be desired. A$ = "VCCVVC" ' This defines how the random word will be generated. Suggested: ' VCVCV For a City's Name ' CVCCVC for a Monster ' CVVCVC for a Weapon ' CVCVVC for a Shield ' VCCVVC for a person's name ' Can you see how you can make a role-playing game that creates new worlds, ' weapons, armor, critters, talismans, tokens, devices, and NPC names each ' time using this method ? :) ' A real challenge would be to develop one that converts randomness to ' familiarity and a sense of order for a game without having to predetermine ' the development of a word or name. To further appreciate this, the ' system would also have to generate images and designs randomly with a ' sense of order as well. Lastly, it would intelligently generate ' random quests and events that challenge the player at a level comperable ' to the experience gained. In order for this to work fully correctly it ' would have to retain knowledge of everything that was generated before- ' hand so the player would have a sense of familiarity for the surroundings, ' images, and names of places, people, critters, and artifacts. L = LEN(A$) DO CLS OK = 0 DO FOR J = 1 TO L C$ = FNC$(A$, J) DO B$ = FNC$("bdfghjklmnprstvwyz", FNR(18)) IF C$ = "V" THEN B$ = FNC$("aeiou", FNR(5)) LOOP UNTIL INSTR(T$, B$) = 0 ' Check to see this letter has not yet been used for this random word. T$ = T$ + B$ NEXT IF POS(0) < 80 - L THEN PRINT UCASE$(FNO$(T$)) + MID$(T$, 2); PRINT " "; ' If we are not at far right edge of screen, continue printing to the ' right, otherwise drop down a line and repeat the process again. ELSE PRINT IF CSRLIN = 24 THEN OK = 1 ' Check for bottom of display, [ESC] will exit END IF T$ = "" LOOP UNTIL OK = 1 DO K$ = INKEY$ LOOP UNTIL K$ > "" ' no need to check for K$<>"" because it will never be ' =LESS= than nothing. :) LOOP UNTIL K$ = CHR$(27)