Forums

Topic: Petit Computer

Posts 7,701 to 7,720 of 9,620

randomous

@Discostew Quite terribly, in Village, my largest single function is the Shop. However, most of the code in Village is dedicated to auxiliary functions. For instance, it seems like nearly all my code is in stuff like the dialog box system, the property system, time keeping, etc. The rest is mostly drawing lol.

Hey, I'm sure this is a ridiculously easy problem (or maybe it's one of those ridiculously hard ones, I don't know), but I can't figure out the solution and I'd like some input. I need a way to transform a set of data points into another set by averaging, but the amount of data will be very similar. For instance, I need to match 54 points against 56 points, so I need an algorithmic (and preferably quick) way to morph the 56 points into 54 points. An example of an easy version of this problem would be to match 28 points against 56, in which case I could just average every two points into a single point and I'd be done. However, I don't know how to "average" parts of a point into another. I hope this makes sense... I'm not looking for how to find the average of 56 points, I'm looking for a way to transform 56 points to 54 points (any number, really) by averaging.

Edited on by randomous

randomous

TAINT_Zzyex

JLMan wrote:

MAINCOUNTL is the amount of frames elapesed. So it's no good. As an example, if you have a really laggy game with 2 frames per second, MAINCOUNTL would rise by 2 in a second.
@LOOP
Code here.
IF TIME$!=NOW$ THEN TIME=TIME+1
NOW$=TIME$
GOTO @LOOP

You are all vastly overcomplacaing this. just do-
@TIME
cls
PRINT""TIME""
TIME=TIME+1
GOTO @TIME
Shortest one here. Tested and approved!
how would one make it goe up per tap? Im having issues with that on a game called beet the clock, where you race a cpu by rappedly tapping.

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

twinArmageddons

TAINT_Zzyex wrote:

JLMan wrote:

MAINCOUNTL is the amount of frames elapesed. So it's no good. As an example, if you have a really laggy game with 2 frames per second, MAINCOUNTL would rise by 2 in a second.
@LOOP
Code here.
IF TIME$!=NOW$ THEN TIME=TIME+1
NOW$=TIME$
GOTO @LOOP

You are all vastly overcomplacaing this. just do-
@TIME
cls
PRINT""TIME""
TIME=TIME+1
GOTO @TIME
Shortest one here. Tested and approved!
how would one make it goe up per tap? Im having issues with that on a game called beet the clock, where you race a cpu by rappedly tapping.

IF TCHTIME==1 THEN X=X+1

get in loser we're going titan hunting

3DS Friend Code: 2879-0639-8952 | Nintendo Network ID: merp_aottg

TAINT_Zzyex

heres wut i have-
@attack
cls
hp=hp100
if tchtime==1 then hp=hp-dmg
dmg=1
vsync 1
if button()==1024 goto @store
goto @attack
nothing happens when i tap.

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

TAINT_Zzyex

okeey disregard that. i just had the hp=100 in the loop, it should have been outside... lol.
Now, how do i run 2 loops at once (enemy loop and player loop)?

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

Pixelrobin

TAINT_Zzyex wrote:

Now, how do i run 2 loops at once (enemy loop and player loop)?

@LOOP (←another email :/)
GOSUB @ENEMY
GOSUB @PLAYER
rest of stuff here. Maybe a VSYNC?
GOTO @LOOP

@PLAYER
do stuff
RETURN

@ENEMY
do stuff
RETURN

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

TAINT_Zzyex

whenever i use gosub/return it says return without gosub. I will try again

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

randomous

If anyone read my old comment about condensing data, I've already found a solution. Sorry for taking up forum space!

randomous

TAINT_Zzyex

Disregard that... (it only works when you guyz say it)
Due to the crappy system, dmg always surpasses the hp breaking point. (0) How do i stop this?
Ex;
@theblackdragon
PRINT "ENEMY HEALTH
PRINT ""hp""
hp==10
HP=HP-0.1
If hp==0 goto @bluerobin2
goto @theblackdragon (tbd will love this)
when ran, it goes past 0 into the negatives. Wut?

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

Discostew

randomous wrote:

If anyone read my old comment about condensing data, I've already found a solution. Sorry for taking up forum space!

And I had a solution all ready too, which allowed condensing and expanding (to an extent).

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

Pixelrobin

@TAINT_Zzyex Living the risky life arn't you. I wouldn't do that If I were you.

Your problem is that you check for zero AFTER you subtract health. So The game would count "0" as -0.1. Just do <= instead of ==. <= stands for "smaller than or equal to" meaning anything in the negetives or 0 will be considered as dead.

@Discostew @randomous, I attempted to make random values based on a "seed" using wacky graph equations. It worked, but I couldn't really specify any range. Do you have any ideas of flexible random seed solutions? I would like people to be able to share their Battlewoods worlds without using qrs.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

Discostew

@randomous

