24 April 2019

Calculating with Text! String Calculation!

For some reason, I am totally obsessed with this so it's one of the things I love about python! The basic idea behind it is quite simple. You calculate like in math with numbers but with String or text instead. Many programming languages allow you to do concatenation using the "+"-sign. Python also implements multiplication allowing "s" times four to equal "ssss".

Defining String

A string is a data type in programming languages to store text data. The way it does that is by storing characters in an array or list. "ABC" contains the characters "A" at position zero, "B" at position one and "C" at position two (in programming counting it often started at zero).

Addition

Just like in all the programming languages addition will work like that. It's quite simple. When you add 3 to 5 you get 8. In our example though if we add an "a" to a "b" it's gonna be "ba". The difference between our addition and the addition of (ℕ, +) is that ours is not commutative. Commutative means that a + b = b + a. In the case of (ℕ, +): 3 + 5 = 5 + 3. In the case of the way, most programming languages do the addition of Strings the second one is added to the first one. It is a concatenation after all.

  • 3 + 5 = 8    "a" + "b" = "ab"
  • 5 + 3 = 8    "b" + "a" = "ba"
It does not work in our case. You could argue that "ab" equals "ba", but.. it just feels wrong.

Continuing With (ℕ, +) Properties!

Let's move on to the next aspect. The (ℕ, +) group has a neutral element. The neutral element is zero. The neutral element basically does not change any element of the group if the group operation is used upon it. This means that a + 0 = a. We actually have that too when working with Strings. There's something called the empty String "". It's basically a String with no characters in it, a length of zero pretty much. If we add or concatenate this to anything it will result in the same you started off  with:
  • 5 + 0 = 5    "a" + "" = "a"
  • 0 + 5 = 5    "" + "a" = "a"
Funnily enough, the neutral element is also commutative, haha.

String Subtraction

Another property of the (ℕ, +) group is that there is an inverse element. If you apply the group operation to an element and it's the inverse element you get the neutral element. Additionally, the inverse element undoes the element. The inverse of three is minus three since 3 + -3 = 0. The inverse is often written with a negative exponent, a^-1. As such we have a definition like a + a^-1 = 0. This doesn't work for our strings though. The only way to get an empty string is to remove elements. We need the opposite of adding one character. We basically want to undo "" + "a" = "a" and that's removing the character. For this, we're gonna use the same way it's written with normal calculations. Thus we say "a" + -"a" = "". Interestingly we just declared subtraction
The definition of String subtraction will now be:
 "The removal of a character, the opposite of the concatenation."
But what if we have multiple elements like in "Hello"? Well, concatenation adds to the end. Thus subtraction should work just like that. If the character is not at the end, we just take the last occurrence of it. Simple, isn't it?

  • "Hello" - "o" = "Hell"
  • "Hello" - "ll" = "Heo"
Another thing we can define here is the subtraction of an a∈ℕ. Let's not go too complicated and just define it as subtracting a character from the end. So "Hello" - 3 = "Hel".

String Multiplication

In python, if you multiply an a∈ℕ with a String it takes the String multiple times. That makes sense. If we look at the definition of multiplication you might have learned that taking three apples four times you get twelve apples. Taking the three-four times is not different from 3 + 3 + 3 + 3 = 12. Which is the same as 3 * 4 = 12 thus 3 + 3 + 3 + 3 = 3 * 4 = 12.

If we concatenate "a" + "a" + "a" + "a" we get "aaaa". This is the reason why python defined String multiplication so that 4 * "a" = "aaaa".

But what about multiplying "a" * "b"



The distributive property of (ℕ, *) allows a(b + c) = ab + ac. If we calculate "a" * ("b" + "c") we can calculate the addition to get "a" * "bc". If we assume that the result follows the example from the (ℕ, *) we can potentially define "a" * ("b" + "c") = "ab" + "ac" = "abac". This means that 
"a" * "bc" = "abac". This is similar to how matrix multiplication works. 

The only weird thing we get from this definition is that "a" * "a" = "a" + "a" = "aa". It sounds not too bad. But there's one more thing I want to define and let's see whether or not it causes issues.

String Division

While this sounds like we're going to partition our Strings it's gonna be more like it works in normal math. There are multiple ways to calculate division. But we go with the opposite of multiplication.

