WEBVTT

00:00.660 --> 00:11.370
Now that we've gone through and sort of determine kind of what each major section has in terms of the

00:11.790 --> 00:21.990
data and so before we midships then or adds in the players in this guess I'll say.

00:22.500 --> 00:28.880
So let's actually start making the real types that we all need.

00:29.250 --> 00:35.150
So first thing I'm going to start with is kind of in the ship's order.

00:36.420 --> 00:40.110
Ships part it says five types listed above.

00:40.190 --> 00:40.840
OK.

00:41.000 --> 00:46.260
So we have the aircraft carrier battleship cruiser destroyer and submarine.

00:46.280 --> 00:53.260
So we have this ship type and it can only have five values.

00:53.270 --> 00:57.810
It has a very fixed and finite set of values.

00:58.130 --> 01:04.140
So that to me means that I should be using an Ina.

01:04.550 --> 01:08.870
So I'm going to make you know I'm going to call it the ship type

01:11.680 --> 01:22.150
and I'm going to actually add one more ship type and that is the ship type none.

01:22.210 --> 01:24.050
So it kind of has.

01:24.130 --> 01:32.450
There is no ship sets and you'll you'll see why I want to have this probably a bit later.

01:32.470 --> 01:40.100
But for now just know that we need none and then was going to say all the rest of ours.

01:40.210 --> 01:45.860
Aircraft carrier in it.

01:46.010 --> 01:55.420
And that I'm using s t i typically prefix all of my arms with the kind of first letter of each word.

01:55.450 --> 02:01.490
So I usually use s t from the same ship type.

02:01.940 --> 02:08.010
I'll ship this case as the cruiser

02:10.420 --> 02:12.740
steede destroyer.

02:14.420 --> 02:18.930
It's these submarine.

02:19.190 --> 02:25.010
So one of my types will be the actual ship type just like we have a pier.

02:25.290 --> 02:25.820
OK.

02:27.280 --> 02:37.120
So the next thing is what else is a ship kind of have it's just kind of cherry pick some the orientation

02:37.700 --> 02:41.240
OK so can either be vertical or horizontal.

02:41.260 --> 02:49.770
So again just like with the ship type we can only have two values vertical or horizontal.

02:49.780 --> 02:54.060
So again I say we all need enough for this.

02:54.170 --> 03:14.400
So say ship orientation type and anime's going to say so aren't all so again for ship orientation.

03:14.570 --> 03:16.390
It is so vertical.

03:18.780 --> 03:24.840
And I'm not going to have a S-O none right because I can't there's no possible way that you can have

03:24.840 --> 03:27.340
a ship that has no orientation on board.

03:27.680 --> 03:30.880
We don't need that.

03:31.810 --> 03:39.960
So now what we have in our ship is a position right.

03:40.080 --> 03:54.690
So this one is a road between a NJ which is one in 10 right and columns between 1 and 10.

03:54.690 --> 04:05.560
So how I'm going to represent this is through a struct because it has two different two different values

04:05.870 --> 04:08.010
K row and a column.

04:08.020 --> 04:14.430
And for mine I'm just going to we're just going to be integers.

04:14.580 --> 04:15.930
Ok --.

04:18.090 --> 04:18.460
Zeeshan

04:22.040 --> 04:24.640
in a row.

04:25.480 --> 04:29.760
In going to call.

04:29.910 --> 04:34.350
So all the ships will have some kind of position

04:38.540 --> 04:46.540
so the last thing we probably need is the use.

04:46.680 --> 04:54.390
It's really and of course that will just be an integer so we don't really need to make anything magical

04:54.390 --> 04:55.080
for that one.

04:55.080 --> 05:05.580
So we're actually going to move on to actually creating a ship so to say ship is a struct because it

05:05.580 --> 05:12.420
holds multiple values as a position as an orientation and has a type.

05:12.420 --> 05:14.090
Just like I showed up here.

05:14.250 --> 05:19.020
So I'm going to represent our ship with a struct.

05:19.640 --> 05:21.680
And I'm going to say ship type

05:26.580 --> 05:30.890
like that it has a size shape size

