 Hello there, I see that some people struggle when they face the challenge of programming. The major problem I realize people often have is that they forget the basics of any, including human, language. So in this video, we'll talk about common mistakes that infringe the basics of logic and how to avoid them. So let's start with a simple example. I want the pig to be either happy or sad, but I want to control when it will be happy or sad. So I want that whenever I press space, it will change his mood. So let's attach a script for him, okay, I will delete everything here and I will add a variable to care either if the character is happy or sad. So let's start by adding a variable is happy and by default it will start by being true. The next step is to create a method to change the mood of the character. So let's start by declaring a method. So func change mood and then we will ask for the mood of the character. So we ask for if the character is happy, then we'll set the texture to be the happy texture. So let's load this resource, then we'll check if the character is not happy. So happy is equal to false. And if this is true, so if the character is not happy, we'll change the texture to the sad texture. And here we have the first problem beginners run into when they start programming. When it comes to logic, a statement, this is a statement and this is a statement, can either be true or false. It's different from the value of the variable, okay? So this variable can be false, this variable can be true, this can be zero, one, and this can be, I don't know, a texture. But the statement can either be true or false. And here we have our problem. We are checking for if the character is happy. So if this is true, then this. And we are also checking for if this is true, then this. That's the difference. And how can we fix that? If this is true, then this is false, right? So we can simplify this statement by saying that whenever the character is happy, so if this is true, then this, otherwise or else, then this will happen. What we will change here is that we will fix this by changing to this statement. This is the principle of the excluded third. So either a statement is true or it's false. No matter the values, the content of the statement, the statement itself can either be true or false. With this in mind, we can simplify it even more. The first statement check for if the character is happy. We can simplify it by saying just is the character happy? Because it will be either true or false. We simplify this and this. The next step is to change the value of the mood of the character. If it is happy, we will change to not happy. And if it is not happy, we will change to happy. And here we have a very simple principle to pay attention to. The opposite of something, it's not another thing. The opposite of one thing, it's not this thing. This is the principle of identity. And what it says is basically that whatever it is, it's. So let's still go this mood right here. Let me delete this. And what we'll do is that after it's checking for what's the current mood of the character, we'll change the is happy to be its opposite. Not happy. Not is happy. This will inverse the value of this other thing. And this may sound confusing to a beginner, because how can something be its opposite? This is due to the next principle, which is the non-contradiction principle. This principle says that it's impossible for something to be its opposite. But this applies only to the logic itself, not to the data. A variable can carry any kind of data, including the opposite of what it is. But a statement, the logic, can't contradict itself. So it's impossible for this statement to be at the same time checking for if something is true, and checking if the same something is not what it is. Because this is contradictory, this will never happen. And we are done. These are the three principles of logic. It might sound too obvious when we are working with simple behaviors like this. But when you try to make more complex behaviors, try to remember of these principles and try to think what will be needed for your statement to be true so that you reach the desired behavior. So for instance, we have our next step. We need to check every time the player taps the accept key, so space bar or enter. And then if this happens, we'll change the mood of the character. Now we already know what we will need. We need to check for every time the player taps the space bar. And when the space bar is tapped, we will change the mood of the character. The way Godot handles the every time condition, it's by overwriting the process function. So this will be called every frame of the game. Now we just need to state what will happen when the player taps the space bar. In Godot we can check if the player is pressing something by using the input class. And there is a method for tapping, which is different from holding. So if we need to check a tab, we can just say is action just press it. And for the space bar, we can use UI set. And finally, when the player taps the space bar, we will change the mood of the character. All the conditions for our behavior, it's been set. So if our logic is correct, when I test the scene, the character will start with a neutral face, which is the default one. And I press space bar and it will change to happy. And then to set and so on. And that's all for now guys. If you have any doubts or questions, leave a comment below. And I will put in the description a link to a product with some exercise for you. That's it. Keep developing and until next time.