One of them is to see it as the opposite of the multiplication. We're saying that if 3 * 5 = 15 we can also reverse or inverse this with 15 / 5 = 3. This means that if "a" * "a" = "aa" then "aa" / "a" = "a". At the same time our other example of "abac" / "a" = "bc". As you can see basically what happens is that division removes all occurrences of the divisor. This clashes with the multiplication of "a" * "a" = "aa". Since the opposite of it is "aa" / "a" = "a" but we would want it to be "aa" / "a" = "". Additionally if we assume "aa" / "a" = "" this means that "" * "a" = "aa", however, logically multiplying something with the empty String per our multiplication should result in no change.
"" * "a" = "a". This also matches the "a" / "a" = "".  

I guess there's a reason why people use "w/o" as "without".

Hooray

We defined the plus, minus, multiplication, and division on Strings or Text. It can't get any nerdier than that. The only issue is that "a" * "a" is not defined as the result does not make any sense in our definition. Though there might be even more issues in there. Nonetheless, it is fun just to think about such weird things, think it through and see how much hold up. Also, you can troll your friends or other people by calculating "1" + "1" = "11". :P
  • 1 + 1 = 2
  • "1" + "1" = "11"
  • 0b1 + 0b1 = 0b10




22 April 2019

Fortune Telling: Using Magic the Gathering Cards [3/3]

In the first two posts, I mentioned some issues while explaining how fortune-telling, specifically card reading works. Now as promised I'm gonna explain how, why and that using Magic the Gathering cards works too.

It Shows Again and Again

You can literally use anything for magick. As ridiculous as it sounds, I've already made a post about using the Guild Wars 2 gods in rituals. It isn't any different here. Again anything we use is just a tool and as long as it helps us achieve the goal it's good.

So, How And Why Do Magic the Gathering Cards Work?

In the previous post, I explained how to make your own positioning and how it works. The idea behind everything is that your unconscious knows what each card and position means. So all you have to do is assign meaning to the cards in Magic the Gathering that is not too obvious (we don't want your consciousness to instantly know the meaning. It needs to be vague enough but so that your unconsciousness knows it). I really need to get into the kabbalistic model as soon as possible to not have to beat the corn around the bushes. 

Let's start off with color. The Magic the Gathering Cards or cut into five different colors:

  • Black - Swamp, Death
  • Red - Mountain, Fire, Lava, Magma, Goblin, Dwarf
  • White - Light, Sun, Field, Human
  • Blue - Island, Water, Sea, Ocean
  • Green - Wood, Forest
Each color has an element assigned to it as well as a landscape (mana) and creatures, spells, etc.. This means that each color brings forth certain feelings and interpretations of it. We can even elaborate on the meanings of each. For example, the blue cards are assigned to water and water stands for calmness or for flow. Technically you could even go as far as to say it stands for the flow of time. Additionally, it could mean sadness, etc..

Once you've elaborate on each card you are pretty much good with the basics. Next up you could specialize on the card type, like working with the lifetime of a card. For example, something with an instant could be immediate, standing in front of the door so to speak, while a creature represents something that is going on for a longer time. Mana or land could be compared to something for the whole life. You can get creative with this. (I do have to admit I didn't go so deep into it.)

Next Up The Positioning

The positioning allows infinite possibilities. You can literally think about anything you want. When I went for it I wanted to read my future grades. Thus I simply went for order from left to right with the most important one being to the left, so: math, German, physics, English, technology. You can go with anything, as complex as you want or as simple as you want. Just familiarize yourself with it enough not learning it in and out though.

The Result

Well, the result was the worst one could expect. I got black on three to four of the subjects one some water too. The weirdest part, though to be expected. I barely passed with multiple fives or E's. Luckily the grades were combined with the ones I got over the year and the oral exam in physics was a one or A. (five/E on written exam one/A on oral exam.. interesting). Well, maybe it's a coincidence, stay skeptical, it seems very odd nonetheless though. 




18 April 2019

Guild Wars 2: Super Adventure Box Crocodiles Can Be Killed!?

The beautiful, beautiful Super Adventure Box. I know there are people out there who hate it and I don't understand why they cannot feel or see the nostalgia of this box. Anyways sometimes when you play games as a game designer or theorycrafter you start to wonder about certain things and two things I was wondering about is, what happens if you permanently hit the crocodiles in the Super Adventure Box and what happens if you destroy the amulet of the frog king.

Spank The Crocodile

