gfxgfxFreeBASIC Games Directory Forumgfxgfx
gfx gfx
gfx
Welcome, Guest. Please login or register. May 23, 2013, 07:58:27 PM

Login with username, password and session length
11.5.2013 - Added a webpage for the latest FBGD competition.

13.3.2013 - Members registrations temporary disabled. For all membership requests, please email me: lachie13@yahoo.com

30.11.2012 - The ninth issue of BASIC Gaming is out! Read it here: http://games.freebasic.net/forum/index.php?topic=560.0

22.11.2012 - Be sure to check our currently running annual FBGD game making competition. This year's theme is SEASONS OF THE YEAR, 300 $ first place prize, and the competition runs till 18th of February. Link: http://games.freebasic.net/forum/index.php?topic=559.0
gfx
gfx
*
gfxgfx
gfxgfx gfxgfx
gfxgfx Home Help Search Login Register   gfxgfx
gfx gfx
gfx
Pages: [1]
Print
Author Topic: Making a huge and complex adventure game that is tiny in size  (Read 2919 times)
RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« on: March 14, 2008, 06:48:15 PM »

About as many years ago as when people were using BASICA to write programs I started to make a game I called WOW or "World Of Wizards". It was a dungeon exploring game based on a similar thing available on PDP11 computers at the time called something like dungeon. Instead of just one dungeon with 16x16x16 rooms, this one had 1000 of these dungeons per city, 2000 cities per country, 3000 countries per world and 4000 worlds. All the dungeons are different and reproducible, there is nothing random in them. The program size was 11 KB in 1994. Yes, nearly 10^17 rooms in 11 KB and there is another feature that means that in each dungeon you can have a wizard who makes another 10^13 dungeons making 10^30 in total (unless you do the same in those).

What is unique about my game is a technique for making complex features that satisfy almost any desired criterion without having to store or make vast amounts of stuff. The game itself is not perhaps worth doing much with, although someone might want to take it up, converting it from BASICA and adding to it. But I thought that I would describe a bit about the method because that can be used in other games to have the same result of enormous detail with almost no memory usage. There are several elements.

The first is a shuffle algorithm that will take any power of 2 objects (n=2^i) and shuffle them in a controlled way using multiple parameters (in my case the world, country, city and dungeon numbers) to give a new order for each. So you can have things like 1 golden orb (or some special thing) in each dungeon which when a person finds it they know they have done that dungeon. The algorithm only works for powers of 2 objects, so the number of rooms each way has to be a power of 2. In effect, each room in the dungeon ends up with a number which is in the same range as the room numbers - in my case 16x16x16 = 4096 so each room has a result number in the range 0-4095 or 12 bits long.

However it would be boring if every dungeon had the same things just shuffled. So there needs to be a means to make variations on the theme also. That is achieved by using not just the resulting room number but ones from the adjacent rooms when more than 12 bits of information are needed. Because of the shuffling, the adjacent room numbers in any dungeon are different. That means that if the bit pattern for the best thing in the dungeon is all 1s in the room itself, you then go to x+1 room to find the bit pattern there to determine what that thing will be.

The openings between rooms (doors) are dealt with by having 1 bit from the 12 meaning :"door to E" and one for "door to S". So to find door to N or door to W you must look in the appropriate adjacent room. Stairs are more tricky as they need to have walls to be set against, so stairs only happen if both the N and W (from memory) walls do not have doors and the same is true in the room above (for stairs up) or below (for stairs down).

Then we use the other bits from the 12 bits to tell about features and creatures and treasures etc in that room. You can have a couple of bits to say 00=empty, 01=feature, 10=creature, 11=creature+treasure. The remaining bits then tell the type of creature (or feature or whatever) and the subtype, colour, size (within its type) etc. If toy need more than 12 bits, no problem, take the 12 bits from the next room in the x direction or whatever. This makes consistency within the one dungeon and difference from all others.

When a creature is killed and its treasure taken a bit is set corresponding to that room. This means that in future visiting that room results in a message about a dead monster and no additional treasure. That also means that only 512 bits are needed to describe the state of the dungeon plus the inventory of the adventurer.

Some of the features are maps and teleports. A map may be of the current level or another level of the same dungeon. Teleports take you to another room in the same dungeon consistently, so once you work out where you are again afterwards they can be a short cut. There is much more, but you get the idea.

My old BASICA program works and has save and restore and a lot of stuff, but I never finished doing all the magic items.

Back to the monsters, you would have genus dragon with subtypes gold, platinum, silver, bronze ... etc and each comes in sizes very large, large, (medium), small and baby. So there are many variations. The game was text only except for maps etc. However I also thought about how to generate creatures using the parameters to make 3D forms and the sizes and colours and variations would all affect the generation of the basic form (making them more stocky or more lanky etc). I even did some real animated flames for the dragon on a different computer back about 1980ish when I first wrote the program.

