Hello, I hope you are having a great day so far.
I and many others are likely guilty of throwing our arms in the air when the going gets tough or a problem seems too grand for us to tackle. So how do we solve these challenges? The answer is computational thinking.
So what is Computational thinking?
Computational thinking is a set of problem-solving methods that tackle a problem so that the solutions are what a computer can execute. Fairly useful on Roblox I’d say!
How do can I use it?
Computational thinking is split into 4 sections:
- Pattern recognition
This involves taking a large problem and splitting it into smaller more manageable problems. You can do this as many times as you would like. For example, if I want to create a tycoon game, I would break this down to its core features:
- Upgrading the base
- Selling the products
- Dev products
- Game passes
But you still may be thinking how will I sell the product? You can break it down further:
- Increase the money when the product touches a part
Now it doesn’t seem like such a big problem, just do this for all your core features!
This involves looking at the lowest stage of our decomposition and recognising that it is similar to a problem that we have solved or seen the answer to in the past.
To sell the products, we need to increase the money, we can simply add the value of the part. I am sure you have all done basic maths at school, it is that simple!
So what is abstraction? We already have broken it down into the simplest form we can. It is used to remove any unnecessary details to the problem. I’m sure at school you have done word problems. All abstraction is removing the words to leave the numbers.
E.g. Bob has 5 apples and eats 2 then buys 6 more, how many apples does Bob have?
The final equation after using abstraction is:
a = 5-2+6
We can do the same for selling the product in our Tycoon, we don’t need to worry about how everything will look at the moment nor do we need to know the exact prices of everything, it is all irrelevant at the moment.
This is how we take our simplified problem and turn it into code that the computer can read (Kind of, but I won’t get into that right now).
E.g. Selling the product:
We need to add the price of the product to the player’s money. (The price can change later)
And here is the basic code:
local productPrice = 5 local function sellProduct(self) local money = game.Players:FindFirstChild(self.Name).leaderstats.Money money = money + productPrice end
Note: This code is not intended to be used thus is not made to be secure or resilient.
So now you know how to tackle that major problem that you have been putting off for a while!