05:36.620 --> 05:45.730
ship and teach and I say you teach an

05:50.140 --> 05:58.430
and it has a position.

05:58.760 --> 06:10.610
So see how we use what we kind of broke down in the understanding phase and translate it into real types

06:10.700 --> 06:15.760
and what we'll use as real data in our game.

06:16.630 --> 06:19.840
So doing this really well.

06:19.840 --> 06:30.220
Like I said in the first section what your input is really will define how your algorithms will interpret

06:30.520 --> 06:38.740
that data and can interpret that input in a specific way to the specific data.

06:38.740 --> 06:45.040
So that's why we really do this first because this is what's really going to guide us in terms of what

06:45.040 --> 06:50.310
the algorithms should do based on this data.

06:50.650 --> 06:58.670
So this is why understanding and creating the input is usually first before actually doing the algorithms.

06:59.640 --> 07:11.730
So now that we have our ship k we should move on to our board and notice that I didn't really specify

07:11.730 --> 07:14.390
what this is yet.

07:14.400 --> 07:25.230
With our ship and and that's because it really depends on where the ship is in on the board.

07:25.270 --> 07:33.370
So really this damaged spot on the ship depends on the board position that it's at.

07:33.370 --> 07:37.540
So I'm not going to have that represented here.

07:37.540 --> 07:44.290
I'm actually going to postpone that into the board snacks.

07:44.350 --> 07:50.250
So what do we need for the board.

07:50.670 --> 07:51.210
OK.

07:51.300 --> 07:54.810
So the boards there's two different kinds of boards.

07:54.810 --> 07:57.490
One is the gas board has three states hit miss.

07:57.520 --> 08:01.720
And you know maybe none I guess.

08:01.950 --> 08:10.470
So one thing we need is kind of our guest type and we need them just like before.

08:10.610 --> 08:11.150
Type

08:13.760 --> 08:21.310
and we're going to say guess type none if we haven't guessed there right.

08:21.400 --> 08:22.520
Zero.

08:22.550 --> 08:24.240
And guess I missed.

08:24.450 --> 08:24.880
Right.

08:26.080 --> 08:34.300
And guess type hit.

08:34.320 --> 08:48.380
So those are three different states that this guess or can be and the other part is our shipboard.

08:48.450 --> 08:55.480
So what would define a ship or what type would we need.

08:55.530 --> 09:00.560
So just like the guest board the guest can only be in three states and we're going to make our guest

09:00.560 --> 09:06.490
bored out of this type and speak to the array of this type.

09:06.560 --> 09:19.810
But what about our shipboard needs a ship and it needs I guess whether it was hit or not.

09:19.810 --> 09:31.270
So for that I'm going to make a structure and call it a ship part type

09:34.030 --> 09:41.060
and it's a ship part time because this is only me one kind of square on the board.

09:41.950 --> 09:51.030
And the ship part time is going to have a ship type.

09:51.230 --> 09:52.720
We had with the ship.

09:52.850 --> 09:53.220
Right.

09:53.290 --> 09:59.630
Same type and I'm going to have a boolean saying whether it's hit or not.

09:59.700 --> 10:04.290
So is hit.

10:04.380 --> 10:07.120
So that's all is really going to have.

10:07.240 --> 10:15.920
Because if you played it before you know and your bottom board is that you have a ship placed at a certain

10:15.980 --> 10:26.570
position which is going to be set in the ship itself this position in orientation and whether it's hit

10:26.570 --> 10:26.960
or not.

10:27.080 --> 10:32.520
So that should cover that.

10:32.610 --> 10:36.870
Now now we have the player right where

10:39.200 --> 10:52.540
in each case it's going to be another struct they're and that's where we'll have a name player name

10:53.930 --> 11:01.890
and we don't know how long the names can easily see ten for now or we're going to make Hanssens for

11:02.150 --> 11:04.050
these in a second.

11:04.320 --> 11:06.770
It's going to have a number of ships.

11:07.130 --> 11:07.490
Ship

11:10.740 --> 11:12.390
and there's only five.