The shuffled numbers can also be used (or additional nearby ones) to determine the type of material, textures and colours of walls and other features, so that near infinite variety can be generated from almost nothing.

If anyone is interested let me know. I am happy to upload the old BASICA code and explain the shuffle algorithm and its use in generating things. I do believe that it is possible to make a fully animated fully textured and realistic 3D interactive game that is very rich in features with more dungeon rooms than particles in the real universe and still takes up somewhere between 100 KB and 1 MB.

Have fun
Ray

PS I posted this in the old (non games) forum already but now putting it here. I had problems getting into this forum as my email never comes when I join new sites - a great mystery. Anyway, I used a temporary email and so this account has an invalid email address.
« Last Edit: March 14, 2008, 06:54:32 PM by RTomes » Logged

Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #1 on: March 14, 2008, 07:02:28 PM »

This is really interesting.

Perhaps you should write an article about it for QBE, with some FB code.

Because without some code, I'm finding it difficult to comprehend this method.

As for forum registering problem, you should always check your spam/bulk folder when register to new forum. Anyway, I'm pretty sure you can change your email in the account options. If not, I can do that for you.


Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #2 on: March 14, 2008, 09:55:53 PM »

This is really interesting.

Perhaps you should write an article about it for QBE, with some FB code.

Because without some code, I'm finding it difficult to comprehend this method.

As for forum registering problem, you should always check your spam/bulk folder when register to new forum. Anyway, I'm pretty sure you can change your email in the account options. If not, I can do that for you.

The first thing I will do here is include my old program which is in BASICA because at least you can see what it does if you are really keen. See below. The key part of the idea is that given some numbers (world, country, city, dungeon) we can translate a room number (the one of the 16x16x16 rooms in the dungeon that we are in) to another number also in the range 0 to 4095 which will be unique in that dungeon. Because it is unique, we can decide exactly (or approximately if we want) how many of something we want in the dungeon. If we want 8 teleports then we can make that number being between 0 and 7 mean there is a teleport there. We don't know where these will be in a particular one of the dungeons but we know there will be 8 scattered through that dungeon. We do not need to store all the information about the 4000x3000x2000x1000 dungeons, or even about one of them, because each time we want to know about a room we just calculate its unique number and that tells us what is there.

I will explain a little of the code here. The variables NL, NI, NK, NJ are respectively the world, country, city and dungeon numbers. NR is the present room number calculated from the three space co-ordinates X, Y, Z as (Z*16+Y)*16+X+1 making a unique number in the range 0 to 4095. That is just a straight count of the rooms. Then the shuffled number is determined from the room number by a series of 4 shuffles. These shuffles us 4 fixed (for any dungeon) numbers derived from the world, country, city, dungeon as NA=NK : NB=2*NL+1 : NC=NJ : ND=2*NI+1 and you will see that two of them(NB and ND)  have been forced to being odd. The variable WM=4095 or 16 successive 1s in binary. This is the subroutine that starts with the room number in NR and ends up with the shuffled number. It does 4 shuffles based on the 4 location variables. A ripple, a twirl, a ripple and a twirl. It does these in an exact repeatable way that depends on the 4 location variables. It you think of a pack of cards, the ripple just proceeds tp put each card (room) in a spot n from the previous one which is a normal card ripple shuffle when n = 2. The twirl is much more amazing in its effect, as you place a card (room), then the next one 1 further on the follow 2 past that and then 3 past that and so on. When you run out the end of the numbers you just come back in the start. It so happens that this weird procedure results in every location being filled in a tidy manner and can be done with very simple maths. However if you look at the actual results of these operations you will find that the shuffle is a very effective one at mixing things up. And every dungeon is guaranteed different or your money back.  :-)

  R=NR+NA And WM : R=R*(R+1)/2 : R=R-Int(R/W)*W : R=R*NB
  R=R-INT(R/W)*W : R=R+NC AND WM : R=R*(R+1)/2 : R=R-INT(R/W)*W
  R=R*ND : R=R-INT(R/W)*W : RETURN

This is a very effective way to save writing a lot of code, to save having to make up maps, to supply huge variety, to make many types of variations of monsters while giving the player a reasonable description of them and many other innovations.

It can be used to create worlds with huge details of structure so that you could magnify the walls and see the atoms and have every dungeon have different details but the same dungeon always the same - without ever storing the data - just calculate easily on a need to use basis.

Regards
Ray

