Unity Game Tutorial: Sudoku 2D | Octo Man | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
43 Lessons (4h 3m)
    • 1. #1 Introduction

      2:10
    • 2. #2 The Concept

      6:08
    • 3. #3 Unity Setup

      2:10
    • 4. #4 Initialize Grid

      10:32
    • 5. #5 Debugging Grid

      5:16
    • 6. #6 Debugging Grid Seperators

      3:51
    • 7. #7 Shuffle Grid

      2:39
    • 8. #8 Mixing Grid Cells

      7:37
    • 9. #9 Completing the Shuffle

      5:07
    • 10. #10 Creating the Riddle Grid

      9:02
    • 11. #11 UI The Playfield

      6:11
    • 12. #12 UI Number Buttons

      3:27
    • 13. #13 Scripting Number Buttons

      8:36
    • 14. #14 Creating The Buttons

      5:44
    • 15. #15 Parenting Buttons

      7:02
    • 16. #16 Button Prefab & Board Setup

      4:49
    • 17. #17 UI Input Field

      5:41
    • 18. #18 Scripting Input Field

      4:26
    • 19. #19 Working Input Field

      6:20
    • 20. #20 Update Riddle Grid

      2:26
    • 21. #21 Difficulty Levels

      6:24
    • 22. #22 Win Check

      6:20
    • 23. #23 Show Hints

      8:45
    • 24. #24 Finishing Hints

      6:15
    • 25. #25 UI Menu Scene

      6:49
    • 26. #26 Menu Buttons

      6:31
    • 27. #27 Connect Difficulty Settings

      2:42
    • 28. #28 Debug & Print CleanUp

      3:10
    • 29. #29 Win Panel

      8:09
    • 30. #30 Concept BackTracking

      10:49
    • 31. #31 Column Check

      3:47
    • 32. #32 Row Check

      1:47
    • 33. #33 Block Check

      7:05
    • 34. #34 Check All

      3:17
    • 35. #35 Check Valid Grid

      2:17
    • 36. #36 Fill Grid Base

      11:49
    • 37. #37 Solve Grid 1

      7:21
    • 38. #38 Check Possibilities

      5:30
    • 39. #39 Solve Grid 2

      10:37
    • 40. #40 Optimize Create Riddle Grid

      5:26
    • 41. #41 Update Start Function

      2:06
    • 42. #42 Game Ideas

      5:45
    • 43. Conclusion

      0:41
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

64

Students

--

Projects

About This Class

In this Course you'll learn how to create a Sudoku in Unity Game Engine.
We create 2 different Conzepts. A Fill Mix Method and Recursive Backtracking Method. We create it as a 2D Game.

This course is a Beginner/Intermediate Course, so if you have trouble in any case, write me a message or Q&A, and i'll help as best as i can.

If you are beginner, you might have some trouble to follow, but the videos will guide you through the complete course. Don't forget you only become better if you repeat things and keep on learning!

So we create several Systems which will give us enough freedom to:

C# (Monodevelop)

  • create any type of Sudoku in general

  • create easy to super hard Sudoku Boards

  • create a Auto Solving System using Recursive Back Tracking later

  • create Inputs with Buttons to get a working Sudoku Game

  • Settings possibility for multiple Game Modes

Unity (2019.1.8f1)

  • create a Playfield of your liking

  • create Inputfield to give the Player Input possibilities

  • Create a simple Win GUI - You may want to create a not solved yet GUI as well

  • Hint and Check Buttons

  • creating a Menu and the Game Scene

Course Material

I provide no Material since it's not needed for the Course.

  1. You have to write the code on your own, i do not provide the final scripts!

All other graphics for Menu's, Icons, Images or Buttons need to be created on your own.
All Materials i provide are for education only and should not be in your final release!

Conclusion

In the end of this course you will have a fully functional Sudoku 2D Game with multiple Game Modes.

So what are you waiting for?

Let's make your dream game a reality!!

Level: Beginner / Intermediate
Video Course Length: ~4 hours 
Unity Version required: 5.3+

Meet Your Teacher

Teacher Profile Image

Octo Man

Let's make your dream game a reality!!

Teacher

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

phone

Transcripts