11:12.390 --> 11:15.430
Again I'll make a constant for this in a second.

11:16.650 --> 11:19.460
And we'll have a guest aboard.

11:19.660 --> 11:23.730
So we're going to use GPS type to make or board.

11:23.980 --> 11:28.950
And we know how big it is so we should just use a basic 2-D.

11:29.490 --> 11:30.320
Guess board

11:32.820 --> 11:39.240
and make constants from this second sets at 10 by 10 right.

11:39.320 --> 11:42.680
So here 10 grid

11:46.140 --> 11:53.650
and we have the ship or two which are going to make and ship parts part time

11:58.400 --> 12:04.480
we could design the data in a different way for this but this is what I came up with it seems pretty

12:04.610 --> 12:11.460
well.

12:11.480 --> 12:15.650
So now we have a bunch of constants here.

12:15.680 --> 12:18.040
And I kind of want to get rid of those.

12:18.200 --> 12:23.250
So I'll show you one interesting thing you can do with them.

12:23.660 --> 12:35.460
And then having kind of an anonymous and we're going to need a few kind of constants so you need an

12:35.530 --> 12:36.220
aircraft

12:39.080 --> 12:44.430
carrier size right is five spots.

12:44.440 --> 12:48.970
So it's set up here right size there.

12:49.520 --> 12:54.200
And I mean do you have for each ship ship size

12:58.940 --> 13:05.160
that and notice I'm like actually setting all the values directly.

13:05.190 --> 13:09.700
So if you if you have an anonymous you know you probably want to set them all directly.

13:09.780 --> 13:13.530
And these really just amount to constant integers.

13:13.530 --> 13:15.070
Really.

13:15.330 --> 13:24.960
That's why that's why I'm using cruiser size three destroyer sizes the

13:33.270 --> 13:33.920
green

13:36.360 --> 13:38.580
to.

13:39.360 --> 13:51.660
And our board size is 10 or so a 10 by 10 grids and the number of ships you have is five cents a ship's

13:53.640 --> 13:59.640
that and we when to say the layer name size

14:02.450 --> 14:05.860
is going to be eight characters.

14:07.820 --> 14:19.850
Because I'm going to have is like Player 1 player 2 and she's 1 2 3 4 5 6 7 plus 1 for it all character

14:19.850 --> 14:21.910
right C C string.

14:21.910 --> 14:27.830
So that's why it's eight characters and I don't have one extra one called Max ships.

14:27.890 --> 14:29.980
It's as well.

14:30.340 --> 14:38.330
And I'm going to use the aircraft carrier size for it.

14:39.780 --> 14:45.560
Because a ship is maximum size five very big is an aircraft carrier.

14:47.190 --> 14:53.420
So that's actually the data that's really all the data that we have.

14:53.580 --> 15:01.340
The and it's just I actually said all your names.

15:01.580 --> 15:02.800
Yes that's right.

15:02.820 --> 15:07.380
All right in ship's

15:11.410 --> 15:12.330
size

15:16.660 --> 15:22.090
size like this one supports It's

15:30.310 --> 15:35.940
something kind of interesting you can do with domes just have anonymous names that just have a bunch

15:35.940 --> 15:38.860
of values that it can be.

15:39.150 --> 15:42.930
And really this just amounts to being constants.

15:42.990 --> 15:55.240
So now that we've finished our data this should give us an idea of how our algorithms are going to work.

15:55.600 --> 15:57.990
So we have to have two players.

15:58.000 --> 16:08.090
Two variables of type player and these players have a name that ships their boards rank.

16:08.140 --> 16:14.150
So there's you plan for boards but there's two players two boards per player right.

16:14.230 --> 16:15.830
So each player has that.

16:15.860 --> 16:17.360
There are two different boards.

16:18.160 --> 16:18.910
And

16:21.510 --> 16:22.610
that's really it.

16:22.620 --> 16:30.150
So this is really going to determine how are our top down design and ultimately how our implementation

16:30.660 --> 16:33.000
is going to be done.

16:33.030 --> 16:38.300
So in the next lecture I'm going to go over some of the top down design.