10 CLS : WO$="WORLDS of the WIZARDS" : J=14 : PRINT TAB(10);
20 REM        ---------------------
30 REM  RAY TOMES : Author and Inventer of the "TOMES SHUFFLE" and method of
40 REM  making almost infinite detail while hardly using any memory.
50 REM  MIKE TALER : Defender of monster rights and general cynic.
60 REM
110 FOR I=1 TO LEN(WO$) : COLOR J : PRINT " ";MID$(WO$,I,1); : J=J+1+(J>14)*7
120 NEXT I : COLOR 14 : PRINT : PRINT
130 PRINT "Once upon a time in a universe far away, the Wizards grew tired"
140 PRINT "of their world as they could so easily do anything they wanted."
150 PRINT "To amuse themselves they created a thousand worlds, each with"
160 PRINT "two thousand countries, each with three thousand cities, each"
170 PRINT "with four thousand dungeons, and it is said that every one is"
180 PRINT "different from every other. Each of these dungeons has 16 levels"
190 PRINT "with 16x16 rooms, and is filled with treasures and magic items"
200 PRINT "beyond your wildest dreams, and strange creatures beyond your"
210 PRINT "worst nightmares. Through a distortion in space and time caused"
220 PRINT "by these worlds, you have accidentally fallen into this universe."
230 PRINT "Fortunately, the place you have arrived at is the great meeting"
240 PRINT "of the pathways that lead to these worlds, and a young (273 years)"
250 PRINT "wizard is here to direct you to the world of your choice."
260 PRINT : GOSUB 300 : GOTO 400
300 PRINT "The wizard said that you can use the commands: n,e,w,s,u,d"
310 PRINT "which move north, east, west, south, up and down stairs."
320 PRINT "You can fight by the command f, save with v, quit with q,"
330 PRINT "give money with g, print maps with p, get an inventory with i,"
340 PRINT "and get this help information with h." : RETURN
400 DIM PP%(15,15),AF(3),AP(3),MO(3) : W=16^3 : WM=W-1
405 FOR I=0 TO 15 : FOR J=0 TO 15 : PP%(I,J)=0 : NEXT J : NEXT I
410 FOR I=0 TO 3 : AF(I)=2 : AP(I)=2 : MO(I)=0 : NEXT I
420 DIM CR$(9) : FOR I=9 TO 0 STEP -1 : READ CR$(I) : NEXT I
430 DIM SZ$(5) : FOR I=0 TO 5 : READ SZ$(I) : NEXT I
440 DIM TY$(23) : FOR I=0 TO 23 : READ TY$(I) : NEXT I
450 DIM FM$(3) : FOR I=0 TO 3 : READ FM$(I) : NEXT I
460 DIM TA(7,3) : FOR I=0 TO 7 : FOR J=0 TO 3 : READ TA(I,J) : NEXT J,I
470 DIM MO$(3) : FOR I=0 TO 3 : READ MO$(I) : NEXT I
480 DIM TR$(3) : FOR I=0 TO 3 : READ TR$(I) : NEXT I
490 DIM MI$(15),MQ%(15) : FOR I=0 TO 15 : READ MI$(I) : NEXT I
500 DIM HE$(8) : FOR I=0 TO 8 : READ HE$(I) : NEXT I
510 DIM MT$(3) : FOR I=1 TO 3 : READ MT$(I) : NEXT I
600 DATA 0008Dragon,0416Giant,0206Unicorn,1608Troll
610 DATA 1208Ogre,1408Troglodyte,1308Orc,1608Jackal
620 DATA 1804Rat,1008Spider
630 DATA 0.5Tiny,0.7Small,1.0,1.4Large,2.0Huge,2.8Enormous
640 DATA Platinum,Gold,Silver,Copper,White,Black,Blue,Green
650 DATA Yellow,Orange,Red,Purple,Brown,Grey,Spotted,Striped
660 DATA Hairy,Ugly,Smelly,Dirty,Unfriendly,Rabid,Maniacal,Deranged
670 DATA marble,stone,silver,steel
680 DATA 3,2,4,1, 3,4,1,2, 4,3,2,1, 2,3,1,4
685 DATA 4,1,3,2, 1,2,3,4, 2,1,4,3, 1,4,2,3
690 DATA copper,silver,gold,gems
700 DATA trapdoor,"stinking gas","falling rocks","horrid illusion"
710 DATA "10dungeon teleport","20level teleport","20room teleport"
720 DATA 30regeneration,30strength,30protection,"30teleport detection"
730 DATA "30trap detection","30wall passage",15levitation,10mapping
740 DATA "10dungeon id","10level id","20room id","90solid rock detection"
750 DATA "01diamond engagement"
760 DATA healthy,"",uncomfortable,painfull,agony,refreshed,"",tired,exhausted
770 DATA potion,scroll,ring
1000 PRINT : INPUT "He asks you what your name is";NA$
1005 INPUT "Are you restoring";A$ : IF A$="y" THEN 3800
1010 INPUT "Which world do you wish to visit";NL
1020 NL=INT(NL) : IF NL<1 OR NL>1000 GOTO 1010
1030 INPUT "Which country do you wish to visit";NI
1040 NI=INT(NI) : IF NI<1 OR NI>2000 GOTO 1030
1050 INPUT "Which city do you wish to visit";NK
1060 NK=INT(NK) : IF NK<1 OR NK>3000 GOTO 1050
1070 INPUT "Which dungeon do you wish to visit";NJ
1080 NJ=INT(NJ) : IF NJ<1 OR NJ>4000 GOTO 1070
1085 PRINT : PRINT NA$;" is entering the dungeon."
1090 Z=0 : Y=8 : X=8
1100 NA=NK : NB=2*NL+1 : NC=NJ : ND=2*NI+1 : ID=99
1110 REM was 1120 PRINT : PRINT NA$;" is entering the dungeon." : GOTO 1420
1130 GOTO 1420
1200 GOSUB 3600 : FI=0
1210 ID=I : ON I GOTO 1230,1250,1260,1270,1280,1240,1220
1220 PRINT NA$;" head butts the wall, OUCH!" : IF FI=0 THEN 1200 ELSE 2040
1230 IF NOT WW AND 16 THEN 1220 ELSE Z=Z-1 : GOTO 1400
1240 IF NOT WW AND 32 THEN 1220 ELSE Z=Z+1 : GOTO 1400
1250 IF WW AND 1 THEN 1220 ELSE Y=Y-1 : GOTO 1400
1260 IF WW AND 2 THEN 1220 ELSE X=X-1 : GOTO 1400
1270 IF WW AND 4 THEN 1220 ELSE X=X+1 : GOTO 1400
1280 IF WW AND 8 THEN 1220 ELSE Y=Y+1
1400 PRINT NA$;" goes ";K$
1410 AP(1)=AP(1)*.99+AF(1)*.01 : AP(3)=AP(3)*.99+AF(3)*.01
1420 NR=(Z*16+Y)*16+X+1 : GOSUB 3000 : RE=R
1430 NR=NR+15 : GOSUB 3000 : RS=R : NR=NR-16 : GOSUB 3000
1440 RA=INT(R/256) AND 15 : RW=RA AND 7 : RB=INT(R/16) AND 15 : RC=R AND 15
1450 WW=0 : IF RW<3 OR Y=0 THEN PRINT "wall to north, "; : WW=WW+1
1460 IF (RW>1 AND RW<5) OR X=0 THEN PRINT "wall to west, "; : WW=WW+2
1470 I=INT(RE/256) AND 7 : IF (I>1 AND I<5) OR X=15 THEN PRINT "wall to east, "; : WW=WW+4
1480 IF (INT(RS/256) AND 7)<3 OR Y=15 THEN PRINT "wall to south, "; : WW=WW+8
1490 IF RW<>2 THEN 1510 ELSE NR=NR+256 : GOSUB 3000 : RD=R : NR=NR-256
1500 IF (INT(RD/512) AND 3)=1 AND Z<15 THEN PRINT "stairs down, "; : WW=WW+32
1510 IF (RW AND 6)<>2 THEN 1530 ELSE NR=NR-256 : GOSUB 3000 : RU=R : NR=NR+256
1520 IF (INT(RU/256) AND 7)=2 AND Z>0 THEN PRINT "stairs up, "; : WW=WW+16
1530 IF RA=15 THEN ON INT(RB/4)+1 GOTO 2400,2600,2610,2620
1540 IF RA=0 THEN 1800
1550 PRINT : GOSUB 4600
1560 IF NOT J THEN AP(1)=AP(1)*.99+AF(1)*.01 : AP(3)=AP(3)*.99+AF(3)*.01
1590 GOTO 1200
1800 CS=Z+RB*2+RC-8 : CM=INT(CS/4) : CS=CS-CM*4+1
1810 IF CM<0 THEN CM=0 : CS=0 ELSE IF CM>9 THEN CM=9 : CS=5
1820 CF=VAL(LEFT$(SZ$(CS),3))*1.05^RC : CH=CF*2.1^(CM-3) : CD=CF*1.4^(CM-4)
1830 CA=VAL(LEFT$(CR$(CM),2))+INT(VAL(MID$(CR$(CM),3,2))*(15-RC)/16)
1840 CN$=MID$(SZ$(CS),4,20)+" "+TY$(CA)+" "+MID$(CR$(CM),5,20)
1850 CV=CH*CD*100 : I=2^Z : IF Z=15 THEN I=-I
1860 IF PP%(X,Y) AND I THEN PRINT CN$;"'s remains here." : GOTO 1200
1870 PRINT CN$;" here."
2000 GOSUB 3600 : GOSUB 4000 : FI=1 : DF=1
2010 IF ID+I=7 THEN 2030 ELSE IF I=7 THEN ID=99 : GOTO 2050
2020 IF P>.7 THEN 1210 ELSE DF=.7 : GOTO 2040
2030 IF P>.25 THEN 1210 ELSE DF=.5
2040 PRINT "you don't escape,"; : GOTO 2070
2050 J=AP(3)*P : AP(3)=AP(3)-.05*J : AF(3)=AF(3)+.02*J : CH=CH-J
2060 IF CH<0 THEN PRINT "you kill the ";CN$
2070 GOSUB 4000 : J=CD*P*DF : AP(1)=AP(1)-J : CD=CD-.05*J : AF(1)=AF(1)+.12*J
2080 IF AP(1)<0 THEN PRINT " the ";CN$;" kills you" : GOTO 4400
2090 IF AP(1)<AF(1)*.3 THEN PRINT " you are in pain"
2100 IF CH<0 THEN GOSUB 4600 : GOTO 2200
2110 GOSUB 4000 : IF P<.6 THEN PRINT " smash,"; ELSE PRINT " thud";
2115 GOSUB 4000 : IF P<.6 THEN PRINT " bang,"; : IF P<.3 THEN PRINT " hack,";
2120 PRINT " crash!" : GOTO 2000
2200 MM=INT(RB/2+Z/4-2) : MM=MM+MM*(MM<0)+(MM-4)*(MM>4)
2210 FOR I=MM TO 0 STEP -1 : IF I=4 THEN 2250
2220 J=INT(CV*(1-I*.1)/10^I)
2230 MO(I)=MO(I)+J : PRINT J;MO$(I); : CV=CV-J*10^I
2240 NEXT I : PRINT " taken." : GOTO 1200
2250 MP=0 : MS=0 : MR=0 : IF NOT RB AND 8 THEN 2275
2260 MC=15-RC : MV=VAL(LEFT$(MI$(MC),2))*(20-MC)*100 : IF MV>CV THEN 2275
2270 MT=3 : MN=100 : CV=CV-MV : GOSUB 4800
2275 IF NOT RB AND 4 THEN 2310
2280 MC=15-(RS AND 15) : MV=(20-MC)*150 : IF MV>CV THEN 2310
2290 MN=INT(CV/MV) : IF MN>3 THEN MN=INT(2+MN/3)
2300 MT=2 : CV=CV-MV*MN : GOSUB 4800
2310 IF NOT RB AND 2 THEN 2390
2320 MC=15-(RS/16 AND 15) : MV=(20-MC)*200 : IF MV>CV THEN 2390
2330 MT=1 : CV=CV-MV : MN=1 : GOSUB 4800
2390 GOTO 2240
2400 T=RB AND 3 : PRINT TR$(T); : GOSUB 4600 : IF J THEN PRINT " still";
2405 PRINT " here." : I=Z*.2+.8 : AP(1)=AP(1)-I
2410 IF T=0 AND Z<15 THEN PRINT "You fall down a level" : Z=Z+1
2420 IF AP(1)<0 THEN PRINT "The shock to your system is fatal" : GOTO 4400
2430 IF AP(1)<AF(1)*.4 THEN PRINT "You don't feel well"
2440 IF T=0 THEN 1420 ELSE 1200
2600 ON RB-3 GOTO 2630,2640,2700,2710
2610 T=RB AND 3 : PRINT FM$(T);" fountain here." : GOTO 2625
2620 T=RB AND 3 : PRINT FM$(T);" altar here."
2625 FA=RB-8 : WW=WW+64 : GOTO 1200
2630 Z=RC : GOTO 2660
2640 IF RC>0 OR RE>2999 OR RS>3999 THEN 2660 ELSE NK=RE+1 : NJ=RS+1
2650 NR=NR+2 : GOSUB 3000 : IF R<2000 THEN NI=R+1
2655 PRINT "teleport...." : GOTO 1090
2660 X=RE AND 15 : Y=RS AND 15 : PRINT "teleport ..." : GOTO 1420
2700 MZ=RC AND 15 : GOTO 2800
2710 MZ=Z
2800 PRINT "Level";MZ;"map here." : WW=WW+128 : GOTO 1200
3000 R=NR+NA AND WM : R=R*(R+1)/2 : R=R-INT(R/W)*W : R=R*NB
3010 R=R-INT(R/W)*W : R=R+NC AND WM : R=R*(R+1)/2 : R=R-INT(R/W)*W
3020 R=R*ND : R=R-INT(R/W)*W : RETURN
3200 INPUT "Print map on screen(s) or printer(p)";A$
3210 IF A$="p" THEN OPEN "O",#1,"prn" : GOTO 3230
3220 IF A$="s" THEN OPEN "O",#1,"con" ELSE RETURN
3230 PRINT #1,"World:";NL;" Country:";NI;" City:";NK;" Dungeon:";NJ;" Level:";MZ
3240 FOR MY=0 TO 15 : MA$="" : MB$="" : FOR MX=0 TO 15
3250 NR=(MZ*16+MY)*16+MX : GOSUB 3000 : RZ=INT(R/256) AND 15 : RW=RZ AND 7
3260 ME$="  " : IF RW<3 OR MY=0 THEN MA$=MA$+"+--" ELSE MA$=MA$+"+  "
3270 IF RZ=0 AND (R AND 128)=128 THEN ME$="Cr" : GOTO 3330
3280 IF RW<>2 THEN ME$=" " : GOTO 3300 ELSE NR=NR+256 : GOSUB 3000 : RD=R : NR=NR-256
3290 IF (INT(RD/512) AND 3)=1 AND MZ<15 THEN ME$="\" ELSE ME$=" "
3300 IF (RW AND 6)<>2 THEN ME$=" "+ME$ : GOTO 3320 ELSE NR=NR-256 : GOSUB 3000 : RU=R : NR=NR+256
3310 IF (INT(RU/256) AND 7)=2 AND MZ>0 THEN ME$="/"+ME$ ELSE ME$=" "+ME$
3320 IF RZ=15 THEN ME$=MID$("TrTrTeMaFoFoAlAl",(INT(R/32) AND 7)*2+1,2)
3330 IF (RW>1 AND RW<5) OR MX=0 THEN MB$=MB$+"|"+ME$ ELSE MB$=MB$+" "+ME$
3340 NEXT MX : PRINT #1,MA$;"+" : PRINT #1,MB$;"|" : NEXT MY
3350 FOR I=0 TO 15 : PRINT #1,"+--"; : NEXT I : PRINT #1,"+" : CLOSE #1
3360 PRINT : PRINT "Carry on ";NA$ : RETURN
3600 K$=INKEY$ : IF K$="" THEN 3600
3610 I=INSTR("unwesdfivqgph",K$) : IF I>0 THEN 3700 ELSE PRINT "Eh?" : GOTO 3600
3620 GOSUB 4200 : GOTO 3600
3640 PRINT "You have"; : FOR I=0 TO 3 : PRINT MO(I);MO$(I);","; : NEXT I : PRINT
3650 FOR MC=0 TO 15 : MT=0 : GOSUB 4900 : IF MR>0 THEN MT=3 : GOSUB 4850
3655 IF MS>0 THEN MT=2 : GOSUB 4850
3660 IF MP>0 THEN MT=1 : GOSUB 4850
3670 NEXT MC : PRINT : GOTO 3600
3680 IF WW AND 128 THEN GOSUB 3200 : GOTO 3600 ELSE 3600
3690 GOSUB 300 : GOTO 3600
3700 IF I<8 THEN RETURN ELSE ON I-7 GOTO 3640,3710,4410,3620,3680,3690
3710 INPUT "Your secret code (4 digits)";PW% : CLS
3720 OPEN "R",#1,LEFT$(NA$,8)+".chr",32 : FIELD #1, 32 AS F$
3725 NA$=LEFT$(NA$,14)
3730 FOR I=0 TO 15 : R$="" : FOR J=0 TO 15 : R$=R$+MKI$(PP%(I,J)) : NEXT J
3740 MID$(F$,1,32)=R$ : PUT #1 : NEXT I : R$=CHR$(LEN(NA$))+NA$
3750 FOR I=0 TO 3 : R$=R$+MKS$(AF(I))+MKS$(AP(I))+MKS$(MO(I)) : NEXT I
3755 MID$(F$,1,32)=LEFT$(R$,32) : PUT #1 : MID$(F$,1,32)=MID$(R$,33,32) : PUT #1
3760 MID$(F$,1,32)=MKS$(NL)+MKS$(NI)+MKS$(NK)+MKS$(NJ)+MKS$(Z)+MKS$(Y)+MKS$(X)+MKI$(PW%) : PUT #1 : R$=""
3765 FOR I=0 TO 15 : R$=R$+MKI$(MQ%(I)) : NEXT I : MID$(F$,1,32)=R$ : PUT #1
3770 CLOSE #1 : GOTO 1420
3800 INPUT "Your secret code (4 digits)";PW% : CLS
3810 OPEN "R",#1,LEFT$(NA$,8)+".chr",32 : FIELD #1, 32 AS F$
3815 NA$=LEFT$(NA$,14)
3820 FOR I=0 TO 15 : GET #1 : R$=F$ : FOR J=0 TO 15 : PP%(I,J)=CVI(R$)
3830 R$=MID$(R$,3,32) : NEXT J : NEXT I : GET #1 : R$=F$ : J%=ASC(R$)
3835 GET #1 : R$=R$+F$+"    "
3840 R$=MID$(R$,2+J%,64) : FOR I=0 TO 3 : AF(I)=CVS(MID$(R$,1,4)) : AP(I)=CVS(MID$(R$,5,4))
3850 MO(I)=CVS(MID$(R$,9,4)) : R$=MID$(R$,13,64) : NEXT I
3860 GET #1 : R$=F$ : NL=CVS(MID$(R$,1,4)) : NI=CVS(MID$(R$,5,4)) : NK=CVS(MID$(R$,9,4))
3870 NJ=CVS(MID$(R$,13,4)) : Z=CVS(MID$(R$,17,4)) : Y=CVS(MID$(R$,21,4))
3880 X=CVS(MID$(R$,25,4)) : I%=CVI(MID$(R$,29,2))
3885 GET #1 : FOR I=0 TO 15 : MQ%(I)=CVI(MID$(F$,I*2+1,2)) : NEXT I
3890 CLOSE #1 : IF I%=PW% THEN 1100 ELSE CLS : PRINT "NO NO" : RUN
4000 P=RND(1) : RETURN
4200 J=0 : FOR I=0 TO 3 : IF MO(I)<=0 THEN 4240
4210 PRINT "You have";MO(I);MO$(I);";"; : MG=0 : INPUT " give";MG
4220 IF MG>MO(I) OR MG<0 THEN 4210
4230 J=J+MG*10^I : MO(I)=MO(I)-MG
4240 NEXT I : IF J=0 OR NOT WW AND 64 THEN RETURN
4250 J=J/150/AF(1)^.5 : REM lopsided
4260 FOR I=0 TO 3 : AP(I)=AP(I)+J*TA(T,I) : IF AP(I)>AF(I) THEN AP(I)=AF(I)
4270 NEXT I : I=INT(5.75-AP(1)/AF(1)*5) : A$=HE$(I+(I-4)*(I>4))
4280 J=INT(9.8-AP(3)/AF(3)*4) : B$=HE$(J+(J-8)*(J>8)) : IF A$=B$ THEN RETURN
4290 K=(I-1)*(J-6) : IF K>0 THEN C$=B$+" and "+A$ : GOTO 4320
4300 IF K=0 THEN C$=A$+B$ : GOTO 4320
4310 IF I=0 THEN C$=A$+" but "+B$ ELSE C$=B$+" though "+A$
4320 PRINT "You feel ";C$;"." : RETURN
4400 PRINT "Goodbye ";NA$;"!" : INPUT "Another game";A$ : IF A$="y" THEN RUN
4410 SYSTEM : END
4600 I=2^Z : IF Z=15 THEN I=-I
4610 J=PP%(X,Y) AND I : PP%(X,Y)=PP%(X,Y) OR I : RETURN
4800 GOSUB 4850 : GOSUB 4900 : IF MR>127 THEN MR=MR-256
4810 MQ%(MC)=MR*256+MS*32+MP : RETURN
4850 PRINT MID$(MI$(MC),3);" ";MT$(MT);", "; : RETURN
4900 MP=(MQ%(MC) AND 7)-(MT=1)*MN : IF MP>7 THEN MP=7
4910 MS=(MQ%(MC)/8 AND 31)-(MT=2)*MN : IF MS>31 THEN MS=31
4920 MR=(MQ%(MC)/256 AND 255)-(MT=3)*MN : IF MR>254 THEN MR=254
4930 RETURN
« Last Edit: March 16, 2008, 05:05:49 AM by RTomes » Logged

RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #3 on: March 14, 2008, 10:05:58 PM »

Haha! A couple of smilies appeared in the code...
Line 500 should be H E $ ( 8 )  : F .....
Line 4280 should be ... ( J + ( J - 8 ) * ( J > 8 ) ) : ...
I stuck extra spaces in here hoping to stop the smiley converter.  :-)
Ray


OK I changed it to CODE now.
« Last Edit: March 16, 2008, 05:06:50 AM by RTomes » Logged

nkk_kan
Forum Howler
****
Gender: Male
Posts: 180

Let's rocK~!

nkk_kan
View Profile WWW Email
« Reply #4 on: March 15, 2008, 09:06:27 AM »

Welcome To the FBGD Forum ^_^, Ray!


Use the code button(Beside Quote button) instead of Quote button and that won't happen.. Tongue

PS : We also have an IRC channel for discussions and chat ^_^
       check this out! http://www.freebasic.net/forum/viewtopic.php?t=9796
Logged

Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #5 on: March 15, 2008, 07:20:11 PM »

This is fascinating stuff.

I need to think about a project where I might use this.

Well, there is this one...hmm.

I'll take a note of these posts.
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #6 on: March 16, 2008, 05:07:57 AM »

Welcome To the FBGD Forum ^_^, Ray!


Use the code button(Beside Quote button) instead of Quote button and that won't happen.. Tongue