CLEAR:ACLS
NUMP1=10:NUMP2=8
DIM P1(NUMP1),P2(NUMP2)
FOR I=0 TO NUMP1-11(I)=RND(100):NEXT
SORT 0,NUMP1,P1
FOR I=0 TO NUMP1-1:?P1(I);" ";:NEXT:?
SPL=NUMP1/NUMP2:IDX=0
FOR I=0 TO NUMP2-1P2(I)=0OR (P1(IDX)+P1(IDX+SPL-.001))/2:?P2(I);" ";:IDX=IDX+SPL:NEXT:?
END

No sure if this was the kind of thing you wanted.

Edited on by Discostew

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

randomous

@Bluerobin2 Are you looking to just generate a world based on random numbers generated from a seed? In that case, you can use the Linear Congruental Generator (errr below):

SEED=(whatever)

@SEEDRAND
RAND=SEED
RETURN

@RAND
RAND=(RAND*7+4444)%59049
RETURN

The randomness isn't all that great (in fact, it's terrible!), but it should be all right for games. This has a period of 59049 numbers, so if you generate more than that, they'll start to repeat in EXACTLY the same order (depending on the context, this might not matter as much as you think). For instance, if your first X numbers are 5, 669, and 7923, after 59049 numbers, you'll get the sequence 5, 669, 7923 again. There's not much I can do about this without making the algorithm EXTREMELY slow. The seed can be any number from 1 to 59049 (don't make it 0). You should call the SEEDRAND function only once (probably right before you generate the map or whatever you're doing). Here's some example code making use of it:

@START
SEED=RND(59049)
GOSUB @SEEDRAND
@LOOP
GOSUB @RAND
X=RAND
(do some stuff)
GOTO @LOOP

I know the seed is random in this example, but if you keep the seed around (or save it after it is chosen randomly), you can use the same value again to get the same stream of random numbers. If you need help, let me know. Also, I'm sure @Discostew will come up with something better, as this is probably the worst way to generate random numbers (it's just quick, that's all).

All that being said, you can actually double seed the generator if you like. You can pick another number instead of 4444, as long as it's not divisible by 3 (this is very important). For instance, you can choose a random set of 2's,4's, and 5's and multiply them together to get a number to replace 4444 (but it must be consistent for all random numbers generated in order for it to be a seed). If you want, I can provide the code for this "double" seed.

Edited on by randomous

randomous

randomous

Discostew wrote:

@randomous

CLEAR:ACLS
NUMP1=10:NUMP2=8
DIM P1(NUMP1),P2(NUMP2)
FOR I=0 TO NUMP1-11(I)=RND(100):NEXT
SORT 0,NUMP1,P1
FOR I=0 TO NUMP1-1:?P1(I);" ";:NEXT:?
SPL=NUMP1/NUMP2:IDX=0
FOR I=0 TO NUMP2-1P2(I)=0OR (P1(IDX)+P1(IDX+SPL-.001))/2:?P2(I);" ";:IDX=IDX+SPL:NEXT:?
END

No sure if this was the kind of thing you wanted.

That's... actually what I came up with as well lol. You said this works for expanding as well?

randomous

Discostew

@randomous To an extent. If you go to double the entries, the numbers will just double up rather than average.

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

randomous

@Discostew That's true... I guess you can't really make more data from nothing lol.

randomous

Discostew

@randomous Well, so long as you have at least 2 entries (point A to point B), you can generate a transition to it with more points. The code I had dealt with just taking the average of two values, but could be modified to take a percent of both, one having a higher percent if the extra point is closer to it (if that makes any sense).

Like, imagine you have 2 points, and you want to expand it to 4. The first and last would be those two points, but the point in between would be a percentage of the two. The second point being at the 33% mark, and the third being at the 67% mark. If expanding to 3 from 2, it would basically be the average at 50%. Expand to 5, and you'd have extra points at 25%, 50%, and 75%. See where I'm getting at?

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

Pixelrobin

@randomous hey thanks again! So umm lets say I want a random range with a limit. Since I have to call this multiple times, anyway to scale down the max limit without ruining the chances of any number? Thanks so much for your help. I guess I got spoiled with most programming languages giving you the option to set the seed.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

randomous

@Bluerobin2 Let's say you want to generate numbers between 0 and 99:

GOSUB @RAND
NEWRAND=RAND%100

It is VERY IMPORTANT that you do not overwrite RAND. If you're worried about doing so, you can take a performance penalty and redo the @RAND and @SEEDRAND functions as follows:

@SEEDRAND
IRAND=SEED
RETURN

@RAND
IRAND=(IRAND*7 + 4444)%59049
RAND=IRAND
RETURN

This way, you'll have an "internal" random number, and overwriting RAND won't have any effect on generation. Also note that the 7 and 59049 should NOT be altered in any fashion. Those numbers were chosen for a reason, and changing them might ruin the randomness.

@Discostew I see what you mean, don't worry lol. I'm using this for a pattern recognition project I'm working on for Petit Computer. If it works... well, we'll have a cool tool for future programs (well, I think it's cool anyway).

Edited on by randomous

randomous

Please login or sign up to reply to this topic