Well, I've decided to do it today, so I went into the Box Zone 3 World 1 and went till the end. At the last checkpoint, I hit one of the crocodiles and jumped on it. Then I held down the auto-attack or skill 1 to permanently attack the crocodile with my nunchuck. I did try auto-attack but it didn't work. I also could've technically placed something on the key but I didn't have the nerve to do so. So there I was standing on the crocodile attacking it over and over again. In the meantime, I continued studying Japanese (I'm currently 2-3 chapters behind). I occasionally looked at the screen and I also was wondering how long it would take.

The attacks take 1/2s, 1/4s, and less than 1/4s. It's hard to tell exactly how fast skills cast without knowledge about the animation time (a.k.a. the time in between skills. E.g.: Skills that have no cooldown or cast time). Nonetheless assuming the animation time is at maximum half a second, it should be between 1/2s + 1/4s = 2/3s and 1/2s + 1/4s + 3 * 1/2s = 2.25s. The skill chain does 25 damage with each hit being two single hits and a double hit. So 4 * 25 = 100 damage. This results in 100 / (2/3s) = 150dps to 100 / 2.25s = 44.44dps. Assuming the number shown is the integer limit of 32bit on a 32bit client and 64bit on a 64bit client the limits are 2^32 = 4294967296 and 2^64 = 1.84 * 10^19. This is only the case for unsigned integers. If we assume they are signed (meaning the data type also stores negative numbers) the size is 2^(32 - 1) = 2147483648 and 2^(64 - 1) = 9.22 * 10^18. This means it would've taken me...
  • Worst case: 1.84 * 10^19s / 150dps = 1.23 * 10^17s (~3,899,616,115 years)
  • Best case: 2147483648s / 150dps = 14316558s (~165 days)

Not Even Five Minutes In...

While I haven't calculated how long it would take me I came across something interesting way before dying by holding a button in a game. What happened is that suddenly the damage number was gone. I was no longer hitting the crocodile. My first thought was to stop attacking it and retrying. Maybe it just didn't show the number anymore at that point? The number didn't restart. Then I decided to move away and get back to it to retry. No change. After a while, the crocodile was no longer stunned and knocked me off of it. I used the chance to retry to stun it but without avail.

This is interesting. The Guild Wars 2 wiki entry says crocodiles are unkillable. If that's the case, what is this? I mean it's not necessarily dead. It's still there but... invulnerable as in it has no hitbox anymore. Yet it can still deal damage and it's still solid, as well as being visible.

Switch On Game Design Brain...

Thinking about it from a game engineering and game design perspective I can only describe it like this:

If we assume a crocodile is a game object consisting of three hitboxes and three models (stun animation, idle animation, attack animation) the hitboxes would be
  • hit detection trigger hitbox (detects when the player hits the crocodile)
  • attack range trigger hitbox (detects if a player enters the hitbox and attacks them)
  • solidity collision hitbox (prevents objects from falling through it)
The hit detection trigger hitbox is the biggest allowing you to hit the enemy without taking damage or touching the solid part. The attack range trigger hitbox is nearly as big but definitely smaller allowing the player to hit the crocodile while not getting hit themselves. The solidity collision hitbox is the smallest and it fits the crocodile when it's in its stun.

The stun is probably realized with either a timer or a boolean.

Since the hit detection trigger hitbox detects the hits and triggers the damage to display I assume it also takes in the damage. So if the health drops to zero this one despawn (dies) while the rest stays alive. Still weird but it would explain the phenomenon.

But...

How Much Health Do The Crocodiles Have?

I had to answer this question hence why I went to another one to test on that one. I know I hit it once so it should be 25 down. So I kept hitting this one over and over until I got around the number where it stopped before. It should be above 12000. Eventually, I got there. The last number I saw was 14525. This means depending on the speed and overkill it probably has around 14500 to 14550 health.

Eureka!

There you go, I learned something else and probably you did too. New information for the wiki and new fun fact or useless facts you can tell other people. Right next to the deadly 37.5m drop when you use the fall damage mitigation trait.

Oh, by the way, don't try in real life. Fall damage is real and it's painful and deadly at way lower drops.

P.s.: if you destroy the jewel of the frog king it refills its health to 100%.
Liked the post? Noticed an error? Wanna discuss the content or leave a comment*? You can join or check into the discord to do so! (*Note: Comments are disabled to avoid saving user data on this website.)
>> Join Discord

About Me

My photo
I'm a B.Sc. Games Engineer and I created this blog to share my ideas, theorycrafting, thoughts and whatever I'm working on or doing.