Jump to content
IGNORED

Need some XB help


Sinphaltimus

Recommended Posts

Best thing to do with TIdBiT is just open a fresh Notepad++ document, write a small program like I did above, or even simpler! Then paste it into the TIdBiT website and hit translate. Copy and paste into Classic99 and watch the fun.

 

It helps keep code structured, because you do not have line numbers to keep up with.

Link to comment
Share on other sites

  • 2 weeks later...

Is there a way in extended basic to create variables on the fly?

 

What I want to do.

 

If a zombie gets created then take the variable zhealth and make it zhealth+sprite number. (Sprite number is unknown until a zombie is randomly chosen and created) for instance:

 

Determine loot for sprite number 10, not a zombie, move on.

Determine loot for sprite number 11, it is a zombie, creat variable zhealth11.

zhealth11=10. Move on.

Determine loot for sprite numbers 12-20, none if them end up being zombies. Move on

Determine loot for sprite number 21. It is a zombie, create variable zhealth21.

zhealth21=10. Move on, etc...

 

I can certainly get creative using arrays and predetermine/define zhealth10-23 (all possible sprite numbers for any given zed without repeating) but I'm looking for a short cut.

Edited by Sinphaltimus
Link to comment
Share on other sites

I think arrays are probably your only option there... variables exist for the lifetime of the program in BASIC and XB, excluding those in subprograms (even there I'm not sure). That's one of the purposes of the prescan, to find and allocate all the variables the program uses. :)

 

Strings are dynamically allocated, but I don't think they'll help your case much, and frequent updates to strings will cause a lot of garbage collection that will slow you down anyway.

  • Like 2
Link to comment
Share on other sites

I was afraid of this but that's ok. I'm a wishful thinker. Thanks for this. After moving to TidBit (What took me so long?!?) I'm able to develop much faster and more efficiently. Right now I'm pretty much reorganizing and crunching things further. I think, with enough thought, I can utilize my existing array and just expand on it by 2 fields in the second dim.

Edited by Sinphaltimus
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

This is where my lack of programming and math skills really hurts.

I need XB code. I know its wordy, I just want everyone to understand what I'm trying to do here as best I as I can describe it.

Here's what I'm setting up and what I need to do with these numbers.

1. 100 boards (levels), starting at 99 decrementing to 0.

2. At level 99 I need there to be a 70 percent chance for a heart to spawn, a 10 percent chance for a Zombie to spawn, 10 percent for melee weapon, 10 percent for ranged weapon.

3. At level 50 it should be at 25 percentile for each loot item (Heart, Zed, Melee ,Ranged)

4. at level 0 it should be 10 percent chance for everything except Zombies which will now be 70 percent chance.

I need those numbers from level 99 through level 0 to adjust each level a player progresses.

I imagine there is some math that could do it since its pretty uniform.

Right now there is an equal chance for any loot to spawn (25/25/25/25) on each of the 14 spawn locations.

I do this with a random integer from 1 to 4. if =1 then hear, 2 then zombie etc..

I was thinking of doing something like this.

The random number chosen for each spawn location is a number from 1 to 100.
Each piece of loot has an upper and lower limit as far as the 1 to 100 range they occupy.

For instance, at level 99
a random number between 1 and 70 is for heart.

the same random number if it is between 71 and 80 means zombie.

81-90 = ranged and finally 91-100 for ranged.

At level 49

1-25 heart, 26-50 zed, 51-75 melee, 76-100 ranged.

 

level 0

1-10 heart, 11-80 zed, 81-90 melee, 91-100 ranged.

 

I was going to try

variables such like HCL = Heart change low, HCH = Heart chance high, ZCL = zombie chance high, etc.....

So that each time a Board decrements, these variable would get adjusted accordingly and the chances for each kind of loot would adjust automatically as levels progress.

Perhaps I'm approaching incorrectly, I don't know.

I have no idea how to accomplish this using some sort of algorithm that could easily replace this thought process. I can't accomplish this task in less than a million lines of code, but I'd love to be able to do it in less than 5 and for that, I'm lost and clueless.

Can any of you help me figure this out?

 

Another thought:

I figure moving zombies to the final percentile place makes more sense since the numbers can then be shifted symmetrically.

So that

level 99 = 1-70 heart, 71-80 melee, 81-90 ranged, 91-100 zombie

levels 98 thru 49 = ???heart, ??? melee, ??? ranged, ??? zombie

level 49 - 1-25 heart, 26-50 melee, 51-75 ranged, 76-100 zombie

levels 50 thru 1 = ???heart, ??? melee, ??? ranged, ??? zombie

level 0 = 1-10 heart, 11-20 melee, 21-30 ranged, 31-100 zombie (mirror of level 99)

Help. :/

Link to comment
Share on other sites

1. 100 boards (levels), starting at 99 decrementing to 0.

2. At level 99 I need there to be a 70 percent chance for a heart to spawn, a 10 percent chance for a Zombie to spawn, 10 percent for melee weapon, 10 percent for ranged weapon.

3. At level 50 it should be at 25 percentile for each loot item (Heart, Zed, Melee ,Ranged)

4. at level 0 it should be 10 percent chance for everything except Zombies which will now be 70 percent chance.

 

No worries, this can be figured out. As a tip, Microsoft Excel can come in very useful for testing out different mathematical formulas. I used that to create the experience formula for Wizard's doom so that it would slowly increase your skill as experience points increased.

 

