00:00
00:00
Newgrounds Background Image Theme

TwistSSD just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Logic 2006-03-17 21:00:08


AS: Mainzors

AS: Logic

Logic is usally taught in Math and deals with statements and conditionals. It relates to Flash because the Actionscript language of flash uses more or less of the same stuff that you would learn in Logic. Let me say that if you are learning Logic in Math class, pay attention!

Not all of the stuff I will teach is related to flash AS, but it deffinatly deals with other programming and languages, I can assure you that.

I'm going to go over 2 statements, and the main conditional.

The 2 statements I'm going to teach you about are the and and or statements.

and statements- The statement can only be true if all parts of the statement are true, otherwise the statement is false.

So let me give an example of how this is used. First we start off with a little key or something to tell us which parts of the statement are true or false. I will make up my own key for you.

John eats meat = true
Mary eats fruits = false

Now according to that key, if the statement says "John eats meat" then that part of the statement would be true. But if it the statement also said that "Mary eats fruits", then that part would be false, therefore making the whole statement false. So let me give a few examples of a statement with the and statement in it.

John eats meat and Mary does not eat fruits
The first part, John eats meat is true according to our key.
The second part, Mary does not eat fruits, would also be true according to the key because the key says that Mary EATS fruits is false, so if she does not, then it is true.
So that statement would be true. Lets do one more example

John does not eat meat and Mary eats fruits
The first part, John does not eat meat, is false because it is opposite of what the key says, and would be false in this case.
The second part, Mary eats fruits, is false, so the whole statement would be false.

Now lets move on to "or" statements.

The "or" statement works pretty much the same way, except that the statment can ONLY be false if both parts are false, opposite of the and statement.

Lets' use the same key as before:

John eats meat = true
Mary eats fruits = false

Now let me give you some examples with the use of the or statement:
John eats meat or Mary eats fruits.
The first part, John eats meat, according to the key, is true.
The second part, Mary eats fruits, is false.
Since one is true, and both are not false, the statement is true.

Example 2:
John does not eat meat or Mary eats fruits
The first part, John does not eat meat, is false according to the key because it is opposite of what the key says is true in Johns case.
The second part, Mary eats fruits, is also false
So, since both parts of the statement are false, the whole statement is false.

Now let's move into my favorite, Conditional Ifs and thens

These can get semi confusing, but if you memorize what each part does, it is extremely easy!!

An "if and then" conditional is used the same way in flash when writing a...well... conditional if! So let's get into it more shall we?

This does not require a key unlike the first two statements, but does require an original statement. So once again, I will make one up to benefit you all.

Original: If I eat, then I live
Now that statement, according to ME and real life, is true. So keep that in mind.

Now, there are 3 parts to a conditional if and then. They are: converse, inverse, and contrapositive. ( I love that word)

Converse
This is when you take the ORIGINAL statement, and switch the order in which it appears. Let us clarify the original statement:

Original: If I eat, then I live

Now keeping in mind that the converse switches the order, the new sentence would be:

Converse: If I live, then I eat

The Converse is ALWAYS opposite to what the original equals. In this case it would be a false statement. As you can see, the statements order was reversed, still keeping the If and then in the same positions though.

Next up:

Inverse
This negates the original sentence. That means that you would turn everything that is positive into a negative, and everything that is a negative into a positive. So let us rewrite the sentence as it's Inverse:

Inverse: If I do not eat, then I do not live.

As you can see, I added the word "not" into both parts of the sentance to negate the sentance. This would also be opposite from the original statement, thus being FALSE.

Contrapositive
This is when you take the original sentance, negate it, and switch its order. So you are using the Inverse and the Converse on the original sentance, to get a sentance with a switched order that is negated. Example:

Contrapositive from the ORIGINAL: If I do not live, then I do not eat

The order in that sentance was switched and negated. This will remain the same as the original sentance, and in this case being TRUE.

So that is basically all there is to logic, it is extremely easy if you memorize it and learn it. It is used in computer programming all the time and especially in Flash! I use this stuff all the time!

One more thing to know. There is also a term called Logically Equivalent, this is the same as the Contrapositive, so when you see those 2 words just thing "Contrapositive"

Hope you learned something out of this =D

Response to AS: Logic 2006-03-17 21:41:10


At 3/17/06 09:00 PM, True_Darkness wrote: AS: Logic

i <3 you for making this topic, david, but i have to fix some things...

no conjecture can be made about the converse or the inverse from the original statement. the most common example mathematically is "if x = 2 + 2, then x = 4".

inverse: "if x != 2 + 2, then x != 4".
just because x != 2 + 2 does not mean it cant be 3 + 1 or 2.5 + 3.5

converse: "if x = 4, then x = 2 + 2".
again, just because x is four does not mean that x has to be 2 + 2.
likewise, 4 + 0 also works.

the contrapositive, however, always bares the SAME truth value.
contrapositive: "if x != 4, then x != 2 + 2"
this can be proven with a proof by contradiction, but we can all see that this is the same.

a good non-mathematical example:
"if it rains today, i will get wet"

inverse: "if it does not rain today, i will not get wet"
i can very well get wet in many other ways

