The Dink Network

New File: Binary Supervars

August 21st, 04:02 AM
spike.gif
Rabid wolves roam the desolate network plains, doing maths and stuffs.

Behold! The Rabid Wolf Number 9 has released a dev file: Binary Supervars. It's a method to store up to 28 true/false values in a single variable. Try to understand how it all works in less than 5 minutes.

August 21st, 08:09 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
Oh, NOW YOU'VE DONE IT! 
Isn't this the same concept as SlipDink's Checkbit?
August 21st, 06:21 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
Could be. I didn't know that existed and I made this for funsies. I'll have to look into it.
August 22nd, 12:55 AM
maiden.gif
Funny, I've thought to do similar things before. I believe you could even use the binary values to store multiple (smaller) variables instead of just binary flags, although it becomes more complicated to extract the data again then.
August 22nd, 09:56 AM
slayer.gif
Rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I actually used Someone's functions from FIFO tutorial as a base for the script to seperate the digit into 10 individual places. Then used a bit of logic to seperate each digit into 3 bools (the final being 1)

It's fully capable of storing non-bool values just using the storage and extract functions. You could even make a variable that uses multiple ranges of values and bools. The functions make it relatively easy to read and modify the variables.

The tricky part is proper documentation for keeping track of your subvars because you can easily muck something up.

This might be a more simple minded and less optimized approach than checkbit, but as someone who is not a programmer or good at math I can actually wrap my head around it
August 23rd, 02:33 AM
maiden.gif
I noticed you'd used three per decimal. I haven't looked into the specifics, but wouldn't it be possible to split things into actual binary? (That is 0 is 00000000, 1 is 00000001, 2 is 00000010, 3 is 00000011, etc...)

Also, I don't know how big variables are allowed to be, but I suspect some versions can use larger variables than others, because the test DMod is crashing when I open the higher-valued chests.
August 23rd, 03:57 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
Oh, NOW YOU'VE DONE IT! 
It shouldn't crash unless there's some sort of oversight in the implementation somewhere. Global vars are 32-bit integers, and have been since the very beginning meaning that it's technically possible to shove up to 32 bools into a global var, rather than 28.
This Cornell page goes into it all, explaining how to store them, and then retrieve using shifting and then the AND operator.

Unfortunately, instead of bitwise operators, reDink and 1.08 received some fairly useless trigonometric functions instead which makes it a slog to implement outside of DinkLua.
August 23rd, 08:42 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
I don't know why it's crashing. I've tried new installs of both FreeDink and DinkHD and it works flawlessly, but when I tried the browser it crashed immediately on opening a chest. Weird. The variable limit is 2,147,483,647. That's why I've limited the last digit to be one bool. The way I store them is as follows:

1: Bool1=True
3: Bool2=True
4: Bool1,Bool2=True
5: Bool3=True
6: Bool1,Bool3=True
8: Bool2,Bool3=True
9: Bool1,Bool2,Bool3=True

When all the bools are true that makes the final result 1,999,999,999.

My implementation in the demo uses the chests editor number 1-28 as a reference to the bool. The first 3 chests are the the fist 3 bools and change the first digit etc.. So if someone mucks around in the editor that could potentially mess up the demo.
August 23rd, 12:20 PM
death.gif
RangerLord
Peasant He/Him Hungary bloop
The nation above all. 
@megadogv2
Out of curiosity, what version of Dink are you using?

@rabidwolf9
I'm reporting that with YeOldeDink 0.95 on Linux Mint 22.3, I did not manage to crash the test D-Mod.
I attempted to open the chests in a weird order, and even used fast-forward.
I don't know anything about programming, and I hate math, so I can't exactly tell if any number is wrong. Or even what this could be used for.
But it's nice to finally test something that I had no major problems with.
August 23rd, 01:18 PM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
Oh, NOW YOU'VE DONE IT! 
Thanks for the report RangerLord. I did attempt to deliberately make it crash by adding more treasure, but those additional boxes instead flipped it into a negative number, rather than setting it to 9 million like one might expect.

>what this could be used for.
Save files only allow for 250 variables to be saved within them. Quite often, these are used merely as flags to determine if the user did something or not. By splitting one of those variables up, it allows for one variable to have 28 (in this implementation) or more flags within it, thereby saving the use of the other 249 for more substantial purposes.
August 23rd, 02:28 PM
maiden.gif
Looks like it's FreeDink 1.08.

Also, does DinkC not have modulo? It's inefficient, but can be used to extract bit-wise stuff in a pinch.

EDIT: For added crash-catching, it's crashing at the first millions place. That is, I can safely store 999999, but nothing higher.
August 23rd, 10:22 PM
custom_robj.png
Robj
Jester He/Him Australia
Feed the void, and it will teach you its hunger 
The supervar functions in the FIFO tutorial were indeed useful, I used them extensively in my Dmod. Although calling the store/extract functions directly with base 2 and specifying the place yields more than 28 bools.
August 24th, 05:02 AM
duck.gif
toof
Peasant He/Him
I disagree. 
Funny, I've thought to do similar things before. I believe you could even use the binary values to store multiple (smaller) variables instead of just binary flags, although it becomes more complicated to extract the data again then.

Yup. Been there. Created a small proc to store and extract values between x, y bits. Ran like crap though, often leading into other bugs.
August 24th, 07:08 AM
spike.gif
I've used binary values to do an extended magic inventory, i.e. every time Dink gets a new spell it would flag it in that variable. My implementation was super ghetto though, like I'm doing &binval += 536870912 instead of having any kind of proper system.