1. #1 Introduction: Welcome to the introduction. Video off how to create a classic sudoku game with a unity in this course, you gonna learn about everything about buttons and canvas system and all the other stuff. We're gonna look into four different game modes. We're going to design this raza quickly. Together we gonna have the possibility to change the mode or actually set a mood. And also, we have the possibility to give ourselves some hints and we can also check if we have one or not. What we now can do is whenever the borders curry. I did. You can see this. Great out numbers are not being selectable because we make them not interact herbal for the white ones, which we probably are able to solve because off the game mode directive like, for example, this number over here would represent a one. Since we have one under one over here, we gonna be able to select one of these buttons where we want to fill in data and can give it any value. Also, as you can see, these are represented with other number off colors. And if we don't like what we see or where if we need a hint because we have trouble somewhere. We can take this hint and let ourselves get this one. Depending on the game mode, we have the possibility to set a different number off hints we can actually take a look at . So, as you can see in my medium mode, I have 123456 hints I can take, and then I can try to continue and fill all the other corresponding data into the company to Sudoku Grid once we're done. Was that of course we show a little game overseen or you windscreen or something like that ? And then you have the possibility to play again as well as go back to the menu and probably check out any other off thes. Moz, I hope to see you in the course. If you are interested into how to create a Sudoku Games fair, free to check in and find out 2. #2 The Concept: Welcome to the Unity Sudoku course. My name is on demand, and I'm your instructor for the next couple of hours into how to create Sudoku in Unity game engine. What you will learn is actually how to concept or how the concept is going to be designed around Sudoku. And once the Doku is, let's talk about the concept about the game itself. First off Sudoku. It's a riddle game where we have to fill all this white fields on the playfield toe Phil, and with different numbers. The amount off numbers in total are 81 81. Field needs to be filled with numbers between one and nine. There are special rules to fill the grid completely. And let's talk about those first off. We have a rule that in one of these little squares, since we have a three by three big field of a year in one of these squares, we need all numbers represented from 1 to 9, so no field can have a double number, meaning if we ever seven here already, we are not able to put a seven anywhere in this fields. Same applies to Rose. You cannot have if you have a three in this complete row. You cannot have a three in all the other ones as well. Same for the column. You are not able to put in nine if there is one already in one of these white fields. So this are the special rules about the Sudoku and total. What we gonna do is we create such a grid off numbers where is different a race and fill them with a specific mathematic calculation. Then we gonna shuffle the board with a different amount. We can set the amount of shuffling on our own. Then we gonna disable some of these numbers or actually fill zeros inside these fields where we don't have any fixed numbers inside. Then what we're gonna create as a canvas as well as some buttons where we can press on all of these wide one. So these white ones, as well as, of course, the gray ones all of them are buttons, But the gray ones are not interact herbal. So we gonna sti activate these buttons because we don't want to have any input on this, so the player cannot change it also, what we're gonna have is a input field like this one. Whenever we select one of these buttons, for example, this one this input field will enable itself. And we can choose one of these numbers from 12345678 and nine as well as an empty one. The empty one represents zero. And according to whatever our input is, we're gonna fill into the field later on. We also create a button for checking the complete board and give out any warning message or any winning message any screens, do I? Whatever we please and like to show that we have done that, or that the player has completed one particular grid, we're going to implement three different difficulties by erasing 35 an easy mode 40 and media moat or 45 fields in hard mode, meaning the more we gonna pick or take away from here, the harder it will be to complete one particular board. You can decide these numbers later on on your own. We just need to define them accordingly. So what we're talking about in total are we are using see shoppers coding language. We're gonna create an Emam for the difficulties we gonna create I believe at least three or race, which are taken. Care off all these numbers. So we have a solved grid than a riddle grid. And later on, we're gonna need to create a list where we can store or this number fields over here. For example, if you want to give a hint to the player, for example, highlight any random number over here meaning we gonna create a hint button for that as well. So whenever he is going, Teoh need to him because he does. The player does not find any good number. He probably gets a good hint by when we are highlighting any of thes numbers. Then off course, we make them inter, not indirect. Double anymore. Intend them, for example, read or any other text color. So he's see. Okay, this was my hint number. Let's see, what I can do was Dad, if you don't know how to solve these kind of riddles, then you are gonna explain pretty quick. For example, we have four over here. When we look into this line we're before here. I will check this line where four. Here. What does it mean, ISS? We cannot have a four in this place is, of course, but it also means that one of these fields need to be four as well, because there is no four in this particular square. In that case, this field would represent the next four, so this one would be a straight So this is the way or one way how you can actually figure the riddles out. So if you want to lie, I want to play the game on your own later on. Of course you can do so. And to learn how toe we asked Lee solve sudoku. Oh, riddles on your own. Every time you start a new game or a new round, the field will always look different, even if we gonna have the same matches or the same mix amount. So always, the field will always look different, and the numbers will change accordingly. Also, depending on the difficulty level, we gonna set up or you can later on, let the player set up. He can actually solve one of the other ones, and you can give up something like a score. We can implement a timer. How long it took for him to actually go through that all of that will be part of the course , and we gonna start in the next one directly and setting up our unity. 3. #3 Unity Setup: Welcome back to the course in this part who want Teoh. I want to make sure that you set up your unity, how it actually helps you the most. The most important one is the consul. I want you to see the consul every time. So I place my consul always over here in the bottom center, you can always wreck around pieces like the console. But I do not recommend putting the consul next to the scene so you don't need to switch back and force. It is important that you see the corn so always because when we have any typos, any problems who want to see them instantly. Also, I created a two d Seen you can also created three D Scene doesn't really matter because we only make use off the canvas system as explained in the concept video. Also, you want to always see the game view at the same time as you see the scene view. This does not matter if it is the studio's really game. It is absolutely crucial that you always have the most important stuff directly in front of your not like being next to each other, because you don't see Maybe a change of what you do in the scene. You you don't necessarily see this change in the game view. Also, you might want to go and do not work and free aspect to always work in 16 by 10 or 16 by nine or vice versa. Nine by 16 in 10 by 16. If you don't have these two values, you can always press on the plus and the crew you create those if you like to. Also what you want to see always is Thean Specter that we need the inspector quite often to take on put in some information into this as well as we always need to see your project very so we can organize everything according to our needs. If you are done with your layout and it is probably looking like that or it is working for you, then you can always say for the layout. So you go to the layout, tap in the top right corner and just say, save layout, give it a name and you're good to go. I have mine set up over here so I can load it like every time I liked you. That's everything you want to take care off at the very beginning before you start the course 4. #4 Initialize Grid: Welcome back to the course in this part. I want to start to create the first scripting piece where we are actually initializing and creating a rez. Assorted way off script for the Sudoku grid. What we want to do is it. First we want to create a new C shop script. Ever came? Probably named this one board or playfield. Whatever you name, it doesn't really matter. What do you also want to do? Of course. You want to open this one up with Mona, develop of visual studio as your police and like the first thing we want to do whenever it's open, we want to get rid of starting update or at least update because we don't need it. We need start later on. Also, you can get rid of the command lines if you don't need them. Also, you can get rid of systems that collection and collection generic. But I guess you just keep them as in here for now. So the first thing you want to create is an array off into just so off numbers which we can actually store all our information into. So it is an integer. So we type an int and into the array. And in this case is not a single array. It's ah two d array as our playfield. Since we have an X and A y coordinate, I gonna name this one solved grid and what I want to do that want to initialize that already? Since we know these numbers already as a new end, open close square brackets once again. And now we put in the numbers off the size nine common nine. So we have basically nine fields inside this interred array and the ex And why coordinate? Don't forget toe and the line was a semi colon, by the way, the thing is, we are starting a race always at number zero, and the nine will never be a nine. It will always be a eight because it will be always reduced. But even if it's starting at zero and we're ending at eight, it's still contains nine numbers. Just keep that in mind so you don't get confused later on also what we want to put in as a string for debugging purposes I gonna name it just s You can also name it whatever you like . Of course. So we're gonna put later on something into this, a little string, so we can d back our grid whenever we created. So the next piece we want to create is the actual initial grit. So for that, we're going to create a new function on its of type void, since it doesn't return anything but we need to fill in numbers between 91 and nine into our solved grid so we can do something with it. So I name this in it grit, and we feel in data by referencing this interred array. To do that, we type in the keyword ref as reference. And now we can put an end open, close grab records and then we just type in grit and we off course close apprentices off those curly braces and what you can see now, once again, we reference a specific type off grid we can later on Put in to that meaning we can late on , put in at the reference off the solve grid and everything. What we do inside the sanction will happen to the souls grid. What we now want to do us, we want to fill the grid to fill it. We need to loop through this two times. So we create a four loop, so we type and four and tap twice on. It creates a fallen for us automatically. In that case, it's an inter Jeff I starting at zero and why I is smaller than the maximum number which we define as being a nine. When you tap once again, you're gonna select the Mex in this case and nine is going to be the number the magic number over here, of course, because in our ex vary you value basically or y value. We both sides do have a nine over there Now, Now we create a nested follow up for the other one for the y value or in this case, we name it Jay. And also day has a maximum off smaller than nine, basically up until eight. So we loops. Rule this two functions of the here and now we need to fill our grid our solved grid with numbers or whatever the reference Great iss. We're gonna talk about this in a bit. Now we're going to do some Miss Matic calculations. First off, we want to fill in everything in grid wherever we are currently looping Stroh. So Grid's I comma J is are the indexes or the indicators where we want to fill in numbers? What are the numbers? We are We like to fill in. There's going to be a rather complex formula, but I gonna try to explain as good as I can and give you some mathematic calculations about it. First off, we open close parentheses and inside we do the calculations. First we multiply, I with three. Then we add I and divide three or divide. I buy three, and then we add day, which is going to be the Y value. And then the last one is going to be recover. Or Ashley, we cap the whatever the number is we captured by a model nine and we add a one to it. Once we had done was model nine. What is going to happen over here? You ask? Of course. No problem. I gonna tell you the very first thing is we gonna do a calculation. I times three. I let me type it out for you, so you probably understand the better. You don't need to type this out, But you can if you like. to. So let's assume I is eight. Then we a multiply eight by straight. So this is the first number we're going to get over here. Of course, we know the result already. It's 24. So the next one is our second number, which is going to be I divided by three. And it's always rounding downwards, not upwards. So end to is equal to eight divided by straight. And since we're having Inter, Jess and we don't have any round up or down function, the result is going to be too. We can also d back all of that in a second. The next one is we do all this calculation and model others together. So we gonna create another. So this is going to be our actual result number and is going to be equal to. And then we put the same formula together as we did over here. So in that case, it's n one plus, and to so that other numbers Now we need to define J. So depending on where day is in which a column basically, let's assume we gonna take the first number in the grid. Eso a j in this case is going to be zero. So what is going to happen now is we calculate all of that together, and then we model that by nine once again, we camp it by nine, and we add a one to it. Now, when we're when I actually print this complete stuff over here than we get in result. So let's test it out. In that case, we gonna say print so we can print always messages. We can also make use off deducted law. So we say n one plus Now we take some quotes, put another plus of the year so we see the actual formula and so that we understand what's going to be the result in the end. So n one plus now we say plus again and two So that's what we're gonna print. Don't forget that we put another plus and in that case, and we gonna took zero over here. So this is going to be the formula. But now what we want to do is of course, we want to make sure that we modelo the nine to this. Of course, I need to put a plus over here in between. So finally we want to print in s well, so because it is taking the model. Okay, so let's save the board and create it. Can was pretty quick. So right, Click create you. I canvas and, of course, probably want to create an image in there as our board. It does not have to be anything at the moment. I just want to have anything where I can connect it. I'm gonna name it board. Don't forget to hit, Enter and put the board script onto it. Now, I just need to make sure that I call in it great and reference the solved grid to it cause . And the light was semi colon. And now what I want to do is I want to de back that particular numbers. The one I know. Press play. I should get a numbers game of a you and a number in the end. What now happening is we gonna calculate 24 plus two plus zero. So, as I already explained, let me do the model for you. So you see what's going to happen with this nine? So in that case, wherever 24 plus two plus zero and now we have a number off 26 When we say now. Okay. Modelo is always taking the higher number and negated by nine. Since we tear took model nine. So we say minus nine is equal to 17 minus nine again is equal to eight. And then after the model who? Nine. Since this is not round a bill by Modelo anymore, or decrease herbal, we're gonna add one to it. In total, we get a nine in the end. So what we now do is we fill the board with numbers based on this calculation, based on this little formula over here from 1 to 9 each row. And it also takes care that there are no doubles in the next room. We're gonna do the debugging off the next rose or off a complete field in the next video. 5. #5 Debugging Grid: welcome to the course in this part. We want to create the debunk function so we can see how our complete board would look so the complete solved grid is looking after we're initializing the complete board or ready. Let's open our board script where we already created in it grid, I create a new function void D back grid and what we need to reference. And here is, of course, the same integer or any interject Ray we like to. In that case, we want to make sure we do this with any grid. In that case, of course, was the solve grid. Whenever we're done or whenever we're calling the sanction, first off, we need to string. In this case, we can make use off s directly over here or we just created new empty one does actually not really matter. So what we want to take is s as our indicate and we say Okay, we empty that at first, so we only type in some quotes Now, What we want to do is we want to look through the complete grid, of course, and add the numbers to our yet to our s to our string when we want to do, of course, is at first we create a for loop. So once again, we tapped twice to create this for a loop we loop at first over. I was nine, as you already did. And the other one over day was nine as well. Since we have a nine by nine field, no one we want to do is we want to add whatever number we find in the particular 12 s. So it's s plus equal and we add whatever we find in grid, I come a j So the value, whatever we see inside, we're gonna put it in there. And we can also already put this or converted to a string since we want to have it as a string and not s an inter job. Once again, our grid array over here is going to be of type into, just so we need to convert it to a string. So we see it better now. What we want to do whenever we have through the first loop, like after we're done, was dead. We want to add a separator. So I say as plus equal and I'm gonna taken at symbol. We can also put in a backslash and what we now want to do whenever we are done with both follow ups, we want to print s But of course we need to put it into have fantasies and close the line was a semi colon. Let's test it out whenever we are now done. And a compiler has no problems with whatever we have written over here, which should be able to debunk that. But we can Onley debunk that whenever we call the function. So we say D back grid and now we reference solved grid once again, don't forget to save. Let's go back and test it out. When I press play, I should see some numbers as well as our calculation from the first place. As you can see, there are no numbers over here in the Consul which is starting was one and they're filling the complete lines from left to right was 1 to 9 at the first place. The 2nd 1 is starting at four. And then whenever it's a hits nine, it started one again. So we never have in this squares. I'm gonna copy this complete part and bring this into an editor so we can see this better. So as you can see, our current function already creates a all lines so that nowhere in these lines or these lines, or even all this squares over here there are no doubles in case off numbers in one of these blocks. Yes, I can see nothing is repeating. This line, for example, has only won one only 123456789 You can check out all these numbers right now on your own and you can see same is going to happen, like with all the last numbers. For example, this this this this So the complete column does not contain more than one off each number. Same in between. You can check everything out. You will never find any doubles in a line in a row in a column or even in a block. And that's what we wanted. This is what our initial grid function is doing for us. It automatically fills it with the model it never overrides or over does it. And it never made old makes sure that none of these numbers are ever reported. And in the last video where we are doing this calculation. We got the nine over here because we took J zero. Since we started at this number Over here, we're in the first row and then we're gonna created everything afterwards. And that's why and how this is so important. This initial grid functionality. So we have of working grit already. Just with that two functions and the 2nd 1 just make sure that we get an idea about it. 6. #6 Debugging Grid Seperators: Welcome back to the course in this part. I want to update the debug line or the D back functionality a bit more so we can read it easier. What I mean by that I want to put some pipe or any other symbols in between those blocks or lines over here so we can actually read, um, easier and see what's going to happen in the future. Open your board script and go to your debunk function. First off, I want to implement some kind of a separator interject. So I gotta create a int over here in the top off the debunk function end and I call it Step is equal to zero. We just start there because we need to have have a function or a number which is taking care of that. So at first, whenever we're starting in the first iteration off, I like on the left span or column, we want to make sure that we create a pipe on the so we say s plus equal. And then we can put in quotes any basically anything. I'm gonna take this pipe and of course, that the line was a semi colon. Now we want to have some more grit, Marcus in between. Like in between every cert j. So I can put a separate over here as well. So we can say Sepp is equal to J Model three. So once again, we kept the separator by modelos race so it will never be higher than three will start once again. And now, when we want to do us whenever we do, the separator day is equal to J Modelo three we want to request If Sepp is equal to two, then we want to put in a separator here as well. So we say as plus equal, open close quotes and bring in a pipe years. Well, don't forget to safe. So now with that, we're gonna put in these pipes inside our grid into the D buck lines into our print message . Once again, it's just for debugging purposes. You don't need to do this, but it is later on. Easier to read. Same here whenever we're starting with the first row or when would ever role in this case. Whenever I increases once before it actually adds any number, we add a pipe into our print message into our s string. Don't forget to save and let's go back and test it out. Whenever the compiler has done running and no problems a cure. We're gonna see a different board. As you can see. No, we have pipes in between all this lines whenever we need them. Once again, I can put this over here. It is going toe, as you can see. Look the same. But we don't need to make sure that we actually yeah, put away all of that. We just need to put in, like to empty lines over here if we like to. And then we're good to go. Also, we can put in some empty spaces or empty lines in between that as well, Like whenever the cert you know, day or actually the ninth on eighths J is going to happen. Then we can put an empty line here as well. We can also do this after the J is or I actually has increased. But then we have like every time Ah, a spin or an empty row over here. So this is how our game field is now looking in case off debugging purposes. Now what we need to do is we need to bring this anyhow into our playfield. But before we do that, I want to make sure that we are able to mix this play feel because if every game would look the same, it would be boring, Right? So we want to mix up the complete playfield, so every time whenever we're done was mixing it, it is looking different. 7. #7 Shuffle Grid: Welcome back to the course in this part. We want to create our shuffle grid function. So at least the first part open of your board script and that's created How do we want to suffer a grid off a race? Well, first off, we need to reference the grid we want to shuffle. And of course, we need to create a function. I gonna call it Shuffle Grid. We need to reference once again our grid. So we say ref int square records, and we're gonna say to D array, and we just name it Grit once again. Also, we want to implement a integer about shuffle amount. So how often do we want to shuffle? Because every time we do this, we can only do it once, and then we need to repeat it based on the shelf of amount. So how do we do this? First off, we need to create a for loop. So we type in four and kept twice. And meanwhile, I is smaller than our shuffle amount. We're gonna increment I once again. Now we create a two of random values. An inter gia, I gonna name it. Maybe value one. It's equal to random good rains between one and 10. So we gonna have a number, but which is going to be one and or between one and 10. Someone is a smallest, but 10 is not being the highest. Nine is going to be the highest number in this case because 10 will be ignored by random that range values. Then I want to have a second value. So I can't say into value to is equal to random, don't range and basically reduced the same between one in 10. Now what? We want to do it over here. We want to mix too cells over here. And once on whenever we had done was that we want to call our d back. Great. Look over here by referencing grit. In that case, it's going to be the grid we put in over here is our reference grid. We now need to create a function which is doing the actual mix for us with this corresponding values, as well as taking the correct grid into consideration. But that's what we're going to do in the next video 8. #8 Mixing Grid Cells: welcome to the course in this part. We want to create a function which is mixing two cells off our array with each other. For that, let's open up overboard script. And let's create a new function called makes to grid cells. Are we gonna take four or three arguments? The 1st 1 is our reference, Ingrid, once again. So in integer reference, we name it grit as we already did before and of course, to values. So the value one we already created in the last one as well as the value too, which we gonna get laid on from the suffer grid and we open close curly braces. Now what we need to do is we need to have four full loops which are looping through the complete board and doing different things. First off, we need some inter jests. So what we can do is we can assent to basically all these inter just zero and these are going to be the accent. Why coordinates inside our grid? So we're gonna have basically four different ones and x one and x two. And why one and a y two. So these once again are representing the fields inside our grid once again, the X one and why one coordinators wouldn't coordinate like oneself. For example, grit 00 There's going to be one, and the other one is going to be X two X and why two is going to be another one? And then we need to slow actually switched those two cells which are ever matching in any case and switching back in force. The next process is going to be a bit complicated, but I tried to make it as yeah, understandable as possible. First off, we created for Loop. The for loop is going to be nine long. So it why I smaller than nine there's, ah small thing we need to make sure we need to say we implement I plus equals zero every time we its rates through that this important at this particular point. By the way, now we have another four loop. We gonna name it K. So it's not the order in this case. We need Teoh take care of that in a moment. So it is cold. K. It's also representing in nine and also we implemented by plus equals Reaper to raper it oration. Now we have two other ones which A nested into this well, which represents the values in between those and we gonna make it so that this one is going to be no l and we have, ah maximum of three values per duration Over here, we can also name A J Basically doesn't really matter. Gonna name a day because probably it's easy to understand And we iterated until three and increase once. No, we have another one. Another four loop over here, which is going to be our l for the name is going to be l and we only it's a raid up until three. Over here. Swell. So what's going to happen over years? We go and big stops us through the complete gridded first made between K or J and K in this case, and we always say, Okay, we hope always three steps. So 012 Then we do a big step. Basically, we hope from zero 23 in this case. So what we now need to do is about the same. Over here we do this like we go in big steps through that complete grid, basically, and whenever we found something, then we go in small steps in between those and see if there are any matching pieces and these matching pieces need to match this particular values over here. So what we now need to do is of course, we need to do some requests. In this case, we gonna dio something like if grit moving close square brackets, I plus J. And then we say comma que plus l. If those numbers equal the value one them. We have a match. So and mathematic calculations is basically whatever this numbers are, we add them together and see you if and and see if I entered a as well as K and l are doing the same and do match the same value, whatever it is, if we have a value off eight, then of course, we need to see if this whatever we find in the first integration matches the same in the set. Second adoration, basically. Then we gonna see Okay, The value one has been matched over there. We're going to do the same stuff later on. Was value to us. Well, what we know want to do it. We want to store whatever we found inside X and Y coordinates. In that case, we say X one is equal to I plus J So whatever the result is and same for the y value. So why one is equal to K plus l. As you can see, we always take the out of one with the inner one and same here I plus J and Skay plus l whatever. These results are unknown stored into why and j values whenever we add both of these values together. So now we're going to repeat the same stuff over. Yes, I called me this part, but we need to do this for value to so we change here to value to the calculation states the same. But what we now need to do is of course, we need to change the accent. Why coordinates to be x two? And why to so that we gonna store everything about the second value in this situation here as well. Now it is important that after you are reaching the end of this for loop. So the search for loop of a here, we need to put in the values into the grid. So what we need to do is we say grid and open close square brackets X one comma. Why one is equal to value too. So we switch now the values from this to be this and vice versa. So what we know can do is the grid in x two And why to is now equal to the value one. So the one we just found. So now we can actually suffer the complete grid just by looping. Throw where it was thes 44 loops over here. Why do we use three over here? Because our big cells are a three by three and our huge fields nine by nine. But we hope over every three steps so we don't intersect into the small fields. Over here. You can do the calculations on your own and you get we'll find out how this is going to work. We can also do a quick check for this, but I guess we're gonna do this in the next video 9. #9 Completing the Shuffle: Welcome back to the course in this part. We want to do a shuffle off our board and let's see how this is going to change accordingly . Let's open have our board script and let's open on one shelf a great function. What we need to do is, of course, we now need to call the mix to grid cells from the supple function. We just need to put in all this argument and call it so we say mix to grid cells open source. Prentice's. Now you can see what we already need, but first we need to reference a grid so we can't say Rev grid. The 2nd 1 is going to be our value, we already calculated. So value one, I always said, Comma value to, Since this is the second value of you already calculated over here in the rendered range part, make sure you dual that inside the follow up because, according to the shuffle amount, we do several different amounts of shuffles. Don't forget to say the script and let's go into the start function in start after we're done was devouring the grid and initializing the grid off course. We want to shuffle the grit so we can say shuffle grid. And of course, we need to reference the grit and tell how often we want to shuffle. So what we gonna do is we reference the solved grid comma. And then now we should say we're gonna have a shuffle amount off, one they don't. You're gonna changes to 10 or whatever your please. And like also, after we're done with shoveling, we want to make sure that we're debugging the referenced grid. In this case, the salt grid will be referenced. Let's go back to unity and see off if the compiler has any problems. If not, let's check it out and see how what is going to be shuffled. I'm gonna open a new tab over here for my or new added a window. I got a copy, the original one already, And put this in here so we can actually talk about the shuffle directly. Now I gonna press play and let the board being shuffled ones. So this is now a shuffleboard. The 2nd 1 I got a copy. This this will and bring this also inside my editor over here. So what do you know can see us. What directly has been shuffled, for example, As you can see, this number, the nine and the five has been shuffled at this point also. What does it mean is this nine here has also been shuffled with this five and in here as well. This nine has been shuffled. Was this five? So the boasfirst random numbers have been five and nine and those have bean just shifted around. And we did this. Do it through the complete board. Why did we do this? We do this because we want to avoid doubles. So whenever we're shifting the five and the nine in this particular case through the complete board, the complete mathematic calculations is not going to be destroyed once again. Same. He and nine and five has been shuffled. And since we did this over here, as you can see here, this five and this nine, if we wouldn't have do this this way, we would have two nights in a row right now. But since we shove it that two numbers by nine and five once again, you don't have any doubles in the row or even in the column. And that's how you can makes it completely without having any problems. Now let's check out what's going to happen if we do another shuffle or at least maybe 10 different shuffles. I gonna press, play, let it shuffle 10 times. It's going in a split second and now this. It can't see you gonna copy this complete board of the year and bring this into my editor window again? Gonna maybe bring this some lines below, over here. Now we can see this board looks completely different right now. The only thing which I currently see is that for 19 is going to be always forward nine over here. But I believe it will laid on look completely different. But also you can see one from 95 is going to be always in the same. Yeah, is set up basically. But the player do not know this and never, ever will be. And I believe the next board is going to look completely different because they are complete. Different numbers shuffled around. But what you can also see the same procedure or the same principle is going to stay the same. But once again, as long as the player do not know this. We don't care, so I can't see. We have always the same sets off numbers being shuffled the way they are. 10. #10 Creating the Riddle Grid: Welcome back to the course in this part. We want to create our riddle grid. First off, open up your board script and we need to create a new function for that. So it is avoid create riddle grid. I'm gonna make a big G over here. Open close, curly braces. What? We want to do it. But first we want to treat add or Ashley. Copy the solve grid to being inside. Ah, new complete new grid. To do so, we need to create a function or as a new interview. Uh, array was the same rule set. Basically, I named this one riddle, grit, and, of course, we initialized that are ready to being an interview. Array off nine by nine as we did was the salt grid. Don't forget to save. Now. What we need to do is we need to have a Nintendo over here on how many pieces we want to raise from our little great so pieces to erase. This is just a number we're gonna set up later on for erasing pieces from the riddle grid. First off, we need to copy the solved grid. We cannot do something like Riddle Grid is equal to solve grid because soft grid will also change later on whenever you do this In that case, we need toe copy this one by one just by looping through the complete playfield or so great and Kobe the values to the actual riddle grid. How do we do this? Of course. We take to four loops over here with length off nine. And of course, we're gonna do this. Nest it. So we go to J End or actually why? In X X is in the board or Ryan Jane, this case doesn't really matter. Once again, this numbers need to be nine by nine. Because that's the size of our field. Now what we dissent is little grid inscribe rickets and always say I come a j And now we set this one to be Whatever the solved grid at the same values has are equal. I come a j over here. So now we have Kopita. Everything inside over solved grid into the riddle grid. The next one is who want toe late on a set difficulty. At this point, I gonna make a command of the year so we don't lose track. But now, after we sat at the difficulty, I gonna create a function for this later on. We also wanted to erase some fields so erase from Riddle grid because these are going to be the numbers where we want the players or which we want to play us to find out later on. Now what we can say is we create a new fall over here on we loop the amount off pieces to a rice. So how often or how many pieces off to rice we gonna have over here? Probably something like 35 later on as an easy mode. And we gonna make sure that we create at first a random position like an X and A y coordinate once again. In that case, we created new X one and set this to be equal to random dot range between zero and nine. Once again, nine is ignored, so the highest number will be eight. So we go through our complete array. In this case, was discord in eights randomly and pick from that. So we also have Why coordinate? So why one is equal to random that range and the same values between zero common nine in this case once again. Zero and eight is the highest Number eight. Now what? We want to make sure that we're not overriding some would already have a zero inside of them. It's like like a zero value to do so we created via loop inside of this follow up. So while the riddle grid we found with this random number with the numbers off X Y come on . Why one or x one? And why one if these are containing zero already, we want to reroll, and we want to make or create a new number over here until we have all 35 completely deleted or erased. I got a copy this inside, but get rid of the integer over here once again, if we have and no found or if there is a zero over here, we want to reroll until we find one with out a zero in between. So that's why the wire loop is going to be important over here now, once we have found one was not a zero inside. We want to set it to be a zero. So ones we found one wiz no. Zero. Then we want to set it to be a zero. So we update our little grid over here. Riddle, grid X one comma. Why one? And we want to set its value to be zero. So that's why we want to avoid and reroll until we have another field. Because we don't want to have, like, just one field changed to zero always because it just did not met complete functionality of here. So that's basically everything. How we reroll that or were actually we how we empty some fields, whatever the amount of pieces to raise is going to be until we have done was that and we once again we re roll inside this wire loop until we're done, and then we're gonna do the final step over here. What we want to do is, of course, we want to debunk that so it can say d buck riddle grid or debunk our grid. And we reference the riddle grid in this case over here so we can see what's going on over there. The final step is, of course, we need to create the riddle grid after we're done was shoveling the create so we can't say in this case, create riddle, grit and what we want to do. Us. Just open close Prentice's and close to land with a semi colon we don't need to reference and a great because we do this directly over here by copying the solved grid into the red, a great in the first place and the debugging What happens inside of this? Well, so what we don't need as this d back in line over here because we don't need to debunk the grid after initializing that we already know what's going to happen over there so you can completely basically get rid of it. So we only initialize the grit over there, and we debunk that after we don't want shoveling as well as after creating the riddle grid later, when we get rid of the complete debugging lines or debugging function for now, since we don't have any play field at the moment, we do this directly here in our D buck or in normal Consul. Since we don't have said any erase amount, we need to make sure that we for now just set a number over here by hand off 35 off pieces to erase, let's press play and see what's going on. As you can see, we get a field created. I gonna copy this once again into my little editor over here so we can read it better. As you can see, some numbers now have zeros. So whatever the board is going to look around or look about, we don't know what's going to happen with these numbers. And now you can also see you cannot predict which field is going to be what feel, because they got rid erased. Also, you can take some calculations here. Or you can ask to count all these numbers a lthough zeros and make sure that you actually delete it. 1% Lee. 35 numbers. So we can do this rather simple. As you can see, we just go through this alliance and count all these numbers. I can promise this are going to be 35 zeroes now inside, Over here. Once again, you can count it on your own if you don't. If you like Teoh just to see this, you can of course, see that they're something probably matching over here. Since we already have seen that as something is going, Teoh, you know, repeat itself. Also you can see that this numbers over there I'm going to repeat, and probably that's going to be four. But once again, this is something which you need to, you know, take care off on your own or so you can see 865865 Also, this is going to be over here, so probably this number in the middle. Here's three as well as this one. But once again, this is what the player does, never know or usually does not know, depending on how many you doesn't delete light on from the board. If that is the easy one, it's going to be harder and harder to predict what which number is going to go where. 11. #11 UI The Playfield: Welcome back to the course in this part. We want to start to create our complete user interface with Lisa. First the board and all is course bonding informations about it. I'm gonna reduce my screen a built yes, so I can see the actual scene view a bit better. Since this is going to be my play board, I'm gonna make this one. Baker can hold on shift and go over the corners of the year and maybe center this one over there. You can put it wherever you like. You can make the plate it on the left to put all the informations like hint, buttons and stuff like that on the right side or vice versa. You can do everything about that on the left side. Or you can just simply center this one and put everything on the left and on the right or just one of the others. Since this is the main part of a here, I guess it needs the most space. And of course it has to be the most space over there, so nothing fancy at all. Make sure it's kind of squared. If you are unsure about that, check out the height and the width of these numbers over there to make sure it's kind of squared. What we know want to do. Since this is basically just my background off the field, I want to have more fields inside of that. We can do some calculations. I gonna put some and the numbers of a here a bit more straight so I can do my calculations on these numbers if I need to. First off, the easiest way to put all these cells from a 123 b wanted three C wanted three into a correct order. We can make use off a grid layout, group, cell type and grid as add a new component and call grit layout group Everything which is now child or being child off. This board is going to be grid. Layout it to see it better. I introduce a black background for my playfield, and now what I want to do is I add another image, and this image is going to be automatically resized toe. Whatever the grid layout. Saiz. I need to drag it a bit, so it's snapping in position. As you can see, I also cannot do anything to the size over here. I cannot drag it around because, as you see, the somebody's are driven by the grid layer group, which is great because we don't need to take care of that on our own. Basically, what we need to do is we need to fill in three next to each other. So for now, let me just copy that two times by care hitting control D and I may be want to attend them , read or anything? Anything else basically doesn't matter. You can light on make or your own colors in that you can make a blue, red, green whatever. So what I want to have is inside our board. In total, I want to have nine, so I can basically just take these ones and duplicate them again. As you can see, the grid Leo Glue group just fits them quite well over here, and it does not overdo it. So what we want to have as or what I want to have is a spacing between those cells off maybe five. So we can't see easier what these cells are going to be about. Ah, but left is totally fine of a year. and I can also go to the padding and let a padding or five to the left and five to the topics world. No, I need to fiddle around with the size of the cells by the cell size basically over here from the girl grid Layer group. You can play wrong with these. You can also do your mathematic calculations, like taking the full with negated by five from the corners or the sites as well as by 10 from the span or the the parts in between over here. So have a total off 360 straight. And you can now take this number 300 a six x ray or 36 336 and divide this by three. Then you have a number off 112. So this number should represent the complete size in height and was off one of these cells . Once again, you need to make sure that the whiz and the height are going to be off course squared. And let's test it out. Is that is going to work over here? Somehow it doesn't let me. So I gonna have to put it in by hand, 112 by 1 12 s. I can see calculation works pretty good. So if you have a 300 by 300 of course it needs to be smaller. Bigger, depending on this, once again petting, you're gonna have once again, this works only because thes are, you know, numbers which are divided ble by three. So take care of that. Also, make sure that you always implement the corner sides as worse. There's parts in between into your calculations or just type of numbers and see what fits you. Where you best? A basically. So what we now need to take care of it, that we rename all of these. So this is going to be compartment a one. This is a two. We need to make sure that they are all renamed correctly because NATO and we need to reference them. So this is going to be a four. Oh, no. In this case, it just be one. This one is going to be be to. This one is, of course, be three. And the last three are going to be C one see to and C street. So this is our basic writ we're going to put on a stuff into now since we know this is 112 and we need to fit in three buttons from left to right and top to bottom because that are our excess points for click ability. We can also do the calculation over here. We don't know any distance between those buttons, but when we divide that by three, then he can't see this strange number over here. So probably we find a number which fits best as well as fits inside our, you know, grid off this 112 in its total size. But we can probably take numbers like 35 or something and put a good padding between them, and they should be fit over there as well. But that's what we're gonna take care off in the next video. 12. #12 UI Number Buttons: Welcome back to the course in this part. I want to put in some buttons inside our one off our grid cells and see how they fit. And, of course, want to create a bit more stuff with these buttons. First off, we can write blank you I A button. So we want to add a button to this. Since in the last video we did a calculation that it could be something like around 36 37 something we can put in 37 height and wizard first. Also, what you want to probably do is already is put in a number in the text field in the button and already said it's up so that it looks good for me. I always like to use best fit. I go from normal to bold and its fund. And as you can see in the game, you it's rez, a quick or rez, a big number, and I will probably want to change the text to full black as well. Maybe I want to go with closer and reduce the number by I don't know a bit, so it's not looking too big and not too overwhelming. Light on. So this is one of my buttons right now, but a one does not have a group layer group, so we create one Gridley a group. Now it says that automatically toe 100 by 100 which is actually not the number we after. We are after a number of something around 36 or 37. So I reduce it over the enter the cell size, take the button and duplicate it nine times. As you can see, it does not fit 100% but it's rather close. Let's go to a one once again and see if we find a way to actually manipulate this cell size numbers. So they're looking better. Probably we can also take care off a spacing with one or one point something, maybe two. So they fit better in our total grit. As again, see no was the spacing of two in between. It's quite close and doesn't look too, too shabby at all. Also, we see still the grid over here as well. A see the blank part over there as well. That's good. Now we can take care of the other buttons and basically didn't delete them. We go to a one. We let the last button we keep it that we need that still on. We now want to copy all the components or the component off type group player group, select all the other panel over here and press on the gear and say pace component s new. So all the other panels a two up two C 32 all have the same layout. So whenever we take this button and bring this NC two, it will automatically at the same parts or the same issues or the same set up s the other one s. Well, it's good. So now we are able to fill in buttons automatically by our grid system late on and fill in all the corresponding data into this and fill the complete solve grid, for example, or even complete riddle. Grit and see of the numbers are going to be the same as recalculate down below. Before we do that, we, of course, need to create some other scripts. But we're gonna do that in the next videos 13. #13 Scripting Number Buttons: Welcome back to the course in this part. We want to set up our buttons so that they're able to get information and we can also talk later on back to the board and see what's going on over there before we do anything. First, I want to create a new folder where all scripts are going to go into. So we keep everything organized. I drag board Inside Scripts folder. Also, I create a new C shop script and call this maybe number field for number button. So this number field a group presents later on the connection to the button and all its course morning data Well, we know want to do is of course, we opened this one up and mono develop over just studio. Once it's open, we want to get rid of starting update, since for now we don't need them. What we need to have is at first a connection to our board so we can to say board and we can name it. Just board was a small B. We're gonna put in all this data later on whenever we create these buttons. So we hold to connect into these fields or buttons or whatever in, um, we can ask the bring back the data without any problems. Also, what we have is all the coordinates where our button is coming from onwards asked came from So we can talk later on to the riddle field and updated based on this particular you know, coordinates. In this case, we have a next one and a white one value. Also, we want to know what it is a current value off this particular button. So we need an integer off type value or was the name value also, we can make use often and identify her so I can name something like string identify. We can also nay and take an inter job basically doesn't really matter as long as we are able to identify who is going to be what. And also we can ride this identified directly on the button. So we see what are the coordinates off this particular button and identify in this case. Also, we need us a connected to the text field on this particular button. It's of type text, but as against see Texas not available so we can actually say we want to add the name space unity engine, don't you? I Since I don't see this, I'm gonna added over here by hand. So using unity engine, don't you? I for user interface. So now a text become available and we can just name it number. So this is our number field where our tax Why our number is going to be shown now. Since we want to have access, we need to create a public function for the excess directly. So we name it public. It's of type white, and we want to set values over here. So I named the function set values open, close parentheses and inside. We need several arguments at first and intelligent was the coordinates in this case a name . It underscore X one. So we don't have any problems later on. Was that ah, wizards switching the numbers between back and forth. You will see that in just a second. Also, we need another integer underscore. Why one so they why coordinate that? We want to have an underscore value for our value as well as our it identify air. So in this case, it's a string underscore identity fire as well as our connection to the Playfield So our board again a name it under school, board whatever. And of course, open close curly braces so we can put in all this informations. So whenever we call this function, we're gonna put in all the values and tired of it. So we say X one is equal to underscore X one. And now you see why we're gonna taken it. Underscore over here. So we don't mix and match X one and X one, so otherwise we would have a naming convention problem. So now let's update all these other values as well. Why one is going to be equal to underscore why one also we want to set its values. So we say value is equal to underscore value. And of course, we're gonna do the same for the identify air as well as the board. So we say identify air is equal to underscore, identify, and then we have the last one once again is going to be the board so we can save board is equal to on the school board. So we know have no ah issues, actually, later on, when we're creating all of that, what we also can do is we can instantly feel information about the button directly inside the number field if we like to, because we are setting this one up already. So no problem at all to do this. What we do is we gonna use an expression which is calculating if there's zero or not. So at first off, whoever want to fill in is the number the text field. So number two taxes equal to and now our expression comes when or if our value is not equal to zero. We gonna say question Mark. Then we put in the value daughter to string once again. This is an inter job, so we need to convert it to a strain. Otherwise so, colon, we're gonna fill in an empty strength. So this expression now say, is fill in the number or the text into the number field over here. If the value is not zero, then just bring the normal number, which is not zero number. So if it is a nine John just filled in as a string otherwise make an empty field. So we don't see the zeroes onto our playfield. So this way we avoid that zero is going to be visible on the playfield, So, as always, Oh, as you never see zeros inside this Ah, your games. We're gonna make just sure that these numbers are going to stay empty. You can also put a space in here. Basically, doesn't really matter. We just want to have an empty string if the value is equal to zero. So that's what we do over here. Also, when we want to do us, if the value is not equal to zero off course, they would want to set the buttons, interact ability to be, not interact, herbal. So we cannot collect on these because thes have fixed numbers already. So basically, we can do the same as we did over here as well. But the point is, the expression would be be different in that case, are gonna take an if statement. So in that case, if the value is not equal to zero, so it is 123 something like that. Then we want to get its components or at one component in parent. So since the text is child off the button, we need to get the connection to the button first so we can say button open, close Brandis ease, not interact. Herbal is equal to false. And if that is not the case, we can actually tend the number color to be colored of blue for examples. So we can't actually see that. Ah, later on, we're gonna show you what's going on. So we say number don't Color is equal to color dot blue instead of black. Currently, my numbers are black, so and these ones which are changeable later on, do have a blue color tint. So everything which has not a zero once again. So don't forget to save the script, and later on, we gonna see all of that interacts. And what we don't want to do is of course, we want to drag number, field onto our corresponding button and set it up. So since we don't have any click or button, click your functionality over here. We gonna do just put the number field yes, script directly onto our button. For the moment, what you also can do is already you can take the tax field and bring this over here because this is showing us or giving us later on the connection to the Playfield, and it will automatically update the taxed inside of that 14. #14 Creating The Buttons: Welcome back to the course in this part. I want to start toe asked if create all the buttons inside the corresponding ply fields, open your board script and let's go up Pretty. For first off, we need to have a connection. Toe all these big cells, like from a one a two s three and B 123 C 123 These need to be public. Since we need to drag them in by hand. The are off type transforms since we want to parent our created objects or buttons directly to these transforms. In that case, we're gonna have to create a one a two and a three. And we're going to need to do this for B one, B two and B Sri s well, as well as for C one, C two and C three. Pretty simple. Just tied them all in one line. Make sure you don't have any doubles or any year spelling mistakes. Make sure they want us three b 123 c 123 are in that Once again, we need those to be our connection to this. Also, we need to have a public game object, which is good representing our button prefab. We're gonna create this buttons off basically directly over here. So we have a connection to these and can basically fill in all the corresponding data on creation If it would pretty create them, then we need to reference 81 buttons. And I don't think that is what we want to do over here. We want to make a life easy and simple. Next one is we need to create the function which is actually creating all the buttons whenever our riddle grid is done. In the case, we say Boyd create buttons is our function name. We don't need to reference any, Grete, because we're going to do this directly inside the function. Anyways, what we now need to do is we need toe off course it right through all these buttons or through all those grids. So by going with a full loop again, so foreign. I mean, while it's smaller than nine, once again, same numbers, nothing different. Same here. We're gonna take it, Jay, which is going to be nine in this case. So for in Jay's equal to zero yj smaller than nine, we increment day now we need to create these buttons. So it first I create a reference of the button because it's easier. Meanwhile, we need to talk to it. I'm gonna call it New Button, and I can set this one to be equal toe instant. She ate. Now what do we want to insensate is, of course, our button prefab. We don't do anything with the transform because we need to make sure that we put all the correct information into this later. So when we now need to do is we need to set or values to the button whatever we have created. And after that, we're gonna do the parenting into the corresponding fields. So first off, we need to catch the number field, so number, field, we can name it, whatever we like. Numb field, for example, is equal to, and now we get the component from the newly created button. So new button don't get component open goes trying a brackets off type number field Open those apprentices and close the line was a semi colon. Now we can call said value on the NAM field so we can say numb field don't set values. This is only accessible when it is a public one. So make sure it is, and I guess you got it already. Now, when we put in ISS, the X one coordinate is going to be I. Then we're gonna have the y coordinate was is going to be day. Then we need to have the value. And the value comes from the riddle grit on its current position So it can say riddle grid in square brackets. I coma J So this is the position where we are currently at now we want to have a string identify or so this identify as basically whatever I is, then you can say, Plus, we put some quotes, maybe a comma. So we're gonna take this, isn't I? Identify a pro? We don't need this, but for now, we just implement this. So we haven't I? Plus, then once again, this is a string. That's why we need to string in the center or we need to convert it to a string. And then we add J. And the last one is going to be the board. We're gonna need to only take make use off the special keyword this because this is the board where we are. Actually, you know, asking or we're actually creating the number field from and we access the button to We can also name this button so we can say no new button don't name is equal to and basically we can take the string, identify our as we already did off here. So I plus then the comer and then a plus day. So we see. OK, this is going to be our new name on this particular button. So we see if everything is correct or not. You don't necessarily need this, but it's probably better. So we see if the coordinates are correctly created. Now we want to parent these parts. So we want a parent, all these buttons to the corresponding fields, wherever they supposed to be. Parent the button. But that's what we're going to do in the next video. 15. #15 Parenting Buttons: welcome back to the course in this part we want to parent, although not now created buttons to the course Morning Redfield's. So every 1st 3 numbers go in a than the next three numbers are going to be and be than the next going to be in C and so on and so force. So we always need to make sure that x and y, or in this case, I end J values are going to be correct. So we gonna do them or create them correctly in the correct order to do so. We go into our last video creators, create button sanction and create some off these if statements and requests where we are actually at. So the 1st 1 is we want to check if we are in a one. I'm gonna do some commands for that. So you gonna understand what's going on. So in a one, we're gonna have something like if I is smaller than three, so something between zero and two and why or J in this case is smaller than three as well, then we know we are in the first field. So we iterated from the left to the right and top to bottom. So what we no need to do us? We need to set new button dot transform Don't set parent to be whatever a oneness and we need to say comma false. We want to make sure that this is not related to the world position, but of the local position. So we're gonna keep that in mind, and then we need to do this for all of the other fields as well. So let's talk about a two. I gonna copy that part. So in this case, what we gonna make sure is that X or in this case, the I value is still smaller than three. But now we go through the J value. We want to make sure that Jay is bigger than two. And day is smaller than sex. So it's between three and five. Once again, we always a started zero in this array, so don't get confused by these numbers. These are array based numbers. So if that's the case, we know that we are in field to now. We can copy this a to port over here and make a three out of it. So a three in this case is going to be located still on the X axis or in this case, in the eye letter over here by smaller than three Sofus Reliance. Then we go through day and day in this case can be only higher than five or smaller than oh , I in this case smaller than that. So if day is bigger than five, so it means it's 67 and eight. So we under certain part of their on the right then we're good to go. In that case, we're gonna have a three over here and also a three over here, which is this parent we're gonna set this one into. Now we just need to convert that information for B and C lines as well. So I can Kobe that complete area over here and need to change these numbers. And, of course, all this information. So first off we go to be B needs us to be. Basically we need to change the appearance right now are actually the setting in this case , B for be. We're gonna go and I we need to be like, as we do over here and Jay, we need to be bigger than two and smaller than six. So once again, if I is bigger than two and I is smaller than sex and why a smaller than three? That means now we are in beef. So the first line or in this case, assert force and fifth line on the on the I So on the basically on the Y axis and this one is going to be on the axle from the left of the right is going to be over here. But we are here and be one. Of course. So be one now fits into that. Next one is B two. Be too has a basically the same setting over here. So we copy that part and bring this over here. So what does it mean? Us? These numbers over here going to stay the same because this is now the center of the Playfield. This is now the center of the Playfield. So we are now directly inside the center off everywhere. So day needs to be smaller, bigger than to its more than six. Same here. And, of course, in the last one and be story, we're gonna need to take the same stuff as we had done before Over here. So we copied this port and bring this over here. Of course, this is going to be be to and this is going to be be to And there's going to be be stray. This one is going to be be stray. So once again, whenever we are in the next US reliance. So line 3234 and five. And we are higher than you know five like in the x axis. Then we are in the correct parenting spot. Same for C 12 and three. We copy this complete part over here. Make sure you have B one B two and B Sri changed over here as well. And now we go to the C line. So we started. See, see, once again is a resin simple. We just need to make sure that I is bigger than five. And why is need to be smaller than straight so And of course, we need to change the set parent part of a here to B C one. Next one is going to be the same. But we need to make sure that I is bigger than five, as we already have over here So we need to have everything on tour the bottom basically. And same here. If that is going to be bigger than five. Of course, we're gonna put this over there. So once again, this is going to be a C two in the sea to line over here. Make sure you commanded out so you don't lose trank. This seats raise always this need to be seized three as well. So if there's any trouble with these numbers later on, make sure you just go through them once again. Do it slowly and make sure you have everything. Correct. Once again, this is the basically the X axis. This is basically the Y axis. So this goes from top to bottom and left to right. Don't forget to say the script. And now what we need to do is we need to put in all these fields now into our transform parts over there as well as creative button prefab. But that's what we're going to do in the next video 16. #16 Button Prefab & Board Setup: welcome back to the course in this part. We gonna set up our board correctly so we can actually create pre fabs off our button as well as Fillol the fields correctly whenever we need to. In that case for herself, we goto aboard and you cannot see that I want us three b 123 and C 123 are visible as well as our button prefab part over there. First off, we want to make sure that we get rid off this button, but we don't want to delete it. We want to create a prefab out of it. I go to my assets for the right click and creating new folder and name this one pre fabs the most in easiest way is police. Do yourself a favor, especially when you are in unity to K 19 or took 18 plus where this new prefab settings are going to be. Make the complete settings first, whenever you had done was the settings. Then create the prefab we can later on put in the on click event. For that, we don't need to take care of this at the moment, so I can you can keep the button Name s your like you can also rename. It basically doesn't really matter. I go into my prefects folder, take the button and drag it into it to create this prefab. As you can see, you can always go and open the prefab. But he cannot see anything just because there's no canvas, which is showing you everything about button. So that's why these pre fabs are basically not the good idea. While at least not for two D button pre fabs or canvas related pre fabs. However, we can still change these numbers later on inside, overboard and update the prefab whenever we drag the prefab onto the already existing prefab. Because later on, we're gonna have to do this probably several times. So just keep that in mind. Since we have this prefab now, we can basically get rid of the one into a was seen over here. Just delete it. Also on board. We cannot take this button and drag this into our button prefab slot over a year now, we can also take a want of three b 123 C, 123 and put them into the fields. So just take top to bottom and make sure every field is the correct field over here. So dragged them all and B one and b feel be one field B two and B two field and so on. And so, force, I'm gonna do this over here. You can do this rez a quickly here as well. Make sure you have everything correct. And don't forget to say if you're seen by the way in between, whenever you have done major changes because sometimes unity can, as always, beautiful piggy, he And there now we have all this connections. What we now can do is we can call the create buttons function from wherever we want to buy . Simple. When our crew riddle grid is done of the year, we can call, create buttons, open close parentheses and close the line was a semi colon. Let's see what's going on was that when were doing so let the compiler yeah, run everything and press play and see if our field is going to be filled and how old these numbers are looking. As you can see, all these numbers which are now actually inside overboard, are getting all its names by its coordinates. We also have this identify as directly on these buttons. Also, you can see that these numbers are not interactive. A. We cannot click on this. We can only click on these ones which are white. The other ones are disabled, so we cannot do anything with those. And they are getting a bit transparent over here. You can get rid of that transparency directly by changing all the corresponding colors inside the Barton script. As you can see, the disabled color of a year has an Alfa. You can basically take a full color over there, so maybe a bit darker, grey, and go full color. You can do the changes directly inside the button prefab. So whenever you start the game next time and you don't like the transparency, you're gonna have these fields now completely great out pretty good. We cannot click on these once again. We can only click on the white ones once again. You can also change the color of these. And if we would go and put in any number in this fields, whenever there is a number to put in, the number is going to be blue. As you can see this color has been changed by our script to be blue because this is a selectable field later on, instead of being blank pretty good. So that all works completely. Now we need to have a possibility to click on these buttons, show some kind of, ah, you know, field where we can pick a number from and put into the field. 17. #17 UI Input Field: welcome back to the course in this part. I want to create some kind of input field. So whenever we select a button that this gets activated and we have the possibility to select any of the numbers inside the board and then a deactivate itself whenever we had done was that first off we go to on canvas, of course, and create a new U I image. I'm gonna take this image and bring this anywhere. Maybe here basically doesn't really matter. But you also can do is probably take the same number size or the same grid size as all the other ones for a grit or cell size of 36. So they are probably late on easier to, you know, select. So this is going to be our input field. Inside of that, we create a new grid layer group for all our buttons. Again, we take the same size as we have done already. We can also copied the changes or the copy the complete component from wherever we like always set it up as we have done it before. You can also create your very own input field. You can make a bigger, smaller whatever you please. And like I'm gonna make it light blue. Maybe so we can see a difference. And also, I want to make sure I add a button to it. So you why button? Once again, I make sure I drag it at least once and duplicated like 10 times. As you can see, it has a difference now the spanning or the pedal spaces in between may not fit my in my actual, you know, design. So in total, first off, I need to make sure my input field has a wizard of 112. I guess so. It fits a bit better. So what? I want to have us, like 10 fields 1 to 9 and an empty one, like for the zero. So I gonna have to duplicate this until I reached this point. I can also drank the image over here to fit the needs, but I need to make sure that the image or the input field is at the moment selected. You can also make use off a canvas group of you like to, but you don't necessarily have to. There's one more thing we might need to take care off is to canvass itself. But I guess we're gonna take all of these parts pretty quick to do the Sphinx and direct them outside the canvas. Now we change the canvas from concert exercise to scale with screen size because this is important later on. And now we dragon back or the information's. Why did we do this? Whenever we maximize on play and press play, you want to make sure that the complete field in full size is going to stay where it is Now we can just fill in all the informations about these buttons. Since we know the size of ready, we can now get rid of all that stuff. First, I take one of these buttons and design them so that I like him by sample. I gotta put a number in here, and you have to do this basically on all these ones because we don't We asked. It could automate that, but it's not necessary. I'm gonna make a dark blue color for this number. I go to best fit bolt, and maybe I reduced this number field once again, as I have done before, with the other ones as well. Also, I can rename this button to be a one. You have to do this right now once again for all these other numbers over here. So I'm gonna do this 10 times. So this one is going to be my number two field, and I need to once again go into the tax element and change this one by two or two to once again. We can do this by coach, but actually, I don't know what's what's easier. So I renamed this one to be three and put a text three in here as well. So you can go also on the top over here. Put the four put the four and so on. And so, force, this is a bit stuff we need to take care off. But actually, the rest is going to be once again a simple and the other parts. This is a one time thing we need to take care off. So that's just simply do this once again. If you want to do this by code, you're absolutely free to do so to create all these buttons with all its corresponding numbers by, you know, looping through and adding, Ah, taking I as a full when you agree. No, take a fall up over here. Then you're gonna be able to, um, start and take I as a literal indicator for this. So important is that the last one of the here is going to be a zero. So this great team in my zero button, but the text over here needs to be empty. So no text on this because we never want to see the zero on to our button over here. So once you have done that, of course, we need to do some changes to all of these bother. This is just a rez. A simple one. We're gonna take care off a bit later on. Now we want to make sure that we are able to activate the complete input field with all this and corresponding numbers. And, yeah, drive a connection to this. But that's what we're gonna take care off in the next video. 18. #18 Scripting Input Field: welcome back to the course in this part. We want to start to activate and also designed the script for the input field. First off, we need to create a new C ship script and call those input fields you can name it wants once again, whatever you like. And please, I'm gonna make sure that once the compiler is done, running was the input field. I can't directly drag it onto the import field over here, so just drag it somewhere in between. Don't forget to say the changes and open the script up and mono develop or visions Studio s your police. And like once the field is open, we want to make sure that we get rid off update loop because we don't need it. We only need to start loop or the start function. Also, what we need to do is we need to create a aesthetic identify or aesthetic excess er for input field so we can easier excess it. In that case, it's a public static on the name is going to be the script name input field and would create an instance off that so you can name it basically whatever you like. But what we need to do is, of course, in awake we need to set the instance so white, wake open, close parentheses and then open close curly braces, we say instance is equal to this. So make sure you only have one instance off this particular fields or this particular a script in your scene In start, we want to set this one to be deactivated. So this dot game object don't sad, active and an open close parentheses. We're gonna set false. I want to deactivate this particular complete input field and its object, Toby not visible. We also want to have us. We want to activate or haven't access er for being activated from any of our other buttons . In that case, we create a new public function off type, void on. We can say Activate input field and what we want to bring in is the last button or the last number field. Where would this become excess from? So we put in a number field field inside over here, or we can also say last field, since its gets over written by whatever we need to, we need to bring the last field off course inside off our activate input field. So we create a new reference number field. I just name it Field. You can also name it last. Whatever you like. Well, we know want to do is we want to activate this game object whenever we activate the input field. So we say this don't game object don't set active open toes fantasies. True. So we activated also what we want to set ISS. Last field is equal to field, so whatever the incoming field is gets activated and we gonna store that in last field. Why do we do this? Of course. We need to talk back later on. Whenever we click on one off this corresponding numbers to do the click input over here, we're gonna need to which we asked the call from all these buttons from the one to the zero . We need to have this function calculate are created over here. In that case, we created you public void, collect input, and what do you need to bring in is an integer number. So this number is going to be called from any off these particular buttons According to whatever their numbers are on, we want to do us. We need to Of course, bring this information back to the button toe the last field. And we also need to deactivate the panel. So I gonna say deactivate the panel so we can say this dot game object dot Said active, open, close parentheses force. So we always a deactivate this complete field whenever we don't need it because that the input has been basically done. Now we need to do is we need to create an input possibility inside our number. Field an update. Whatever is inside according to whatever the collect input ISS. 19. #19 Working Input Field: welcome back to the course in this part. We want to make sure that the buttons on our board are activating this panel. This panel also can talk back to those and deactivate itself. Whenever we have made any inputs to do that, we need to open up our number field script first and there. We already said this values and we're gonna have all I our identify us inside of these. I want to creators at first a button click faction whenever we click on this button that we call the input field. So in that case, we create annual public Boyd a button click open, close parentheses. I'm gonna make a big B in the beginning because it's a function for me and when we want to . So is or actually activators. Of course, the input field we have created in the last one. So we say input field thought instance dot activate input field and the last number field we're talking from is this one. So whatever the button is, we are actually taking this click from and to is going to activate this input field. That's nice. Now we just need to call, actually connect our one prefab with the button click event. Also, where we want to do here is in our number. Field is we want to receive input from the input field. So we create a new public wide, and I named this function receive input. The input we need is the new value. So we say end, underscore or just not understood, but new value. So the value we gonna get from the button click from inside our button field. So basically from the collect import based on this number, what we now need to do is of course, we need to set our current value off this particular button to be equal to the new value which is currently coming into. Also, we want to change the text so we can say number don't text is equal to whatever the value is if it is not a zero, of course. So basically, we do the same as we do in a set value. Over there, we created expression. They say value is not equal. To know is that is the case we say question Mark, we gonna take the value and converted to a string only close parentheses and otherwise colon we're gonna fill an empty space because we don't want to see any zero values. We want to see only empty villages when there's no numbers inside, or basically a zero number is going to be picked. Also, after that, we need to update our riddle field. We're going to create this function later on. But for now, that should be enough to receive the input and update the tanks according to the input field, Let's bring that stuff together. First off, we go to our input field answers we have already on what clicked input over here. In this number, we can also go into the script pretty quick in the end put field. And before we are deactivating the panel, we can now talk to our last field and we can talk to the function we just created for receiving the input from the value so we can say receive input. Whatever the number is. We're gonna sent into this this one over here, so we update the button accordingly over here as well. Now let's go back to unity and set it all up. Come completely correct. Let's go to a prefab button, scroll down until you find the on click event. Click on the Plus and Dragon the Blue button itself. Now what? You want to take us from the number fields you want to call button. Click so button. Klink once again does. Activate the input field button. Click import field incense. Activate input field. Make sure you do this. You don't basically don't have to do anything else in input field. Wherever these four buttons are, we need to create on or nine or 10 buttons. We need to create all on click events over here as well. Select the mall and then dragged the input field into the on click event and call the function clinked input, and it requires an interject for us to put into this field. The Inter jail represent is represented by the number on that. So we just go read a quickly through and set these up. So this is the one A to a three for life six, seven, eight and nine. You don't need to touch the zero because zero states as it is, don't forget to safe the scene and let's press play the input. Penhall now should be deactivated on start, but whenever we click any of these buttons it should activate. Also, whenever I now click any number, it should deactivate and update the field according lead to whatever the field has to be. For example, what what he can also see now the Texas one and also tanks. Now, this information from this input fear we can always change it to any number. And we can also do this wherever we like to on any off the other fields over here. If you don't like the color scheme, of course, make sure to change it to your own needs and to your own, you know, design decisions. You can make everything white, black, grey, whatever it ISS just to make sure everything works so far. 20. #20 Update Riddle Grid: Welcome back to the course in this part. We want to update our riddle grid whenever we do any change or any input from the input field. You already have some functions for that. But the only one we do miss is the board scripts functionality. To update this to do so in board directly, we created new public Boyd set input in riddle or something similar. You can also say in Riddle Grid what we want to put in is the X coordinate as well as the Y coordinate as well as the value. So we say in acts and why and in values, though these are the ones we want to set up. Also, don't forget to put a comma in between now What we want to do is we want to talk to the riddle grit. So we say riddle grid in square brackets. And now we take this inputs, we gonna get over here x comma y, and we said it to be equal to the value we just sent into this function. Now we just need to make sure that we call the set of input function from the input field or, in this case, from the number field. So wherever we received the input from our input field already we need to update the Riddle field. And since we have the connection to the board because we were setting this one whenever we were setting the values completely off this particular button, we are able to now talk to the board directly without finding it. So we can say board dot sent and put in riddle grid. And now we just need to fill in all the information we already stored over here as well. So in that case, it's X y and its value So x one comma, why one comma and its value Don't forget the underlying was a semi colon. And now we can also update the riddle grid and we can later on check against the solved grid. If one off or all of these numbers are going to be correct, don't forget to say the script. Also, don't forget to save the board script where we just created the center input riddle grid and we had done was that part over here 21. #21 Difficulty Levels: welcome back to the course in this part. I want to implement a difficulty level for the game to do. So we gonna open on your board script and implements a more functionalities. I gonna put something like over here just to make sure you know what's going on. So to the easiest way to bring difficulty in as probably using an in, um, an enema is nothing else than an integer ray bunt with string access er's we create a public in, um and we call this maybe Diffie cruelties. What we can put in these difficulties now is all the difficulty want to have or set up into . So, for example, we can put a d buck difficulty. So it's just for us for testing purposes, then an easy mode, a medium moat and, of course, the hard moat. You can also put in an insane mode if you like Teoh once again, all of that is up to you can put in and the difficulties for that as long as you know what you're doing. Of course, Now we need to public excessive for this as well, so we can't say public difficulties, and, um, we just name it. Difficulty something like that. So now we can attain the difficulty level directly from the inspector just by using this public excess er. Now what I want to create is a new function which is doing all the settings for us whenever we requested and the request it is going to become. Whenever we are basically creating the riddle grid, we already have, ah, notification about that. So to do so, we create a new function, and I gonna make it so that it is a point set. Difficulty open, close parentheses. We don't need to do anything over there. We don't need any arguments, so well, I want to introduce over. Here's a switch statement of switch statement is nothing else and if else if else if else statement. But in that case, it's easier to read. So what do we want to sweat is, of course, difficulty. So in switch, we can have a different cases, and the cases are the cases from the Inam off here, like case a D back, easy, medium heart and insane. And based on that, we can put in any numbers for our pieces to a race currently that settled 35 because he wanted to have any number. But let's create these cases. So in case off the difficulties, don't d back. Then we need to set a colon after this, and now we can put him basically anything we like to. For example, we can say you race or pieces to erase its equal to five. Once again, that is up to you. Then we need to break out of this or to break this particular case. And now we need to create a new case like basically all the other cases we already had before. So in this case, we're gonna take difficulties. Don't easy, colon. Then we can say pieces to erase. It's equal to We cannot put in something like 35 the super easy. Of course, since you know that already, don't forget. We need to break out of here. Next case is going to be the difficulties, and now we can take maybe medium. The order does not matter. You can basically border this to whatever you like, but maybe it's easier to read like that. Pieces to a race in this case might be 40. You can make your own rules later on. I just give you a headline over that. The next case is probably going to be the hard one. Colon, don't forget the colon. Otherwise you might get problems. Peace is still raises. Maybe 45. I don't know. And don't forget you have a total off 81 pieces on the board. So the more you race from the board that the harder it is going to become, probably some might be unbeatable. But you can introduce something like a hints and stuff like that. So the last one is going to be our difficulties Insane and insane. Might be pieces to arise. I don't know, equal to 55. So we don't have much pieces left. Maybe that's too easy. Maybe it's too hard. We don't know. You can also put in a default case over here, but I don't really think that it's going to be needed. Don't forget to save. And now we just need to make sure that we call a set difficulties whenever we, you know, create the riddle grid. In that case, we open create riddle grid and whatever our commanders over here, like after we have copied the soft red to be inside the riddle grid. And wherever I have my command over here, I'm gonna set difficulty open, close parentheses and close the line was a semicolon. So this number over here gets overridden, and then we gonna go into and erase the number off Whatever has been said before inside, Over here we can test this one out. Easy we for Don't forget to save and let the compiler run and unity, and you should get a drop down menu or list of. But in something like that inside the board, as you can see down below there as a difficulty debug level. And since debug is no activated, we should only see five pieces erased. 12345 If it is going to be insane mode because the player likes insane, hard or in saintly heart of riddles or particles, then you're going to get something like that. And you don't have any idea on how this is going to be solved. You just need to take care of the and check it on your own. For example, Now I can see Okay, we have 80 and this row eight in this row. So somewhere here here or here? Well, no. Here in one of thes to ones that are going to be an eight once again, the player can later on. Decide of that is going to be in a door that is going to be an eight, but that is how we can set the difficulties for the moment. 22. #22 Win Check: Welcome back to the course in this part I want to discuss How can we ask Lee, make the play attack. If they are correct or not, we can introduce a little button for that. So the player has the possibility to select this button. Click on it. And of course, the bottom will check if the board is completed or not. In that case, we go toe on canvas and go to you I and create a new button. We can put this basically wherever we like. We can make it as big and the small as we like. We can places directly over here next to the Playfield. We can put it on the other side if we like to. And so on. And so force. So I'm gonna put the button over here, maybe make it a bit bigger. So it's easier to maybe touch on if you are using light on a touch input and we're gonna name this for check. So also, I want to make it. 1 may be bald as well as best fit, and also I want to make it more or better readable. You can also tend. Think of the text to whatever you like. And police are gonna leave it black. And I reduced the size of the text field a bit and bring this up a bit. This well, so this is going to be my check button. So I'm gonna rename this button. Otherwise, I might not find it easy on later on whenever I work through everything. So whenever I want to click on this Anita off course, have a non click event and meaning I need to talk to the board. Anyhow, In that case, we need to open on your board script first and create an excessive function to actually check if we have one or not. How do we know that? Actually, we have to screw to grits. Where the solved grid and the griddle grid. Whenever we compare these two, of course, we get a result off drew or falls. But how do we actually do this? At first, we need to have an excessive from our check button. In that case, we say public void sank complete. Oh, because parentheses We don't need any arguments over here because we just want to have this click ability. So to check that we can create a new bull function for that. So in that case, we return to our force. So we create a bull check If one something like that often goes curly braces. And now we loops, row both off these grids and compare their values. So we create a full loop and I smaller than nine once again, the same numbers, Same here, Another four loop. In this case, letter J also was a maximum of nine. And what we want to do this we want to compare now. So if the riddle grid inscribed records and then we take I NJ once again as the indicators . So I come a day and when I want to do us, we want to compare those like if they're not equal. So one of these, no matter which one is if the riddle grit I day is not equal solve grid I day. So I come a day If they're not the same, we want to return false. So if one of these is not actually 1% the same or 1% correct. So we returned force. We instantly actually break out of the four loops and we're gonna destroy the bull function over here where we don't need it anymore. If we are not passing both for loose because none of these are returning false, we gonna return. True. So we say return true because we have passed the complete for Luke test over here and now. Also, we don't have this red line of the day, which is saying a note. All passes are returning something. In that case, in the very end, whenever we pass the complete test over here and everything is basically matching them will return through it. No, what we can do is an hour check complete function. We can just, you know, check for it. So if *** if one So that returns true, we say we can actually print a message for now you want. And if that is not the case, we can actually also say an else statement Over here. You can also put this into an expression once again, up to you print something like try again or something is wrong. Whatever. We just print these messages because we want to see debug lines over there and see if check complete does work. We also play a D buckle round. Basically and see of all of that stuff is going to work as well. Don't forget to save the script. And now we need to create a reference of the check button basically from the check button to the board whenever the compiler is done running. So collect on your check button, click on the plus drag in the board and a select the board itself and see what check complete is going to be happening. So we can I go out off, maximize on play and I do a test play over here. And whenever now I press on the check button, I get try again. That means I'm not done with the board. We can also try the other way around, meaning I select the board first, go to debug mode, since I want to have a simple ah fix of a year. Want to have a simple board to d back? Gonna check? Try again. But now when I fill in all the needed or necessary fields like this one needs to be night. This one here also needs to be a night. Ah, this one is going to be four. This one here is going to be nine and that when he is going to be a one and we check again , you can see now it saves you one. Meaning we now have filled all the correct parts. And in that case, we can ask you show some user interface like a do y, which is telling you how long it took you am or if you want to play another round. Oh, if you want to go back to the main menu two twos another, you have to get another mode running like to, yeah, see what's going on over there. 23. #23 Show Hints: Welcome back to the board in this part. I want to talk about hints. So whenever we, for example, click on a hint. But then we want to give the player the possibility to highlight or ask please show any number meaning as a player, I need to hint. Okay, what could that number be? Then? I click on a button and highlight this. And I showed this maybe as a at the red number or any other color, as well as make this one not indirect herbal anymore. And maybe we limit that hint input by, I don't know, maybe maximum off 3 to 5 hints. Maybe according to whatever that the mode is going to be like, if it isn't insane mode, Did he gets like, I don't know, eighteens or five hymns. And if it is easy, Moti probably only gets like two or three in something similar like that. We can introduce this hint possibilities rather simple. We just need to take care off that we limit the hints. I'm gonna explain night on why To do that, we need to open up a board script since that is actually taking care off all the hints we're gonna create a button light on for that. So we need to have a partner that public access away from this hint functionality. In that case, we create a public void, so hint What we now need to do is we need to introduce a little list which is taking care off who can actually be activated as being in this item. So meaning we need a list off type number field, which is actually able to be hinted. So in that case, I create a new basically, doesn't we need to be a public list? Just a list. Open close trying a brackets. It's of type number, field. I gonna name this. Maybe field list is equal to, and now we initialize that already as a list of type number, field open, close parentheses and close the line was a semi colon. Don't forget to save. So now what we want to do is we want to at first check how many we do have left in this field list. So in our so him function, and we want to make sure that we don't under do it. So meaning if our field list his biggest zero only then we are able to do so. Also, we want to introduce a new port fill the field list needs to be counted. So we need to say field list don't count. If the countess biggest and zero end our maximum hints, we don't have that. Maxim's is also biggest zero, only them. We want to do that. We can quick fix that by just create or generate a Maxence off type in tow over here, or you just type it in over there. So it is int maximum hints. And don't forget to save, of course. So if Maxence is bigger than zero, of course, then we only are able to get a hint. So first off, we want to make sure that we pick any random and number inside the size of the field list. So we create a new interject. I call it Rent Index, or random index, which is basically a random number, so random dot rains and this number is going to be somewhere between zero and two. The field list dot count So the maximum possible list amount over here. So we're gonna decrease at first maximum hints, so because we already do that now we want to do is we want to set the riddle, Grete, to be whatever this hold greatest. But the point is we need to request from the number field. We're currently excess ing. We need to request the X, the Y coordinates, and ah to get their correct index. Because we just got it directly over here from this particular field. And we can now talk to this field by just, you know, going through or to this riddle grid over there to get the correct values. We gonna have to get the accent y values from here. Otherwise, we are not able to access those. In that case, we're gonna need to create a public, get acts, close parentheses, and it is of type into since we return an integer over there or we want to return here is basically X one. Then we could be all of that part. And we want to do the same to why access So get why we return. Why one at this point in the number field, let's go back to the board now we can request this informations. So what we want to do is we want to set our riddle grid at its position where we are currently at so and the position we are currently at is the random index or actually at first the field list. Then we want to access the field list by its random index. So in next, we just told it took over here. Then after this first square brackets, we want to get the X values. So get X open, close parentheses and we said comma. So this is the first indicator for the X value inside the riddle grid because the field list already knows that information. So next one is the why will you Inside the riddle grit once again is going to be the field list. Then in square brackets, we gonna need Teoh, take the random index once again, and we need to get the vie will you off this particular one by reading it. I want to set this right really great part over here to be equal to this whole grid in squared records and nobody we gonna take the same indicators. Basically, we can copy this complete square print Brent theses part of here completely, and put this around the solve grid one. It's going to be a bit longer over a year. So I'm going to read it for you. Solve grid in, and then we're gonna have the X coordinate its field list. Random index, get X and the X or the Y. Well, you, in this case is fueled. List random in next. Don't get why. So now we said or update our ridder grid by the input from this Don't forget to put a semi colon in the end. Otherwise we get a problem. And also the Prentice's over here going to be a rez. A strange sometimes Now what we want to do us. We want to set the hint accordingly. So we say field list in square brackets and now we're gonna take once again the random index. And now we want to set the hint. But we don't have the city infection already, so we need to create this. So we go to our number field over here and create a new public void set, hint and we need to pass into power one para media. In this case, it's going to be the value. So in underscore value, we're gonna set this stuff up in the next video. But we're gonna complete the board functionality of here pretty quick as well. So what we want to do is we want to call set in open, close parentheses, and the actual value sits once again inside the riddle grid over here. So basically, we're gonna take the complete part over there. So riddle grid field list random index by getting its acts and its Y value, and that's where the hint is going to be in on. We're gonna place that or put this into this pair of parentheses over here and and the line was a semi colon. Now we want to update the field list. So we say field list dot removed at want to remove at whatever the random index is going to give us over here because we don't want to access this field list item anymore because it is already taken or it has been set as hint Already, we can also say something like else in the very end, where we can just say we are out of hints. So something like print no hints left or something similar that a cures only when this and that does not happen anymore. don't forget to save the script. And then the next port, we gonna finalize all those parts, make sure that the compiler runs correctly and we get no problems in the console. 24. #24 Finishing Hints: Welcome back to the course in this part. We want to finalize the part about the riddle hints that's open our board script when we now need to do is we need to at first fill the field list. We can only do this whenever we create our buttons. So open the create buttons function. And before we are actually putting in the parents to are setting up the parents for the buttons, we want to make sure that we're gonna do attack in that case is check ISS. If riddle grid in square brackets Now we go. I come a day that is equal to zero and only then. So it means this is a riddle, actually a riddle. Grit representing numbers. We want to add this particular piece, this particular number field to our field list. So we say field list dot ad and what do we want to add? Is the num field, which you can see over a year just added to it so we can later on excess it and give the hint. According to this, of course, no typos. Numb field was a big f. Don't forget to save and all we should be able to call the finance and correctly show hint from a button. Don't forget to safe once again if you have any made. Any changes? No. Let's create a button. Basically, we can just copy this check function button over here. I gonna name that, maybe hint Button. I drag it up a bit so I don't have to set up too much over there. Maybe leave a space. Also, I go in the change attacks over here something like hint And in the own click event, I want to change from check complete Toby board, so hint and safe. We are still not changing the buttons directly, which we are excess ing because the function we have created already is not set up. What we need to do is we need to open our number field where we already have created the base for the setting where the value is coming into to set the hint we need to update the value first, so we se value is equal to underscore value. Also we want to do is we want to set the number text to be the value of strength so number don't text is equal to value dot to a string. Also, we want to make sure that the color is probably different. So we see this is a hinted number so we can say number that color equals color dot rhett or green whatever you like. Also, we want to set the button to be not indirect herbal anymore because we know this number already and we cannot change it or we shouldn't change that. In that case, we say get component in parent open. Does the string of brackets say Button come close? Prentice's Don't Interact. Herbal is equal to false, so we don't want to be able to press that and also it automatically. Now it changes its background because it's not indirect herbal anymore, and it's going to be highlighted as a rep number. Don't forget to save. And let's go back to unity and check that out. Were you gonna press play? But we shouldn't have a possibility to get a hint. No hints left because we haven't set any possible hints. In that case, we can go up in our board script wherever we are setting difficulty. For example, incent difficulty. We can say OK in debug mode or Mexicans are going to be equal to maybe three and easy. Our Mexicans are probably something like, I don't know, five in medium. We might go and put in something like a seven. Once again, these numbers are numbers you need to take care of. On your own and heart, we probably have something like 10. Even if that seems to be quite some high number and insane, we maybe you have tennis will. Once again, you can play around with these numbers. See of that fits your needs. Maybe we're going to do something like eight, six and four or something similar Order and I don't know. So maybe it's something like that works quite nicely over here. Don't forget to say for once again in D Block. We may be only one to have to, so we don't overdo under Do it when we know press play. We are in debug mode. We should have the possibility to get to hints. I click on this, but I need to do this. Of course, in the game you as you can see, this eight now go changed and his rat and we still have one left. So this one gots automatically filled with the one because it was necessary. And now when we press again, we have no hints left and we cannot do anything. Another thing I tried toe demonstrate right now is whenever we have changed any of these numbers already, no matter what of, no matter if they are correct or not, doesn't matter, and I select hint. Now it's still picks one and change it to the corresponding number. This is helpful because, well, otherwise we would start be stuck in a wire loop of we would check for zeros. But there's never a zero left. And in that case, that would not make any sense at all. And we would keep staying inside off a you know, while loop often unlimited one once again if we are going to changing the board to on the functionality to easy mode and we gonna have like four Hinz, it can happen that whenever you have a coric number, that it still gives you Ah, a number. As you can see, it updated this one, but it doesn't really care about it now. We don't have any hints left pretty good, and our hints system does work correctly 25. #25 UI Menu Scene: Welcome back to the course in this part. I want to create a little menu scene where the player can basically choose the Yeah, the mode to, like the hard mode or insane mode or whatever, until we gonna design buttons and also make them or give them the possibility to change that. And, of course, we're going to start this particular level over here meaning with the setting off the particular mode. So how do we do this at first? Of course, we need to create in your scene. Make sure you save everything over here. Before you do anything else, we create a complete, empty one. Well, you probably want to create is a new canvas over here and off course Already do a scale with screen sides of a day. What you know can do is you can bring in any images, any background stuff, anything you like, any designs you have done probably on your own, and create a nice menu over here once again, you have thousands of possibilities to do that. I just discover one of the day because it's quite some stuff. So what I have is a classic zoo giokos right over here. I created this one, Raza, quickly, Nothing fancy at all. And I imported this one of the day. So on my image I can just drag this little one as a sprite, make sure that I re preserve aspect ratio And then I just go in direct this as big as small as I like to Also, I want to make sure that I sent her this one over there and basically that everything I gonna do over here, maybe I gonna do the camera change and bring not the skybox, but a solid color and maybe $10.1 white. You can also bring Ah, yeah, letters or anything else or numbers in the background. Once again, all of that is going to be completely up to you. Maybe your center is not the centre of here because this is going to be a bit overlooking over there. That seems to be a bit not matching 1% of their, but doesn't really matter. Once again, you can always go here and rotate these things. If they don't match everything, probably it's because of the letter mounted that this does not look centered. As you can see, the distance to the left is different to the rights of probably once again, I do a little offset over here. It is the center, but still get it. Any help? Probably right. Once again, if I liked. I can always go and rotate things as long as I think that might be corrected with a And then I bring this maybe back to the center and see that fits. Well, better. Whatever. So once again, these are hundreds off possibilities. You can take care off, as you can see when I just hold this next to the grid like this graphic. And I see this line over here does not match this line over there. So probably I gonna rotated a bit back. So it's a probably fits better. Ah, this way. Okay, so that's everything about the title you might want to bring in your local. Your website s somewhere on the bottom. Over here. Maybe a corporal, right? Text all of that stuff once again is up to you. So all these design decisions I gonna make it may be a best fit over they and bring this text will make this takes a bit. Ah, yes. Something like that are gonna maybe center this and you can put in something like Could be right, boy. And then I'm gonna put my name over here, probably the year off creation. Also make sure that it is big enough over there, but not too much. And maybe bring this over here you get also, put this in the top in the bottom left center, all of that stuff. Once again, it's completely up to you. Make sure you designed that in the 16 by 10 or 16 by nine environment. And if you are, I'm not quite sure about that. What you can see is happening that the text or not to stay at the position. So what you can do is you can take these anchors over here on direct transform. Hold on, old, and bring this one down to the bottom. Now, when I do the change right now, it always days in the bottom. Same for this one. You can basically center this one, make hold on old, bring this one up to the center over there, and then just make sure you bring this to the left once again or wherever you need. Teoh, the distance to this anchor sport is going to kept by the system directly. You can basically also lift this one up a bit slightly over here, if you like to. So now let's create some buttons for the game mode. So once again, stay inside the canvas, make sure so like that you are right. Click angry Ida button over here and in that is basically we can do something like helping screen. We can do whatever we like. We can do some cross promotions, but these buttons, But we don't care about that at the moment. So I gonna name this may be easy moat as a button. And what I want to do is I want to change the tax, he as well, and put in something like easy mode. And then the player can just select these buttons or is so yes, So, like, these things are going to give the best fit and maybe a bit more brighter dark color, so they can probably read it a bit easier. Maybe you're gonna Yeah, make this this easy mode button a bit bigger here as well. But I tried to reduce the text size of it so it's not too much off a problem and maybe are going to make it a bit broader, since other modes might name it different over there. So we're gonna have, like, four different modes, I guess. So there's the easy mode than we have a medium on our heart and insane moat. Once again, we can copy and paste all of these things over here and change the text inside of that. We can also make use off a horizontal out group. Once again, all of that stuff is going to be totally up to you. So here we have medium mode. Then you can also once again rename at this button directly. So your name. Oh, actually, you know it, but not necessarily. So this one here is going to be the hard mode on. Do not hit Enter and this one here is probably impossible or insane. Moat. Once again, completely up to you. Don't do any typos, and that's probably everything we want to do over here. Once again, you can do something like accent buttons, adds buttons and all the other stuff on a short button. If you like to, maybe you want to sell medium hard and insane mode and give easy mode for free. Whatever all these ideas are coming or you need to go and take care off on your own, you can also implement some. Yes, some particle effects, like falling stars, are falling numbers. Once again, all that stuff is completely up to you. You decide what you want to see over here in an export. We're gonna connect these buttons to a remote and then update the moat accordingly. 26. #26 Menu Buttons: welcome back to the course in this part who want to create a script and connect these buttons to our mode and set it up correctly. First off, we need to create a new C shop script and maybe recall this one settings and open this one up and morna develop a vicious studio. Once everything has been loaded, we want to make sure that the Settings class is going to be a static class so we can actually access it from anywhere. Also, we don't want to derive from a money behavior, and we don't need starting update settings is just going to be a placeholder for all this information's. What we need is basically the complete in import over here from the board script. So we just copy this one over and put it over there. Since public difficulty over here needs to be aesthetic member as well since the class aesthetic, we just need to make sure that this one is a public static difficulties with the name difficulty. Well, we now need is a access er to this particular settings one from our buttons, but we cannot directly update these because we don't have the possibility to do this directly from a button because this is aesthetic function. So what we need to do is instead, we need to create a button script for just that. Settings are going to create a new C ship script. I call this button setting and open this one up and model develop or visual studio. Once it has been loaded, we need to get rid off. Starting update. We just need to have an excessive function, which is talking to the settings. In that case, it needs to be a public, Let's say bottom collect. You can also name it whatever or set settings it needs to be of type white, and I want you wanna have is an accessory or actually a string para meter, which is taking care off the setting directly. In that case, what we want to do is we want to set the settings, don't difficulties or, in this case, justice difficulty to be equal to. And now we can basically talk to all of the difficulties we're gonna have there. So in that case, we want to set it to be settings dot difficulties, and now we can set it to whatever we want, for example, easy art insane or even medium? Let's assume we want to put it an easy Of course. We only need one exclamation mark, and now what we can do is we can basically switch to whatever the setting is going to take . What talk to us. Let's do in a statement. So what we say is if setting IHS equal to, let's say, easy that we want to do the setting off the difficulty, Toby, the difficulties to be easy now we can Basically, it was the same for all of the other ones. I just a duplicate this four times. So if that is going to be medium, then this needs to be changed to be medium. If that is going to be hard, we need to make sure that this is set to be hard and we're gonna have insane. We're gonna put here. I went insane mode. Don't forget to save the button. Click and our let's bring this onto our buttons. So we take all over buttons and drag the button settings directly onto the button. No, we want to earn a with one click event. Now we need to do this one per one. So this button needs to go in itself. And now we go to button setting button. Click. Well, now we can put in the easy key over here. Since this is the easy mode, Same for the medium one. We just drag it over here. Button setting button. Click on. Now we re name this one to be medium. This one here is going to be, ah, hard mode. So I rename it, drag it into this on click event again and shoes, button setting button Click Heart. And that's one of this going to be our insane mode. So I rename it, drag it into the on click event button setting button, click and rename this one too insane. Make sure that all your naming commences 100% correct. And don't forget to save the scene s menu scene or whatever you please. And like once all your settings are completed over here, we should be able to load the settings in the same run. Basically, whenever we're starting our seen our game scene. In that case for that purpose, I want to make sure that I rename this one to be game scene. Since usually it becomes named as simple seen. Basically, it doesn't really matter. We gonna load this scene whenever we click on these buttons as well. But before hand, we need to update that over here into the button click setting. So first we do the setting, and then we gonna load the scene to load the scene. We just need to implement using unity engine. I don't see management as the name space after we're done once again with the setting or whenever we are at the very end, we just need to call the coric function. In that case, we can say See, Manager don't load scene and an open close fantasies we can put in the scene Build index or the scene string name. In that case, it's going to be or game seen as we renamed it. Once again, naming convention is King. Make sure everything works 1%. Don't forget to save on, Let's go back And now we just need to make sure that we goto our file built settings and make sure that the menu scene is available and at the first sport over there because this is the first thing the players going to see, whenever you are building the game once again, don't forget to save just in case. And in the next part we gonna connect the settings with our game. 27. #27 Connect Difficulty Settings: Welcome back to the course in this part we want to connect to the menu scene. Was our setting scene also? What you have seen probably is that my tank games over here. My game and total is changing its size. Whenever I gonna do this change with the aspect ratio changing over there, we're gonna take care of that, probably in one of the next videos. First off to connect our menu, our game scene with the settings we have created in the last two videos. We want to make sure that we access the settings directly from the board to do so before we actually start to initialize the grit, we're gonna get the information about it. In that case, we say difficulty is equal to settings, Don't difficulty. So whatever the difficulty setting is going to be inside over there, we want to update it accordingly. To work properly, we might want to typecast this one into board door difficulties, so difficulty is equal to settings. The difficulty was a typecast to board don't difficulty. So because that is going to be converted now into difficulties in, um, it needs to be done, Otherwise it might not work correctly. So whenever the compiler has done and has no issues, was that and we press play, we probably see the debug mode running over here. So even if we are going to go and change the board now to be easy, as you can see just said to be easy, it's taking the first setting from the settings. In that case, it's going to be the debug mode, as you can see over there. But if you would now change that scene and goto a menu and press play, and from here we go too easy mode, you can go and check it out inside the board. Now it is said to be the easy mode. If we're gonna do the same for, for example, the insane mode. You should test everything, by the way. Anyways, if you have any typos, you can go to the board and see. Now it is insane mode activated this way. We have, like five modes off for modes, or were how many months you want in one game, seen just by changing and type, casting the difficulty from the settings into the board, and that's everything you need to know for all this modes over here 28. #28 Debug & Print CleanUp: Welcome back to the course. This is basically the final steps. We're gonna go in a discover in this course. So what we want to do is we want to get rid of all debug lines and debug possibility to print messages from all the scripts we have created so far to do. So we just open it up and we can basically get rid off the all the debug stuff like this one over here. Inside our initial grid, we can just commanded out. Probably. We need us later on for debugging purposes. Same for the deeper grid. Basically, the Sprint message only gets run whenever we call the book. Great. So probably you want to see all the references or anyone who is going to access it. In that case, we're gonna have the shuffle grid is going to excess it. So I commanded out. Also, we have a reference from the riddle grid over here inside the real create riddle grid function where they want to get rid of that as well. And this one is just a function itself. Don't forget to say if you can close the search results once again. After finding all this references and let's see if there are anything else. Doesn't seem so pretty good. What do you want to do is you probably want to not just print a win methods or try again message. But maybe you want to give the players something like a do y and interface where, for example, time has run out and so on and so force. You can totally do anything, any design, any stuff you like and give them some buttons to interact with. I believe I gonna create a little video about that pretty quick after war, this one. But I want you to make sure that everything else is so for a good to go. So whenever we are now starting the game, make sure the consul is clear. Whenever you start and we go to any mode and check for hints and whenever we have done also , we get a debug line that we don't have any hints left because off the, you know, off the rules, we already dead. Also, the check is going to give us still the sprint message about try again. You're not done at the moment, so you probably also want to get rid off, No hints left as well as the other Yeah, line commands over here. So in that case, you can get rid of that and put in any other interesting informations about that. Maybe you don't want to do anything. If that is not one, maybe you want to blend in some text for a second or two. And once again, if there are no hints left over there, you can do a print message of here as well. Or just show some yeah d y for that particular purpose and then just deactivated after, I don't know, a given amount of time. Once again, there are hundreds of possibilities, but you might want to take care of that on your own. So far, based on the design decision and so on and so force. 29. #29 Win Panel: Welcome back to the course once you're done with the game or the players done was the game and he has basically one. You might want to show some I don't know, some window in the center of the screen and see or show that and give them the possibility to play again or maybe go back to the main menu. And how do we do this resin? Simple. We just create a new do y for that. I created just a super small window over here with an image. So this image can or should not be part of the board, but off the canvas. So I'm gonna recreate one based on the canvas image again once again, designed this to your needs, Whatever you like. You can put in any informations there any buttons and all the other stuff on your own gun. Attended a bit. I don't know greyish and maybe give it one of thes U Y backgrounds. Over here. Maybe no to Doric. Maybe a bit it happy. Something like that. You can create your own graphics for that. In that case, what we can do is we can literally put in anything on that I gonna name it? Win a panel and we can no put a button on to it or two. So, for example, play again or back a menu. So in that case, we create a new button over here. We gonna change the text on this particular button to be try again or something similar, or play again? It's not try again. It's a play again. And maybe a question mark. You want to make it? Maybe also bowled best fit and give it some good or good visible seen part over here. Maybe you want to make it a bit slimmer, but not just the tanks, but also the button. Maybe make it a bit big or something. Whatever you please like once again, there are hundreds of possibilities in case of design on die Gonna bring the text bit above or below there. So it's not too huge but still goodly Wiz herbal. And whenever I'm done, I gonna duplicate this and bring this on to the other side. So this is going to be my something like back to menu back to menu. Then the player has a possibility to select this one. I can also give it a enter over here. So maybe is a bit easier reading. I don't know. You can once again think about all of that stuff on your own. So now I have these two buttons and maybe are gonna do something like you win game over or round over whatever. So you can also introduce that directly inside of the panel so you can say something like you win estimation Mark, and we gonna do the same like a bolt taxed, best fits and a super dark. And you can also play fireworks and all the other stuff I don't know. Once again, you can also implement time and stuff like that and bring this into this interface as well . So what we want to do is whenever we win, we want to activate this from the board. Whenever we are done with checking the complete board over a year, the complete part and we want to do the play again functionality as well as the back to menu. These are going to be the easiest ones, which we can do directing the button setting ones because we have implemented the bottom settings in the set or the scene management part in here already. Once it has been loaded, we created two small helper functions. For that, the first born is a public off cause off time point and is going to be something like replay and to replay. We just say, Seen manager, don't loot scene. And what do we want to see? Load as basically the same scene. So we say, See manager dot Get active scene and open close parentheses dot name since it needs the string para meter for loading the scene name correctly. So now we have a scene or replay button, and we can also create a back to menu buttons. Public void. Come back to menu. You can introduce a string directly four loading this particular string. You can also bring them to any other scene if you like to just from that particular button all once again up to you. What? We want to load us a scene manager. That load scene And where do we want to bring this guy? Of course. Back to menu. And that's everything you need to do for the back to many. Once again, you can bring in a pyramid, a string perimeter in here and then just load the string perimeter from this particular point. No problem at all. Now we just need to make sure that these buttons get about in setting information about it as well. So I select bows, bring button setting directly over here in between. Make sure I add on both the on click event now direct from this button, which is going to be the play again button goto button setting and say, replay and the other button. I gonna direct this in this well select button setting and say, back to menu, and that's it. Now we just need to activate the wind panel whenever we are done. Don't forget to save your scene and let's go back to the board. Actually, it's to the board script wherever we're checking for wind. So whenever we have one Ynoa check complete function, we just want to make sure that we activate the wind panel. But since we don't have the active the wind panel already, we need to create it. So we go to the very top at first and create a public access er fraud, the wind panel. So we say public game object when panel and start we want to deactivate the wind pedal automatically. So we say win panel don't set active is going to be force. So in Prentice's force and we're going to do the same. We activate this panel whenever we are done with the game. For me, it is quite some below over here. You're gonna say, when Penhall that sank active to be true. So we activated. And we have the possibility to do the input to go back to the menu or what not? Don't forget to say the board script and the final step is just take the board and connect the wind panel to this, as you can see is the wind panel. I just take this, bring it over here and I can ago and play directly. That should bring me into the debunk mood. Since I don't have anythings set it up already, the wind panel gets deactivated automatically are gonna go and do two hints, so I don't need to do much over there Gonna put it to in here because it is necessary. I need to have a seven over there and this one should be a five and then I check, but it seems to be wrong. Oh, this is no to seven. This is a nine and no, it was the check and I can't see. I have the possibility to a select play again, and it's loading the complete level once again with other settings with another board, I can once again take my hints as well as can clean this one up correctness of distributes . Ray, this should be a seven, and this will be one, and I'm gonna check again. And I can also try to go back to the menu and we're back into the menu. And we can also load the insane moat. Pretty decent. Everything works. We now have a complete solid work flows through the complete game, and everything is as it supposed to be, I guess. 30. #30 Concept BackTracking: welcome back to the course in this part I want to explain. What were going to do was to play field in another possibility. The point is our first message, which we already have created to create the playfield or toe organize that we were doing it so that from the first cell we were always going to the right and feeling everything accordingly. What we also did is by jumping over the you know, 1st 3 tire 1st 3 numbers for the next row. And then we feel that I'm from the left of the right and always started to go and do the same stuff. What you he already see is that these three cells are the same as thes resells as well. Aziz. Three cells in its order, basically same is going to appear top to bottom 714 are going to be in the same year span or column. Same here. Same here, but in a different order since we are able to even if we like Teoh makes these values, we can take this four and we gonna randomize that which we already did and, for example, makes it was all nines. What's going to happen is they're gonna just, you know, change their position like that. So all the nines are going to be now in the orange fields. What is going to happen is still they're gonna keep some kind of Ah, you're parity because we need to do that. Otherwise, we gonna have the problem that sooner or later they will not match was to complete playfield. But its way we going to do this? Of course, as you probably already know, which you have seen already. We also do this with the complete other parts off the playfield. So with all other forces and all other ninth or whatever the random will use, we just twos and by rendered range. So since we are mixing that, we always still know that 95 and six are going to be in the same manner in the same order. Even if we gonna mix and match that 100 times, there will be always something which is going to look the same way as the other ones. So once again, you can see this over here. Seven i, 84784784 And all the other ones are going to a cure, no matter what. How often Weak on the mix this is going to happen. The same tire are the world time. It is one type off a play field which we can play but probably is not as a much is appealing as another message I want to introduce in a minute or two. What we can do is at the same time we can, for example, think about Okay, let's flip some rose or spends. So we can, for example, go and take this roll and flip. It was that we can also do it the other round away around. For example, we can flip this column with this column as long as we stay in the for in one of these blocks. Otherwise we're gonna Yeah, completely destroyed the idea behind it. But what we can do is we gonna try that. Okay, let's assume we're gonna flip these two rows. Or in this case, two columns we can also do. This was Rose. We can do this was condoms. But what we're gonna create over here is OK, we're gonna create another way or another number set up. Nothing fancy at all. As you can see, we just would go and flip these, but still the set up it's going to stay the same. 59 and six will always be in the same. I'm order on the same rule in this case. Same here. If we don't flip these, they're going to still stay here and we can also decide. Okay, let's do it with any other column over here. We can do that. For example, these two, it will still a cure the same way off course. We're gonna have some flipping here and there. We can also randomized these flips. We can also say we don't want to flip any, but we can only do this per block like per complete rose in one particular block once again . Otherwise we would destroy the fact behind it. What's going to happen now is of course, it looks more shuffled like 67 and four. I know in another order, but we know always these three numbers whenever we discovered them, wherever, another color, wherever another number is going to be. We know that the same set up appears on the other cells, like on the other blocks over here. And that's not actually not too much appealing for a player. Once again, we can also do this with other ones. Like flipping them up. Went down like this, complete Rose in this case, which would take me some more minutes of a here. Or maybe we're gonna do this way. Maybe it works. I don't know. So why I just take this rule and to changes with this role? Basically, there's nothing fancy about it, but the same problem appears we always have the same parody or the same setups. 95 and six are still in the same rule here, here, here, here, here, here. But when we once again the only thing we gonna change over here like even if it would do a far outside flip like no, just that size bought We can also flip these two from here to here. That's not a problem at all, because it's going to still do the same stuff. It is just flipping thes away from each other and you're changing the base of the set up. This is working. This is one way to actually do it or Teoh play the game. Or actually, it's one possible solution. Even if this is not going to be a good one. And because of that, and because we know that this is not a good one, or I know that this is not a good one. I decided to change the algorithm a bit, So we're gonna go away from that and create a completely new one. Once again, we can go and go on manc mix and match these a yes cells per block and rose and spends or rows and columns per block and just flip them, like far outside or close outside or whatever. Still, it is going to be a possible match after that, flipping like whenever the we do these. But well, always the grid always looking basically the same. So we have always the same sets. Always 213 are going to be at the same set up, depending on how often we makes it. Of course, it's going to look a bit different, but as you can see, we're gonna have a once through 32 here, 23 I want to stay here 213 here. So no matter what we do, it will always stay the same. So and we want to avoid that because once again, to play a maid and noticed that sooner or later. So that's what brings me to the next message, which is called Recourse off back Tracking message. This backtracking mass it starts at the first place was an Andy Red, as we already did with the other ones. What we do is at the very first, we're gonna fill in some random numbers which are not going to give us a parity anywhere over here. We just feel 1 to 9 over here and we take away this number and then we're gonna fill this role. Or we can do this both at the same time. Ah, well, there are several possibilities we can do over here. Then, whenever we have that, we have a base. And this is always the random start where we can randomize completely the complete playfield. What records of backtracking message is going to do? It picks at first the first next free field and ah, yes, stores This information like the accent, the Y court night on this board. And then what we need to do is we need to check the block it. What is the next possible number based on this block. Same for the Rose saying for the column. What we now do is okay. For example, we gonna fill at the very beginning randomly. 123 in here, and foreign five over there. Then we know that for this particular field, we have four possibilities to fill in a 67 and eight and online on. What we gonna do now is we gonna store that information and go to the next integration. Basically, we take the next field. Maybe this one and ah, store all this information. What can we feel in? Okay, we can feel in six or seven and eight and nine. Same here. Same here. So these are the four possibilities for these four fields. But what we also do is, whenever we have all this information we get go from one small cell to the next one. We iterated through the complete grid and see where's an empty field. And what other possible numbers for this field. What we're gonna do is whenever we had done was one of these we create the same message once again and request Is that possible? Field is that is the case then we gonna go to the next cell. So and total it's going to be whenever we are at the very bottom of here. We know all these other possibilities already. We're gonna take one from the already possible known ones and bring this into a cell. And we fill the field with one number, which is possible, usually was the first number in the set or in this list, off numbers. So in this case, we're gonna take them a one, and then we go and backtrack. That means we're gonna check now, can What can we put in here? OK, we can put in a two or 45 as you can see over here, 4 to 456 and seven that we feel in anything in there. If there is something which is not matching, of course, we feel in the zero. And then we go back once again to the check for zero fields away. Once again, we start the complete process until we gonna have fulfilled the complete board. Same here. We're gonna fill in the four in here because it matches. We gonna take this from the 1st 1 so basically it's not in here at the moment, but they're so and then we feel the complete board from the bottom rights and go backwards and fill in everything. As long as we do that, we gonna fill every single piece inside the board with this massive. And in the next couple videos, we gonna create all the possible or needed functions for that, like checking spans or columns taking rose checking boxes. Because that is the base of that. Also, we gonna randomize to fill the first column in the first row, and then we're gonna create the backtracking gore ism. 31. #31 Column Check: welcome back to the course in this part. We're going to start our backtracking or recourse off backtracking message in that case means we gonna create the column check at the fair first. So open your board script and I created some of these markets over here just for me, because the script is going to become longer and longer. If you want to get rid of the other functions we probably don't need in the future. Or maybe you want to reuse them for learning purposes, then off course. Make sure that you keep them. You can also create a complete new board script if you like Teoh. But for me, since I want to reuse some of the sanction and we're going to rewrite some of them later on a bit, I want to make sure that I keep ever seeing in a side over here. So about the backtracking, once again, we want to create the column for us. Or actually, we want to create a colum check first. If one particular number is containing in this particular column, we're currently checking Strope for that, we're gonna always return a bull like a true or false. So beside Bull column contains our number, our value, whatever we are requesting. And to take that, of course, we need to have an interview off wise of the Y axis on our board or to de board. So the column from top to bottom. In this case, this is what the column number is going to be. We need to put in. Also, we need to have an indigent with with our value. Doesn't matter in which order we put it in here and we want to reference any specific grid . So we gonna say ref and array and just name it grit. So what we can do is we can request now any grit as we already does over here, or a reference any grit based on this request. At the very end, we want to make sure that we return force. Since when we ever are here, Then we know that there is no number inside this particular one. So, like in this column, whichever we're currently checking to check one column, we just loop through it by using the integer I or in this case, I gonna name it acts. So it makes more sense, probably for you. So we go through all access, like from top to bottom. In that case, which is going to be the X axis, and we're gonna check the Y value like, where is what is the current spend probably is a bit misleading over here, but just take it as is Well, we now want to do is we want to request if the great on this particular number, like on X comma Y, is equal to the value which we are currently putting into once that is going to happen. Meaning we contain that we found this particular value by looping through the complete row . Or in this case, as through the complete column, top to bottom. Then we know. Okay, there is this value inside once again the why Well, you is the one we have requesting. It's still fixed. We only looked through X like from 0 to 8. And once we had done was that we Okay, no, that want to return through in this case because we know that we found the number. So the bullying contains or the column contains a number. Yes, it contains the numbers. So that's why we returned through otherwise, will return force because Nope. We haven't found any on our complete way through the complete access access. And that's everything we need for the column check. And then in the next port, we're gonna create the road check. Probably. You know already how this is going to look. 32. #32 Row Check: Welcome back to the course in this part we gonna do or create eight hour Rotech. Our road tank is nothing else. That's a column tank. Like if row contains a number. So basically, we just flip values and do the same stuff as we have done in the last video was to contain column number. So what you can do is you can, for example, go and copy this company part over here like the complete bull. Once again, I put everything like inside this old texts part so I can later on find it easier. You can also make use of regions if you like to. I want to rename this one to be roll contains number because we request row in this case. So roll contains number We gonna put in an X value later on, you're gonna notify will notice why I going to do this this way. What we want to look through is why the why access and not the x axis in this particular case. So I gonna rename X here to be why. And in that case, we still go and change. This one is input to be X here. So this X is now the fixed value. And why is the value we gonna go and look through completely? And once again, we return true. Whenever this is completely done, otherwise or whenever we found the value, otherwise will return force. So we know. Nope, This particular nine cells and total are not containing the request that value in the request. That grid, that's basically everything for the ball. Check inside the road. In the next part, we're going to go and check one block. 33. #33 Block Check: Welcome back to the course in this part. I want to check complete block. So if a block contains a number, whichever were requesting So open your board script and I go once again into my old checks part of a year and create a new bull function. In that case, it is going to be bull block contains number and we request in distant case, we gonna request an interject off X for the X value. An inter Jenoff. Why? For the why will you then an inter jump? Where's the value itself? And of course, we reference any grid in square brackets like a to D array grid. Once again, as we already did in the other ones, you may wonder why always there's There's a red underline over here size because the block the bull does not return anything. So in the very end, we can Okay, say already we're going to return false first. So we get rid of the red lines and not getting too much distracted. Now we need to look through the block, whichever is a sitting next to our X axis. So meaning whenever we are at x zero and y zero we know that we are in the first block. And to make our life easier, we can take any number and modelo it down so that we are always from wherever this point is going to be like this X and y value basically and then calculated downward. So whatever that particular numbers are going to be, we say okay, it can never be higher than straight in this way. We can now add to this number which is ever the result An ad I or J on this k x and y to it . To do so so or to do this check, we can say OK, we lives. Rule first acts. So we say for into X is equal to and now we can take this number and kept it 2 to 3. But since X is used because we're going to make use of that already and here are gonna make use off the letter, I So once again, eyes going to represent X. We gonna take check it out in just a second. Now we need a nested for loops as usual for the letter J Or in that case, for the y value. Once again, we can make use off X and why? But we would need to recalculate them beforehand. And of course, we limit that to be a number three over here as well, since our blocks are always from 0 to 2. So 012012012 That means also a top to bottom left to right. Also, we gonna cap it to smaller than stray. So we know what Never, ever overdo it. Now we need to check the particular grit we are going to request. So for us off, we're gonna need to calculate what is the current X value in our particular block. So we gonna say if our grid inscribed records and now we're gonna need to fill in the data between those two. In that case, at first we take X and we need gate acts. So whatever the incoming value over years by X models rate, once we do that, we keep it as the core into number. We're going to do the same later on was divided value. So what we also need to do is we need to add not one, but in this case, the letter I sense That is our integration factor for going through that. Okay, let's assume our X value we're gonna put in here is going to be number five. So what is going to happen? We gonna take our five. I'm gonna show it in the calculator, so he probably understand it better. We're gonna have a five in our X value. And now we need to negate this by modelo acts. So model three or a five Model three is going to return to meaning we now take X as as o first indicator, which is once again a number five. Then we negated by three. Because modelos re is doing that. So we have two left. Now we take five and negate that by two. In this case, is this number three? And now we add to it. So we say, plus whatever our current letter, iess. So in that case, we gonna have whenever we are in the Annex five and we don't add anything Sewer. We know that we are in the second block because the second block block starts at number three in our row or column, so we can do the same calculation with number eight. Let's assume we are in the last block over here. We always try to find that the first index off or the first position off this ax value. Let's assume we're gonna have into X equal eight. And whenever we gonna take eight and eight model or three is going to be one. Why is that so? Because we say we need gate by three. We can still needed by 30 in this case is going to be to not one. So now we take if we take eight and negate this by two. So our first index is going to be zero, or in this case, six. The first index for this particular block on the X axis is going to be six when we now add I to it. For example, we are at the first place in this case zero. This is going to be our first in next. If we add plus one, of course, our next index in the second Federation is going to be seven. And the net last one, which is going to add another one over here is going to be 80 r. Block always started coric position. I hope you understand modelo right now and how it helps us to organize or be inside the coric block. We no need to do the same for the y value. So we can't say why, miners. And don't forget to put the model a port inside parentheses. So why model three? And then, of course, we add in this case J because this is our index for being at the court position. Of course, we're gonna close this. If statement was apprentices, so but now we have our index in great whatever the greatest we gonna create or yeah, Elka, actually a request over here. Now we want to check this particular part against our value. And if that is going to return, something like the value is in our complete block, which we're currently shaking through. Of course, we return. True. So now we have the possibility to check old rows, columns and even blocks according to our end axe And in why values based on any group we like 34. #34 Check All: Welcome back to the course in this part. I want to create a function which is doing all the text at the same time and returning, false or true, depending if the value we are requesting has been found at the same time in the block column or row. So to simplify our own process, open your board script. Wherever we have created our other bowling over here, this bowling right now is going to tack once again for column role and block at the same time, or actually one after another and returns to correct values or the correct. Yeah, whatever we want to know, I gonna the name, it's maybe check all. And of course, what we need to have is the indicators for I like the arguments for I for the X axis in our grid. The Y Axis goes who want to know our value. And of course, we want to reference any grid off type into job and two d array. Name it grid. So what we now want to do is we want to call column, tank Rotech and block tack in this complete Frank's in return. Whatever we want to know in that case, we can say if now we, for example, check the column for us, since it's at the moment at the very top. So column contains number. So if that returns true, then we want to give back false because we are not able to do something with that because the the number is already persistent or exists already. What we want to put in as Why? Because that's what the number is going to give us. What we gonna bring into this, then the next one is going to be the value we want to check for. And of course, the referenced grid. We want to check over here. In this case, it's the grid we're passing in with directly references. Over here is that is the case off that returns basically truth directly from that fact, because it contains a number that we want to say will return force because that means we are unable to do a check over there. Or do I put this particular number inside of that? We're going to do the same right now for the role. So if row contains number one, it's X value in this case, referencing the same grid Basically, we also want to return false. Of course, we want to do the same for the block. So if the block contains a number on X comma, why we need to put an X and Y over here Because we have the company plot to check that Wizards value and its reference. Ingrid, We also want to return false. If we are not going to become catched in this Ray wants and we do not return false in at the complete part, we want to reach untrue, meaning we can put in this particular number. We are currently checking four inside the grid. Don't forget to save your scripts. Don't will get to safe often. And that's everything we need for the row column and block tack on. We just call, check all that's it. 35. #35 Check Valid Grid: Welcome back to the course in this part. We want to check if we have a valid grid, meaning if every grid peas or every cell has been filled and no zeros are inside anymore to do is open up your board script and go into our old tanks region to check for that. We just need to look through our reference grit and see if there are any zeros left. In that case, we say bull is valid. Board or grit, you can name it, whatever you like. What we need to reference over here once again is just the grid itself. We are. We want to check. It doesn't matter Which one again? Celery reference. Our two D array, off type Inter Gia passed in the grid. Whichever we want to check. Now we go and look through the complete board over here. So we say foreign I with the maximum off nine off course, we do the same for the J value. You know that already we have done there's like 100 times right now. That was a maximum of nine over here as well. Once again, if you want to type these four loops quick type and four and press the tap button twice. Well, when I want to tank is if the request that grid off course contains zero. So in that case, if grid in square brackets and now we can put in I come a day If that value inside is going to be a zero, then we want to say we want to return false because it is not complete grid. So or not a valid great. In that case, you return force. Have we bypassed a complete four loop? Of course, you want to say we wouldn't want to return throw because this is now a valid grid. This check later on becomes interesting whenever we go for the backtracking part, and we check this at the very first or maybe second toe every time we create a new it aeration through the complete backtracking process. So this function is crucial as all the other ones are as well 36. #36 Fill Grid Base: Welcome back to the course in this part. We want to fill the first row and the first column to have a base for our recourses. Backtracking, massive. Let's go to our board script. And wherever I have created this a generate great functionality. I want to create a new function, which is off type void, since we don't return anything and I'm gonna name this something like Phil Grid Base. And of course, we need to reference an integer array or two D array was the name grid. So we can basically later on Phil any type of grid. If we liked you, it was just that manner. The next one is we want to create two lists which are containing all the possible values to fill in. So the first is a list once again off type in Georgia, we give it a name, something like Roe values. We set this one or initialized this one to be equal to a new list, type into open close parentheses and close the line with this in my colon. Well, we know can do is we can already fill in data by using curly braces after the Bruin pair of fantasies. So open, close curly braces will give us the possibility to fill in any values of type integer into this list. So we're going to fill in as a one, 234567 and eight and nine. So all these numbers, we want to have them to be filled in. If you want to have it a bit more assorted organized, you can also create the curly brace afterwards, So it's reading a bit easier. You cannot copy this complete list since we also need this one for all column. So for the first column So I'm gonna rename this list to be column values. And since we still need the same values inside, we're gonna just take it or keep it as it is now. What we want to do is we want to create a first random value and put put it in the first group spot at 00 So the top left corner, So I'm gonna create in. You interject and I name it value and is equal to. And now we pick from any raw roll off golden values. Doesn't matter. We're gonna pick from one of these values which are inside. And we want to actually pick a random index on this list on the row values or calendars. So I'm gonna take red, um, And next now and in this case, we're gonna make use off random that range once again. So we're gonna move inside a range from zero. So the zeros possible index to the maximum possible in next, which is roll values does count. And, of course, and the line was a semicolon. Um, count needs to be up a case. What does it mean is now? It takes a random value from this in. Next, if it picks zero than the value will be one. And we're going to store the value insight. This interview over here. So know what we can do is we can take this one and bring this directly into the referenced grid. In this case, grid open ghost crab Ricketts zero comma zero. So the first position in the grid on we set this one equal to the value. Now we can or assured remove these values from the from both lists. So we say random values don't remove. And what do we want to remove is the value wherever it is. Doesn't really matter. We're gonna do the same for the column values. So I'm gonna copy this line and then this one, Seawell values don't remove the value. Now we have something inside our first spot. We know want to do it whenever we're done, we always want to go and a debunk what we do so far, so we can't say debug grid, and we're gonna reference whatever the grid is We're referencing, as we already have done in all the other functionalities as well. So this is going to be at the very bottom. There's going to be some more stuff inside over here, but we're gonna take care of that in a minute. Go up into the start function and find where it is an open it and deactivate every single just inside except the wind panel. I gonna go and just total line comment after deactivating the wind panel, I want to call our new function. So, Phil, great base and we want to reference any great in this case, we can take our souls grid and referenced that because it doesn't get filled now by innit grid referencing the soft grid, we now fill the base on the being the soft grit and this solve grid is now passed by once again inside this and now we can also debunk that whenever we press play so we can literally go after we have saved to unity. We let the Cam pilot run here, and whenever he's done and we press play at least once, nothing else is going to happen. But only we get one number in the top left corner, a random number in this case. Now it's a sex in. The next round is going to be any other different number in this case, a one now we want to do is at first we want to fill the complete left rope. So in this case, complete column zero and all. Rose, we want to have one number. We can easily do this by looping through that completely. So first off, we create a for loop. When we can the name it into Joe. I basically doesn't matter. We gonna actually set the maximum to be nine. But we have. And this is important to start at one at the interview one, because at 00 we already have a value we know want to do us. We want Teoh actually pick a new random value from our row values like this one. Gonna copy the line except the indigent over there. So we created your value pickets from our already or still existing ah values inside a list on a roll values list. And whenever I have one, I gotta update the grit. In that case, the index is going to be I. But the column is going to stay zero. Then we said this one equal to the value once and whenever we're done, we update role values. So row values don't remove. And what do we want to remove is rather simple. We want to remove the value, so it's never, ever being able to be picked again. Don't forget the saves the script and let's go back to unity and see what's going on over there. We let the compiler run clear the console. If you like Teoh, I'm press play and see what's going on. Well, you can see the complete row is filled with random numbers. But all of these numbers do not duplicate themselves because it's impossible for the system to duplicate that. The next step, we need to fill the top rule, which is a bit more complicated because off the first column or block to do so, we need to look through that. I'm gonna make command over here, Rose First. Now we're gonna do the same for the columns. So columns here. So to fill them off course, we need to feel go and loops through all the columns. So we created new for hope We can once again take the same integer I because we have closed that already here. It doesn't matter so far. We want to go up to nine. But if we're going to start at one since once again the grit is already you had done that there is zero over here. So what we want to do is it for us. We create a brand in value, so we're gonna copy that part. What you need to now make sure that this is not going to be the row values about the column values. Otherwise, you get a argument out of range. Exception ero. So this value now gets picked from column values. Random range between zero and column values don't count. This is absolutely crucial once again if you get an argument out of range exception, you forgot to change these over here. Next one is we want to check if I a smaller cents rate. So we had the first block. So if I is smaller than three, we are. We know that we are the first block No we want to do is we want to check if the number we have picked over here is already existing in the first block. How do we do this? We're going to create a while. Loop at first and inside. We request our block contains number function, which Inter just as are are going to be acts. And why is good rez? A simple We just take the indicator zero comma zero. So since it is a first block in the top left corner, we started their zero and it read from that point. Then we're gonna fill in the value we have actually calculated beforehand and see if that is actually referencing our grid and see if that returns true or false. I close the fantasy and open close Colin braces whenever that is happening. When we find this particular value already, we need to re rule the value. So gonna copy the first line here and bring this over there. This is absolutely crucial. Otherwise, we could have doubles later on once we're done. Was Dad So we passed. Basically this if statement and everything else so far, we're gonna actually fill in the data inside the grid. So we say grit, open, close square brackets. And then we're gonna say, zero for the first row basically, or in this case, the first roll bought in the index I And we're gonna set this one to be equal to the value . And of course, now we need to make sure that column values gets cleared. So we say column values don't remove whatever the value is. Don't forget to save on once again. This while you've only runs in the 1st 2 numbers. So in the number one and number two after number three, this wild block does not repeat itself anymore. And we don't have too much in processing power. Lost basically. So once again, we go inside this for loop. We start at the first position, not in the zero position. So basically the second spot in the grid, we create any random value and see if we are in the 1st 2 it orations while we are having one of these block numbers containing this particular value we found already, then we're gonna reroll the number until that does not happen anymore. Once we are passing this part, we're gonna put in the value inside the grid and remove it from the column values so we don't pick it. Once again, let's go back to unity on Let the Compiler run. If we have any arrows and problems or anything else and once we have them, was that and press play, we should get it filled grid Or actually, the 1st 2 lines being filled and the first block should not contain any double numbers. The other numbers do not matter. It's just about the first block. You can now repeatedly try and test out of this everything working correctly, and the first block never contains any time one of these doubled numbers. As you can see, I can repeat the several times over here and see that none of these 45 numbers already over here are going to be always the same. That's what we need and wanted as a good start over here 37. #37 Solve Grid 1: welcome back to the course in this part. We want to start work on our solving al's algorithm, since we have a full field already, or actually the first to once like the first column and the first row, we want to make sure that our algorithm at first notifies the first free spot from the top left of the bottom right. In this case, it's going to be this number over here, as already explained in the concept video. To do so, we want to return values depending or according to whatever is found over there. There's going to be some back and force. So I hope you get a correct first off this function or is going to be off type bull and they're gonna name it, solve grid. So we basically create a so over for our filled grid base and once it is done, was filling that. We can basically go toe to go back to and create a riddle from that. But before we do that, we need to make sure that we have a fully completely filled and solved grid first. That's where the backtrack or the Aso recourse of back tracking algorithm, comes in place. In that case, first thing we need to do is we need to reference our grid or any grid we want toe being solved. So we gonna name it once again, Grit as usual. Since it doesn't return anything at the very end, we gonna make sure that we return false already, Just in case, because we need to do that. Otherwise, you always have this red underlines over there, depending off course, off the program you're using to create stuff like to program their things over here. So the very first thing we probably want to do is we want to tak if our grid is a valid grid and we have the Isabella grid function here already that we want a safe or store in the first place also, maybe at the very beginning, we want to make sure that we d back our grid at this point. So debug, grit, referencing grit. Also we want to do is in our Phil grid base. We want to get rid off de Baca grid over here, since we don't need that anymore. We know that already and also we don't want to to actually. Yeah, go back into the fill base more than enough. It's just once. And then whenever that is filled, solved Group is getting being called meaning whenever we had done was that and we called D block grid off here. We still have the same result at the very first it's oration. So basically what we are going to do is we fill the base grid and start, and once we're done with that, we're gonna call Solve grid was a big s and all school. Also, we want to reference I won't solve the grid over here next. So I know now you're maybe a bit confused because this returns a bull. Still, we can make use of this function because we actually feel still data inside the source Britain, Meanwhile, goals through the spool. We're gonna make use of the bulls check, probably sooner or later. But for now, we're going to keep it as is because we need to return to a force at a several different possibilities as well. Several possible times. So first off, after we're done was debugging and seeing what's going on with our board. We want to see if it is a valid grid, so if is Vela Grit once again, is valid grid returns true. Only if it is completely full. We want to reference our current grid. So whatever we are currently trying to check and see if that is on already solved Grit, if that is true, of course we want to return to at this point. So whenever we request, return true or force, we can do that. Now. When we want to do is we want to find the first free cell. I gotta make a commander over here find first free cell. So the cell is going to be one of these, you know, numbers, whichever it is so and well, to do that. First we want to store that into an X coordinate. And why coordinate? So I create to inter jests and named them X and Y and set them or initialize them to be set to zero. Are we gonna look through on complete grit? We have not returned at this point. So we are able to go into this part and I is going to be the maximum of nine. And then we need a nested for loops as usual. And we're gonna name this one Why? And of course, this is also a maximum possible off nine. Now we request the grid itself. So if grid, like basically the grid position in square records I come a day is going to be is actually a zero, so nothing is filled inside. Then we want to update the Inter just X and y. So whenever we find zero inside our grid, then we want to send this information into the accent y value we have created over here. So we say X is equal toe I and why is equal to J also want to make sure we break out of the loop because he found something already. We found the cell we wanted to find. We can also always go and the debunk that at any point, whenever we want to. For example, we could actually debunk that after we're done over here the first loop before, with or after we break. Actually, we can make sure that we're gonna brill your debunk the first cell X and y so And since we're breaking out of that, the complete for loop becomes obsolete. So in this case, we can if you want to print something like X plus why? We can also put something in between so we can actually read it better. So we're gonna make another plus over here a quote and then say X comma Y this is going to be whatever we have found over there once again, since we are calling solved rid already after we're filling the base, the first resell we're gonna find should be 11 that's test it out and press play whenever the compilers done running. So first off, we get this information. And also he's not just breaking out of that. He also goes completely through, as you can see and tells us. Okay, 11 is free. 213141 up until 81 All of these four are completely free. So now we know that the first role has actually seven free cells. So when we now can do is we contest now against all these cells? So, actually, we gonna try to fill in possible numbers Or actually, we want to find out what are the possible numbers for these particular cells? We actually started to look at 38. #38 Check Possibilities: welcome back to the course in this part. We want to make the check for if there are on which are the possibilities for each empty cell to do so, we need to create a list which is going to be dynamic so we can fill it whenever we like him. Please, To do so, we're gonna create a list inside. I was solved Grit function after we had done with indicating what of the next three cells. So in this case, we create a new list off time Inter gia, and this is going to give us or we gonna name it possibilities as we gonna initialize that to be equal to and you list off type integer, open doors, parentheses and close the line was a semicolon. Once again, this are dynamic. We can flush and data and take away data at any time whenever we like to. So that's why we're gonna make use of that. Now we want to check What are the possibilities for this particular first checked list we currently have? And to do that, we gonna request the coordinates in X and why which we have filled in over here per reiteration. Basically So what we're gonna do is we gonna take this number and we need to create a new function you list, which is going to become returned whenever we request something. So we create a new list of time in over here and we give it a name, for example, get or posa abilities and we need to fill in the X coordinate off time interred a X into why for the y coordinate, then we want to reference any grid. We don't care about the value because we have a value already. Or actually, we know that the value is going to be zero. So we want to return a list from this function over here, which is taking care of what shanking for us. What are all the possibilities? And now we're gonna make use of our check all function because we can actually take care off that and because off whatever they return and through a falls based on the check or functionality, we're going to get the coric values back. In that case for self, we need inside of here create another list of inter just because we need to temporary store this over here, I can also name this possible let teeth, and we can We need to initialize that already as a new list off type into gia and only close parentheses. Close the line. Was this in my colon? Now we're gonna loops through our value, whichever the value is we want to have over here. And since we don't know the value, we're gonna define it in this for you. So I I gonna name I've l because this is the value we want to check against. We're going to start at zero, and we think up until nine. So we say smaller, equal nine. And this followed. So this is the value we possibly able to tank inside this particular cell. We want Toe Asa request. So when we want to do is we request I will check or function and put in all necessary data . So first off, we want a request X comma. Why? So the ones we're gonna try to get from this get possibilities function. Then we boot in vell, which is the looped through value, and then the referenced grid. So ref grid and whenever that is going to be true. Then like we returned True because this product does not contain any row column or block number off this particular value. Want to put the found value into the possibilities funk list? So we say possibilities don't add. What do we want to add is basically the value Good. Now we need to return this list off possibilities. So whenever we had done was the four loop. After that, you can say return possibilities. The great thing about that is inside I was solved. Grid we can no request get on possibilities. And Phil, I'm a possibility. This list over there don't forget to save. And maybe you'll shrink this together or not. And open the soul grid again. And in here we cannot say possibilities is equal to get all possibilities. And then we're gonna fill in just the numbers or the data. We want to request X. Come on. Why and our reference grit and the value is calculated inside our check. Don't forget to close. The line was a semicolon. Now we just need to start the backtracking as a charism after we're done. Was that to check if we can actually do something 39. #39 Solve Grid 2: Welcome back to the course in this part. We want to do the final or almost final backtracking Check algorithm, stuff, insight. Ah, bullying check. So go into your board script and open up your solve grid function. And after we're done with checking all the possibilities and storing them inside the list off possibilities by getting them, we can now look through it because we know all the possible matches for that. So we looks rule with our into whatever index, we want to make yours off. We can also use the P for possibilities. You can also keep it as is. And the number we are requesting is going to be smaller than our possibilities don't count . So we want to look through that complete list we started zero. So the index zero up until the maximum Whatever is going to be inside over there, what we're gonna do now is we're gonna set a value already inside of a in our grid, so set a possible value. So what we do is we talk to our grit, our reference grit, and put in this particular value. So grit open, close square records, and now we're gonna take basically the information we have already in this gaze its X comma y Because we do this all on one, it oration and we want to set this one to be equal to whatever we have in possibilities. Don't pee for our possibility. So we have when we sent X y so great exploit this one the first free. So we found in this case and sent this one to be equal to the possibilities peak. Whenever we have that, we know that we have to backtrack. So no, we're gonna I gonna make another command, backtrack and to do the backtracking. Basically, we need to request the same function. So in this case, whenever the solve grid returns something, whatever it is, we want to give it back over here and go backwards and update accordingly. So in that case, we call the same function we are currently in Solve grid, open, close parentheses. We want to reference the current grid. We are in course, we need to have another parentheses over here. And when we know want to do is whenever that returns the true. We also want to say OK, return True. So basically, if we have any match over there if that particular step works otherwise. If that is not the case, we want to return force, basically. But in this case, since whenever you know are we know that does not return true, we want to update the grid again, back to where it came from. In this case, you're gonna set grit, X comma y to be equal to zero. So we reset the cell to be zero, and we're gonna go forward basically. And in the next iteration, we gonna check if we're going to find any other possibility for this particular one. Meanwhile, we fill all the other ones at the same time as they also can see. Is this else statement overhears redundant? Meaning it is not really needed to put the else statement over there. Because whenever we returned true over here, we will never be at this point, no matter what. So in that case, we would return force at this point in return or actually bring the grid to be zero. So in that case, you can also take this outside or you don't have to put it into an else statement over here . Just keep it as here because we know already that we have not returned to at this point. And we did not actually left this particular bowling check. Don't forget to save this is important. And let's go back to unity and see what's going on. If you have any mistake, anywhere it can happen that unity is going to crash. So be very careful. And if it crests, use your task manager to actually stop the unity and restart and see where the trouble or where the problem is. If you don't know where it is, just rewatched the videos about the recourse off backtracking aneurysm. So whenever we press play, we're going to get a bunch of numbers over here. I'm gonna make it so that I can't see the amount as you can see, because off Backtracking has 148 messages before it starts to give me a result. So the 1st 1 is going to be, as already explained before is the filled grid the first situation in the second iteration ? It tries to fill in a number over here so you can always go. Okay, This one gives me a number one and he is a filling the next number. In this case, it's a number three. So he feels now from left, right. It can also go up by wise version. Can. Also, as I explained before start from here, basically doesn't really matter. So he fills these numbers now inside, which are probably on which are matching this particular field we're in. Then it goes into the next row because these are no zeros left over there. Now we go to the next one. Okay, The six matches over here because it's not in the block, it's not in the row. It's not in the column. It's going to continue this the will time. Let's see until we find a parody like you. So he's trying to put in a five in this point it so the AI or our program tries to fill in a five in the next step it sees. Oh, no. It is impossible to put go further at this point because this three can not to be a three at this point because it does not match over there. So what he does is what the program doesn't change is the value of the possibility for this field to an eight and fills the three over there because it cannot put it over here because it gives the parity. I guess because of the top over there. Next one. Is he putting the five inside. Then he noticed Oh, no, the three cannot be at this point. It would give a parody, do it through another attack and fills in the five over there. And then it's rice to fill the the number three in this next point. And then he sees Oh, no, All of that does not work again. We gonna take here and take the next possibility for that number is going to be in nine. It does make more sense, probably. Then he fills in the three once again in this role and see if that makes more sense. And then the five. So the next two possibilities, which we had before already. Then he sees no three does not work. So he goes back and put the five inside of a day and keeps the next one going to give the three again. And then he noticed. Nope. All of that does not work. We're gonna have to backtrack even more because he cannot fit the five and the three in these to pay in spaces because the five is already represented over here as well as over. Here is the three already, so he cannot fill this information. Also, here's the five and he has the three, so these two numbers are just breaking it completely. So what's happening? You feels now another number before it wants before. Now he gets takes the same or the next possibility from four to change it to eight and tries to import the three again. Now we have other possibilities of four and 54 does not match, so it takes the five at the next point. Then he changes five and four does not match. So he takes the four back over here and he does that the world time until he's able to find the correct possibility. Now he has 189 over here checking against a nine. Can he fill? This number is completely over there. If that is the case and it is now the case, he's going into the next row over here, and now we can check the complete process working Raza smooth through that. So do through. That was rez. A simple especially in the last point, because these were the only possibilities left to put into this fields. Now we can go and check the other ones over here as well you can do on your own. You see, It takes him quite some time to fill all this information. But the less possibilities there are left because we have a bunch of numbers of here already, he is able to full full rez a quickly and take away from all these possibilities over here . Check out dust that match. Does that work? Can we make use of the six in this particular one? Yes. No. If we cannot do this, if you cannot go forward, then we gonna feel completely different. If we have any parody, then we gonna track back completely. And he keeps all this information about all this year things or this interest correctly inside over here and goes back through until he finds I'm not gonna scroll down a complete fulfilled grid. Once again, you can take this one and bring this into any editor of in new. If you don't see this completely and make a check on your own, check out if he is doing it, 1% correct. So check out every cell. 12345678 nine. So this cell works 1%. Also go through the rope. 8196375 to 4. So this are the first rose we have created beforehand. So these are matching, no matter what. Just make sure that, for example, this one here works 1%. 123456789 So every number is since I also take any random rule and goes through its 7645 to nine 138 What you can now see as that you don't have any off these numbers sets anymore as we had done before. So as you can see, for example, this one is a 791978972 So there are no Yeah, Axel. Yeah, matching pieces or not as they are as we have done before or had done before. Also, you can light on Philip Rosen. Switch rose if you'd like to, or even columns. But make sure you only do this inside these blocks. So that's everything for the backtracking Al Gore ism. And now with since we have a fulfilled field, we need to update all the other functionalities to give the correct feedback back into the grid and make it able to be solved once again. 40. #40 Optimize Create Riddle Grid: welcome back to the course in this part. I want to make sure that we are updating or creating our riddle, grit and updating the function we already have. We can also just copy and paste it and change it to our needs are gonna explain it right now. So first off, go into your script and see where you are. Create griddle grid function is another Copy that since it doesn't contain any arguments, it will not have any problems for us later on. So I'm gonna make another comment over here and name. It may be something like a new gameplay. I got a copy. Editor will be red line underlined over there. But as soon as we fill in some data over here inside the create riddle grid function, it goes away and we can talk to it like we actually would without any problems. First off, we want to have to arguments in this, so we want to reference to grits off time Inter gia to D array. So the 1st 1 I'm gonna name here is s grid for being on our sold grid. The 2nd 1 I want to have over here is going to be also another referenced grid. In this case, it's also type into Gerais. Gonna name it our grid for our riddle grid. As you remember, probably over here we create a little group out of this empty. So we need to copy the complete field from A to B. As you seen here, we gonna made use off a follow up, which is, let's say, not the fastest idea about it. We can optimize that Bible or for being faster so the gameplay can start even further to do so, We gonna make use of a system or .net function. It's off type or which is sitting inside the system name space. So we can't say system dot array. And now we want to do if you want to copy that array and which do we want to add or which we want to copy? Is it for us? Whatever the solved grid R. A s. So as grit is our reference point over here, the next one is going to be on a destination array. In this case, it's our reference riddle grid. And now we need to have the lengths. How long is that going to be in this case, we're gonna take as great dot lengths as our yes size indicator. And what we cannot do is we can get rid off this functionality. So we are not actually taking care off really great and solve it because probably later on , we're gonna have any other grids. We may be too grits at the same time. We can reference or talk to no problem at all. So next one is we wanna set. I want difficulty, of course. And now what we're gonna do is over here. We're gonna erase parts from the riddle grid. And since we're doing this over here in a while, loop and we talk currently to riddle grid, which is absolutely okay. But we can also say we gonna go and take our actually rather our referenced little grit. So our grid in this Y loop and over here Once we found one, we're gonna set this one to be a zero. Don't forget to save, and what we can also do is we can once again, after we had done was creating the riddle grit. We can't debunk that riddle grit. So now I go back once again to the start function, and I want to make sure that I create a riddle grid. And since we have to riddle grid functions, we're gonna have to possibilities. We can take the 1st 1 or the 2nd 1 which is taking or which are taking our reference grits we want to take so we can say ref solved grit, comma, ref, and then our riddle grid because that's this grid. We want to copy our stuff into and delete things from when I go down. Once again, I got a d back. That and our nearly created riddle Grit should look well, as we already know beforehand should have some zeros inside. Let the compiler run and press play once Now it took 147 steps are actually two less because this step is also counted. So I can see this is our full grid or solved grid. And this one over here is the created riddle grit from this grid. So we just first copy that was disarray Kobe message, which is way faster than doing it to buy two full loops. And now it is an optimized grit and looks pretty correct. So depending on once again whenever we goto our board and depending on how easy or difficult this is going to be, even if it is an insane one or debunk one, it's only shoot. Delete five zeroes in the riddle grit so we can check it out if one over here to over here . 34 And there's one missing somewhere over here in the first row. So that's know how we create or updated our riddle grid functionality. Don't forget to save if we have done any changes and that's go forward the next video. 41. #41 Update Start Function: Welcome back to the course. The final step over here might be, at least for the moment, create the buttons. So I'm gonna copy this line over here, which we already have created, and put this over there. Don't forget to a tank the difficulty line. And to bring this before, we are going to feel the grid base over here. Make this one active once again. Otherwise, the buttons are not going to work from the main menu. And the settings will always be the debugging settings. Don't forget to safe. And then you're good to go with the start function and that See if that works after the compiler is done. Ronnie, I gonna press play and we should see a fuel off buttons with five possible inputs. Do it through our debugging purpose. And we now also be able to get a hint one to and we only got to two because we decided to only have two hints over there. They since seem to be correct. So last one is 123 though, So we need a four in here. 12345 So one of these are going to be a six and it's going to be this one, and the last one is going to be almost seven and we can't check for complete. And you see everything works once again, but was away more complicated grit, which we created beforehand. You can play again, and we should be able to load a complete new scene and create a new complete riddle grid. Where's new actually created functionalities. You can also always check if these D rose over here are actually once again matching this fields, and they seem to do so good. Also always cheat because you know what the solve rate is going to look about, and now you should be able to create easy, medium hard and even insane mode ones on your own. 42. #42 Game Ideas: Welcome back to the course in this part. I want to give you some ideas. How? Teoh stand out from the crowd with us. The Dokka game. In our case, we're just made use off a simple and usual surgical. Yes, serious. So we gonna make use off numbers and put them into our fields into our text fields. But what if these would not be numbers? Think about what? With that would be letters like from A to F or whatever the amount of numbers is you're gonna need to have here. So ABC on D E F G h I. Let's say up from a toe, I If you're gonna put in letters instead of numbers into what would you need to dio? Just think about that. What would you need to do to put letters inside this fields? What would you need to change? Think about that for a minute or two. And probably you get the solution already because what is a letter? A letter is a string, so you need to convert all these numbers into letters. Of course you need to. And of course, in late, only to compare if this is going to match or not based on strings, not on these numbers or indigenous, so that is one idea behind it. So you can basically make use of strings and then just put in these interjects or change these indigenous to be actually string letters. What about using images like symbols? Think about you have, like nine different year figures or smiley faces or flowers or whatever it ISS think about that. And yet maybe you're going to get an idea, or even colors like you need any color off any type off shape. Or let's say you have different shapes, like a square triangle, a circle off course, hexagon, end gun, whatever and all the other things like stars and, you know, filled and not field circles and your other stuff. You can also put in any other image. But how would you actually do this? Think about that, and what you can do was that is, he can differentiate or answer the standard from the crowd with your specific type off game , where because you're gonna do it completely different as other people's. I mean, there are a lot of the local games outside, I guess, but now you have the knowledge about the records of backtracking, and now we just need to think about how could you change? Basically, the you have the input fields or how can you change these? You? How can you make use of images instead of text fields? How can you make use of anything else, whatever it is and make sure you have one specific one. Also another possibility. If you let's say we're going to stay at numbers, how about is super Easy one for kids like you don't have a nine by nine field about a six by six, so it's smaller. What do you need to do? What do you need to change? Just think about that same four for a super experience player for a not nine by nine but 12 by 12 field. If you increase the size, what do you think is going to happen? And is the same principle working? How many backtracking do you need, of course, and recurrences in recourse of backtracking. How many steps are needed? Actually, doesn't matter. It takes a couple off milli seconds, and what is actually how can you make it even more difficulty later? A little difficult later on. What do you need to do with input field? Of course, you need to implement more numbers onto this. Otherwise, the play I cannot put in any other numbers inside, like, 11 or 10 or 12. You need to have this possible input fields for this particular place style. So in the end, you're gonna have to update the complete grid or probably make sure that you're going to make a use off different. Yes. Set up possibilities, I would say. And how would you do this? How would you make your life easy to do this, Ashley, think about an Emam once again. You know, an Inam is just a setting possibility that we talked about the settings already and how we can copy them and just think about you have button for, ah, kids mode, expert mode, whatever mode. And then you also have the difficulties inside thes according to the settings according to these different difficulty levels. And of course, the difficult those settings between the child mode and, for example, the insane mode which probably has a 12 by 12. And then you're gonna have a different setting for that because it is not anymore the child mode where you probably only take away, like 10 numbers off this field. Or maybe in an ad, insane a child mode might be not more than 20 or something like that. So the child actually is still able to fulfill the complete grid over there. Think about that. And also when it comes to the size, of course, you can also go and do something else with ease your numbers instead of numbers. Once again, letters once again images any type you can think of. So these are my some ideas for you as an extra and in how to improve or increase the value off your game completely over here. And, of course, how you stand out from the crowd with your specific and very own version off Sadako. If you have any questions free, free to ask at, probably I'm able to answer them. 43. Conclusion: Welcome back to the course. This is the final video about the classic Sudoku tutorial. Serious? I hope you enjoy this one. And I served you well. Feel free to write me any commands or you ask questions if you have any already. And ah, don't forget to share your experience with the scores by writing a small review about the course directly. I hope you enjoy this one and out to see you in one off my other courses. Thanks a lot for taking this course and have a good day. Bye bye.