Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,030 --> 00:00:02,370
Now let's look at operators.
1
2
00:00:02,380 --> 00:00:03,780
With variables alone
2
3
00:00:03,780 --> 00:00:05,340
we cannot do much.
3
4
00:00:05,640 --> 00:00:09,960
Not even store data, in fact, not because they cannot.
4
5
00:00:09,960 --> 00:00:16,620
But because we need to use an operator to actually assign a value to a variable.
5
6
00:00:17,250 --> 00:00:25,200
Now, let's look at the code here and let's assign two values to two variables and then use the addition
6
7
00:00:25,200 --> 00:00:31,490
operator to add these two values and assign the new value in the third variable.
7
8
00:00:31,500 --> 00:00:39,810
So first we have "a" which is 1 because it is an operator assign, then we have "b" and then we have "c",
8
9
00:00:39,810 --> 00:00:42,480
which is the sum of "a" plus "b".
9
10
00:00:42,930 --> 00:00:50,280
So the order of the execution of this is of course "a" + "b", and then the final result gets assigned
10
11
00:00:50,340 --> 00:00:55,050
to "c". You can print "c", so you can see that the number will be three.
11
12
00:00:55,050 --> 00:01:02,100
in this case. There are other operators that you should know of: addition(+), subtraction(-), multiplication(*)
12
13
00:01:02,100 --> 00:01:02,940
and division(/).
13
14
00:01:03,540 --> 00:01:10,260
All of these operators work exactly like in math, with the observation that the division cannot be
14
15
00:01:10,260 --> 00:01:11,640
divided by zero.
15
16
00:01:11,670 --> 00:01:13,260
It will result in an error.
16
17
00:01:13,380 --> 00:01:17,040
Not all of the operators handle calculations.
17
18
00:01:17,040 --> 00:01:25,080
For example, we have the logical operators: AND(&&) and OR(||) what they do is basically they handle own unique
18
19
00:01:25,080 --> 00:01:31,470
variable type called boolean, which can be either true or false as following.
19
20
00:01:31,470 --> 00:01:37,740
For example, if you use the AND operator, it can also be as this symbol &&.
20
21
00:01:38,010 --> 00:01:41,130
If we have true && true, it will be true.
21
22
00:01:41,430 --> 00:01:46,650
If we have true && false => false, false && false => it will be false.
22
23
00:01:46,920 --> 00:01:53,560
For example, this is good in conditions like is the AI moving to a particular target AND also is the AI
23
24
00:01:53,580 --> 00:01:55,140
having a particular health.
24
25
00:01:55,140 --> 00:01:58,050
Then it's true that otherwise it's false.
25
26
00:01:58,050 --> 00:02:05,910
And the OR operator is a little different, of course, because true || true equals true, but true || false
26
27
00:02:05,910 --> 00:02:08,100
equals true.
27
28
00:02:08,760 --> 00:02:13,980
So the difference is that only one of the conditions needs to be true
28
29
00:02:13,980 --> 00:02:18,600
in order for the whole statement to be true. We can put it to the test and see the result.
29
30
00:02:18,990 --> 00:02:26,430
Of course this is AND so true and false will be equal false and this is how we can actually use them.
30
31
00:02:26,430 --> 00:02:30,270
Let's see, we have a variable called is enemy visible and true?
31
32
00:02:30,270 --> 00:02:35,850
And then in the next section when we will be discussing about flow control, we will see how to get
32
33
00:02:35,850 --> 00:02:38,070
the most out of these operators.
3519
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.