One problem... Your heart spawn rate makes sense... 70 at 99, 25 at 50, 10 at 0. But the weapons don't, they start at 10, increase to 25, then go back down to 10?

 

I'd suggest that you simplify your approach. Zombies and Hearts are basically mirroring each other; if one is 70% the other is 10%. So all you need is a single formula to calculates one and then determines the other through subtraction from 80%. Leave weapons at 10% each for simplicity.

 

A very simple formula I just came up with on the fly:

 

Heart = MAX(10,INT(Level*0.71))

Zombie = 80-Heart

Link to comment
Share on other sites

I will be experimenting with this. For XB, are there any other debuggers or tools available besides break and trace? I'd hate to have to setup another array to track variables for debugging. I am developing in emulation but the debugger for classic 99 is too low level for me.

Link to comment
Share on other sites

There isn't any advanced diagnostics for XB, not the native version anyway.

 

I know your pain; I've had to write in extra DISPLAY AT or HCHAR calls into my code to see what variable values are at critical moments to help me hunt down problematic bugs.

Yep, that's pretty much what I do now.

Link to comment
Share on other sites

When I had two systems side by side, I used to dump variables and other data (i.e., line number) out to the RS232 port so that I could see what was going on without interrupting the main screen. Once the RS232 port was opened, I would print to the port via a SUBprogram or GOSUB, depending on what I was debugging. A slower baud rate introduced transmission delays,which sometimes helped trace the issue more easily.

  • Like 1
Link to comment
Share on other sites

Easiest way to tail on Windows is to just use the GnuWin32 utilities and run tail. ;) Unfortunately, it won't work - Classic99 won't flush the file to disk until it's closed. Open/write/close would work but be really slow. :)

Ah, shucks... It looks like you are equally efficient in "CLIP" as well... meaning it contains nothing until a close occurs.

 

-M@

Link to comment
Share on other sites

In regards to Post #58, this is what I came up with...



New Code:

 

 

 

_LDS:
IF BOARD<=49 THEN LDSV=LDSV+1 ELSE LDSV=LDSV-1
SIDEZ=-40
FOR REPT=1 TO 2
LDSN=INT(RND*100)+1
IF LDSN>LDSV THEN _MR
_HZL:
LDSN=INT(RND*100)+1
IF LDSN>BOARD THEN _DOZED
_DOHART:
CALL SPRITE(#SLOT,88,7,GRND-9,((HLE+1)* 8)+SIDEZ):: SLOT=SLOT+1
LO0T(LAB,LTN)=88 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
GOTO _NEXLDS
_DOZED:
CALL SPRITE(#SLOT,96,4,GRND-9,((HLE+1)* 8)+SIDEZ):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=96 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1
GOTO _NEXLDS
_MR:
LDSN=INT(RND*100)+1
IF LDSN>LDSV THEN _DORAN
_DOMEL:
CALL SPRITE(#SLOT,112,8,GRND-9,((HLE+1)* 8)+SIDEZ):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=112 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
GOTO _NEXLDS
_DORAN:
CALL SPRITE(#SLOT,113,14,GRND-9,((HLE+1)* 8)+SIDEZ):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=113 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_NEXLDS:
SIDEZ=40::NEXT REPT
RETURN

OLD CODE:

_LDS:
LOOTL=INT(RND*100)+1 :: LOOTR=INT(RND*100)+1
IF LOOTL>BOARD THEN _MRL
LOOTL=INT(RND*100)+1
:: IF LOOTL<>1 THEN _3110
//!HEART 88
CALL SPRITE(#SLOT,88,7,GRND-9,((HLE+1)* 8)-40):: SLOT=SLOT+1
LO0T(LAB,LTN)=88 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3110:
IF LOOTL<>2 THEN _3130
//!ZED 96
CALL SPRITE(#SLOT,96,4,GRND-9,((HLE+1)* 8)-40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=96 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3130:
IF LOOTL<>3 THEN _3150
//!MELEE 112
CALL SPRITE(#SLOT,112,8,GRND-9,((HLE+1)* 8)-40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=112 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3150:
IF LOOTL<>4 THEN _3170
//!RANGED 113
CALL SPRITE(#SLOT,113,14,GRND-9,((HLE+1)* 8)-40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=113 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3170:
IF LOOTR<>1 THEN _3190
//!HEART 88
CALL SPRITE(#SLOT,88,7,GRND-9,((HLE+1)* 8)+40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=88 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3190:
IF LOOTR<>2 THEN _3210
//!ZED 96
CALL SPRITE(#SLOT,96,4,GRND-9,((HLE+1)* 8)+40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=96 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3210:
IF LOOTR<>3 THEN _3230
//!MELEE 112
CALL SPRITE(#SLOT,112,8,GRND-9,((HLE+1)* 8)+40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=112 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1
_3230:
IF LOOTR<>4 THEN RETURN
//!RANGED 113
CALL SPRITE(#SLOT,113,14,GRND-9,((HLE+1)* 8)+40):: SLOT=SLOT+1 :: LO0T(LAB,LTN)=113 :: LAB=LAB+1 :: LO0T(LAB,LTN)=SLOT-1 :: LAB=1 :: LTN=LTN+1::RETURN

Edited by Sinphaltimus
Link to comment
Share on other sites

  • 2 weeks later...

Not in baseline Extended BASIC, no. The original BASIC reference manual had a catalog program which pretty much illustrates how one works.

 

Pretty much every other flavor of XB included a catalog command of some kind. Super Extended BASIC has CALL CAT("DSK1."), for example.

Thanks. *sigh*

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...