PS : We also have an IRC channel for discussions and chat ^_^
       check this out! http://www.freebasic.net/forum/viewtopic.php?t=9796
Thanks for the welcome nkk_kan. I went back and changed it to code now.
Logged

Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #7 on: March 16, 2008, 02:38:55 PM »

Just noticed your account info. 60 and female?!?

That's....interesting.

Lachie winks

OMG, I need help. Tongue

BTW, I'm pretty sure you can change your email in the account options.
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #8 on: March 16, 2008, 10:25:41 PM »

Just noticed your account info. 60 and female?!?
...
BTW, I'm pretty sure you can change your email in the account options.
Oh dear, better get a sex change operation.

Yes, normally you can. However this is how it all came about...

I joined using name raytomes and my correct email address.
No email arrived .
(This happens for about 75% or all forums that I join ... love to know why)
Go and get a temporary email at one of those sites that allow that.
Join up to the forum with that email.
Try to change to real email address ....
Forum says, no you can't have that email, someone else already has it!
There is no way out of it from there.
:-)

OK, off for that sex op.
Logged

BadMrBox
Forum Sage
*****
Gender: Male
Posts: 371



View Profile WWW
« Reply #9 on: March 17, 2008, 08:45:37 AM »

That sounds strange Ray. Really strange. Maybe your mailaccount thinks of the notification as spam and discards it?
And the forum shouldn't have a hook-up on your real mail as it never was used to activate your account. Perhaps lachie could check the nonactivated accounts and erase the account you first tried to make. If it's not gone already. Meh, I dont know. Undecided