converse: "if i get wet, it rained today"
i could have very well gotten wet in many other ways.

contrapositive: "if i dont get wet, then it didnt rain today"
that is clearly true (all umbrellas and raincoats notwithstanding)

please dont take any of this as an attack, TD.
i just wanted to make sure that all the information is clear.


BBS Signature

Response to AS: Logic 2006-03-17 23:21:33


At 3/17/06 09:41 PM, authorblues wrote:
At 3/17/06 09:00 PM, True_Darkness wrote: AS: Logic
i <3 you for making this topic, david, but i have to fix some things...
please dont take any of this as an attack, TD.
i just wanted to make sure that all the information is clear.

Thanks, nope I understand. The topic can get pretty confusing for some people and I can see why you wanted to make it more clear. You had some pretty good examples, with numbers as well which I should of included to show how it can be used in mathematical equations and programming, but you covered that for me. By the way AB, what exactly is your name? =P, you always call me by my first name but I never really learned yours...

Response to AS: Logic 2006-03-17 23:51:59


At 3/17/06 11:21 PM, True_Darkness wrote: By the way AB, what exactly is your name? =P, you always call me by my first name but I never really learned yours...

if you listened to his broadcast you would know.
some great info there that people should know, and congrat's on 2k posts ^_^


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Response to AS: Logic 2006-03-17 23:53:46


At 3/17/06 11:51 PM, -Vengeance- wrote: some great info there that people should know, and congrat's on 2k posts ^_^

Thanks!

Response to AS: Logic 2006-03-18 04:58:21


Glaiel also made an AS: Logic, but it wasn't about the same thing, so kudos.

Your statement "that's pretty much everything there is to logic" is way off though, there is infinitely much more to logic, this is only a small part of it =)

Still, nice topic.


BBS Signature

Response to AS: Logic 2006-03-18 09:58:56


At 3/18/06 04:58 AM, Rantzien wrote: Glaiel also made an AS: Logic, but it wasn't about the same thing, so kudos.

Your statement "that's pretty much everything there is to logic" is way off though, there is infinitely much more to logic, this is only a small part of it =)

Still, nice topic.

Thanks, well I meant the basics since I only covered the and, or, and if and then conditionals... thanks though =D

Response to AS: Logic 2006-03-18 10:03:35


Even though you technically didn't provide any AS, this was actually very helpful, I hope it gets added. Really does make sense.

Response to AS: Logic 2006-03-18 10:05:11


At 3/18/06 09:58 AM, True_Darkness wrote: Thanks, well I meant the basics since I only covered the and, or, and if and then conditionals... thanks though =D

What you explained, you explained good. =)
On another note, I like using the word then to improve readability in code... Like:

if (condition)
then statement;

Unfortunately AS doesn't have then as a keyword =(


BBS Signature

Response to AS: Logic 2006-03-18 10:24:46


At 3/18/06 10:05 AM, Rantzien wrote: if (condition)
then statement;

Unfortunately AS doesn't have then as a keyword =(

Nope, instead it is a {
God knows why the heck "then" is a little squiggly parenthesis(sp), but whatever gets you by eh? =P

Response to AS: Logic 2006-03-18 10:32:09


At 3/18/06 10:24 AM, True_Darkness wrote: Nope, instead it is a {
God knows why the heck "then" is a little squiggly parenthesis(sp), but whatever gets you by eh? =P

Yep =D
Some day, I'll develop a scripting language that looks cool.


BBS Signature

Response to AS: Logic 2006-03-18 10:33:52


At 3/18/06 10:32 AM, Rantzien wrote: Yep =D
Some day, I'll develop a scripting language that looks cool.

Make it ALL english and super easy.

Example:

when you press the key spacebar, jump, otherwise, fall

^ That is codeing right there, no weird squiggly stuff, just... english =P

Response to AS: Logic 2006-03-18 10:48:14


At 3/18/06 10:33 AM, True_Darkness wrote: ^ That is codeing right there, no weird squiggly stuff, just... english =P

That would be cool indeed, the problem is such a language would run very slowly, at least I think it would. ^^

[code]
If player collides with tree, stop moving.
If player collides with any item and item is pickable, add item to inventory.
If player collides with any enemy, go to battle screen.

In that manner it actually wouldn't be all impossible to make. =)


BBS Signature

Response to AS: Logic 2006-03-18 13:39:37


when you press the key spacebar, jump, otherwise, fall

Oh pshaw. To LEET programmers all code looks like that anyways. =D


Come join music competitions on Chips Compo and hang on our Discord!

Good artists copy. Great artists get banned from the Audio Portal.

BBS Signature

Response to AS: Logic 2006-03-18 15:47:33


At 3/18/06 01:39 PM, JohnF_N wrote: Oh pshaw. To LEET programmers all code looks like that anyways. =D

thats true... i dont say in my head "if condition, bracket x plus equals var speed"


BBS Signature

Response to AS: Logic 2006-03-18 15:59:15


At 3/18/06 03:47 PM, authorblues wrote: thats true... i dont say in my head "if condition, bracket x plus equals var speed"

Who said anything about your head? HUH!?


BBS Signature