I am also a fan of Douglas Adams and Terry Pratchett. They are excellent. Oh, and I like your blogs Smiley
Logged

Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #10 on: March 17, 2008, 05:53:47 PM »

My bad. I forgot to check the inactivated accounts.

Anyway, that's fixed now. I changed the email in this account and also changed its name to RayTomes, as you originally wanted.

I also sent you an email regarding this to avoid confusion, but having in my your email provider... Tongue
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #11 on: March 17, 2008, 08:18:25 PM »

Thanks for comments BadMrBox and for kindly fixing all the confusing knots in the email and logins Lachie. Everything is sweet now.

Does anyone understand what my idea is about for making games with very little data but generating them all on the fly? This can save huge effort in making adventure games or any other sort that wants lots of terrain, lots of rooms, lots of anything spread about everywhere. In other words about 50% of all games or more.

Logged

BadMrBox
Forum Sage
*****
Gender: Male
Posts: 371



View Profile WWW
« Reply #12 on: March 18, 2008, 09:33:00 AM »

I understand and it's some clever stuff allright. Thought I have problems following the BASICA code.
Logged

RayTomes
Amoeba
*
Gender: Male
Posts: 9



View Profile WWW Email
« Reply #13 on: March 18, 2008, 07:40:39 PM »

I understand and it's some clever stuff allright. Thought I have problems following the BASICA code.

Thanks BadMrBox

The guts of it is in this little piece:
  R=NR+NA And WM : R=R*(R+1)/2 : R=R-Int(R/W)*W : R=R*NB
  R=R-INT(R/W)*W : R=R+NC AND WM : R=R*(R+1)/2 : R=R-INT(R/W)*W
  R=R*ND : R=R-INT(R/W)*W : RETURN
starting from the room number in NR and the 4 variables for the "world" which are used for the shuffle (NA, NB, NC, ND) it calculates the answer in R. The "AND" is a logical operator so that 0011 AND 0101 is 0001 for example.

Have fun
Ray
Logged

Dr_D
Forum Sage
*****
Gender: Male
Posts: 204


dr_davenstein
View Profile WWW Email
« Reply #14 on: March 22, 2008, 12:54:04 PM »

I wrote some code a while back that generates random dungeons and demonstrates some pathfinding. It would probably go well with what you're doing. I don't even know if you're interested in this kind of thing, but it's pretty useful in randomly generated games, so I thought I'd post it. Cheesy

You'll need to use -lang deprecated to compile it, but that could be easily changed.
http://copy-pasta.com/pasta2052
Logged

The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.

John Carmack
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Cerberus design by Bloc
Valid XHTML 1.0! Valid CSS!
gfx
gfxgfx gfxgfx