WEBVTT

00:00.630 --> 00:06.340
Soon we're going to start creating our Battleship game.

00:06.810 --> 00:15.540
And I really feel like this is the game that really emphasizes what I went over in the first section

00:15.540 --> 00:24.450
which is how to approach problems and how to have a specific methodology for doing so.

00:24.450 --> 00:34.490
I think this one's going to illustrate that the best and if you remember the picture programming that

00:34.490 --> 00:46.240
I have in my head you'll know that since we have this picture we you should notice that every time we've

00:46.270 --> 00:51.530
solved again we always start with understanding the problem first.

00:51.850 --> 00:52.580
Right.

00:52.600 --> 00:55.640
This is kind of the output of it all right.

00:55.760 --> 01:01.480
And I always said that first you understand the problem then you kind of understand the data and then

01:01.480 --> 01:04.700
you do kind of all the transforms.

01:04.900 --> 01:06.550
In other words algorithms.

01:06.550 --> 01:11.120
This is really understanding the problem is always the first part.

01:11.260 --> 01:18.490
And so in a read through the description try to understand what will need right all the input that will

01:18.490 --> 01:24.920
need and that will give us a very good way of creating the algorithms.

01:25.000 --> 01:28.270
This would be the kind of top down design part.

01:28.690 --> 01:38.590
And in this lecture I want to focus on the both the output and the input of the game.

01:39.190 --> 01:52.010
So skill through this so game Battleship game is played on for 10 by 10 grids by two players each with

01:52.010 --> 02:01.240
each player having two grids each the rows of the grid go from eight J in the rows and one to ten in

02:01.250 --> 02:09.130
the columns each player will arrange their ships on their respective ship board before the main game

02:09.130 --> 02:10.810
starts.

02:10.810 --> 02:18.750
Each ship occupies a number of consecutive squares on the grid arrange either horizontally or vertically

02:19.860 --> 02:28.110
the number of squares for each ship is determined by the type of the ship the ships cannot overlap.

02:28.470 --> 02:33.100
And we have five ships here the aircraft carrier and the site size is five.

02:33.100 --> 02:41.810
About ship is order cruisers 3 and Sawyer is also three and the submarine is two.

02:42.070 --> 02:45.270
And so these are going to be sizes on the grid.

02:45.300 --> 02:52.770
So they're going off by for example the aircraft carrier is going to occupy five spots or I've squares

02:52.770 --> 02:53.640
on the grid.

02:54.360 --> 03:02.530
And so after the ship has been positioned the game proceeds in a series of rounds each round.

03:02.670 --> 03:09.830
Each player takes a turn to announce the target square in the opponent's grid which is to be shot at

03:10.760 --> 03:18.440
the opponent announces whether or not the square is occupied by a ship and if it is Miss the player

03:19.220 --> 03:23.480
marks there guest board as a miss.

03:23.720 --> 03:27.560
And if it is a hit the market has hit.

03:27.650 --> 03:32.030
This is the build up a picture of the opponent's fleet.

03:32.240 --> 03:41.360
If the guess was a hit the attacked player will mark their ship as it has hit in the best location and

03:41.450 --> 03:42.910
that will end the turn.

03:44.760 --> 03:47.400
When all of these squares the ship had been hit.

03:47.400 --> 03:52.020
The ship will is sunk.

03:54.090 --> 03:58.900
And there is output about what ship was sunk.

03:59.070 --> 04:05.500
If player ships have been sunk the game is over and their opponent is king.

04:05.670 --> 04:17.650
So so now that we sort of understand what the game is I think we all play of before we should start

04:17.740 --> 04:23.220
trying to understand what kind of input we're going to need for our.

04:23.440 --> 04:29.420
So it's kind of start doing that right here.

04:29.470 --> 04:33.220
So in general I've noticed

04:35.500 --> 04:38.120
three or four things.

04:38.740 --> 04:45.530
Generally I have noticed that there are ships.

04:46.740 --> 04:48.940
I've noticed that there are boards

04:52.620 --> 05:06.070
and players and we have this kind of gas as well or the guess is really a position on board

05:10.240 --> 05:11.240
Kay.

05:11.380 --> 05:21.930
So of of those kind of for general things in here from just reading the description now let's kind of

05:21.930 --> 05:28.690
break down each one and see what they are or what they can consist of.

05:29.130 --> 05:30.760
So it's sort of a ship's

05:36.780 --> 05:39.900
in there are five types.

05:39.920 --> 05:49.870
OK that's one thing that the ship has sort of a type in it listed above it was out of

05:52.550 --> 05:55.150
say five types

05:57.410 --> 06:06.110
in its There are they have a size right.

06:06.140 --> 06:14.040
So if those here an aircraft carriers five spots on board so each one has some science.

06:14.090 --> 06:14.280
Ok

06:18.180 --> 06:27.340
one has a position on the board.

06:27.410 --> 06:27.910
Right.

06:28.110 --> 06:45.120
So the roads are between a and J and columns between one and 10 or so some position.

06:47.200 --> 06:52.340
And they have an orientation on the board.

06:52.500 --> 06:52.980
Right.

06:53.200 --> 07:05.420
So either vertical or horizontal.

07:05.550 --> 07:06.410
So

07:11.730 --> 07:17.020
right here so each ship occupies a number of consecutive squares on that grid arrange either horizontally

07:17.050 --> 07:27.220
or vertically so they have some position and they occupy some size or some consecutive number of squares

07:27.250 --> 07:31.310
on the board and their position horizontally orbit.

07:31.500 --> 07:32.170
Right.

07:32.610 --> 07:36.110
So we're just trying to understand kind of what a ship is.

07:36.220 --> 07:37.550
That's what we're doing here.

07:38.290 --> 07:52.320
And the can be damage rate because if you guess and on one of their spots then and if it's a hit they

07:52.320 --> 08:00.950
were hit in that specific spot right in a specific spot.

08:03.930 --> 08:11.030
And that's kind of really it for ships there's nothing much more really.

08:11.370 --> 08:13.760
So let's move on to the board.

08:13.780 --> 08:14.070
It's

08:21.820 --> 08:32.390
so if you have ever seen a picture of someone playing battleship you'll know that the top ored is kind

08:32.390 --> 08:33.410
of your

08:36.680 --> 08:40.880
Europe like your view of your opponent's sport.

08:41.690 --> 08:45.750
So they're really two different kinds of ball.

08:45.830 --> 08:54.460
So two different kinds different or really.

08:54.560 --> 09:02.800
And that is your he going to say the ship or where you place all your ships and

09:08.080 --> 09:15.000
right in your I'm going to say it's the guess or in fact set it up here.

09:15.350 --> 09:15.970
So

09:22.450 --> 09:23.690
it's somewhere here.

09:24.560 --> 09:29.650
You turn the page.

09:29.990 --> 09:34.020
I've said so right here.

09:35.370 --> 09:37.740
So that's going to be kind of your

09:40.800 --> 09:42.020
your view of the pones

09:44.510 --> 09:49.530
or you.

09:49.830 --> 09:50.530
It's

09:53.010 --> 09:54.110
OK.

09:54.300 --> 09:56.360
There's kind of can be two different one.

09:56.440 --> 09:58.930
It's so

10:02.080 --> 10:03.760
the chess board

10:06.460 --> 10:11.900
and be in three states re.

10:12.000 --> 10:19.640
So it can either contain Like or so each spot on board.

10:21.160 --> 10:22.000
Each

10:24.830 --> 10:30.310
sition on the board can be in three states right.

10:30.590 --> 10:35.890
So you either be hit there could be a miss.

10:36.150 --> 10:41.100
It's like you didn't hear anything there or we haven't guessed there.

10:41.260 --> 10:48.100
Right.

10:48.390 --> 10:49.200
So

10:51.990 --> 10:52.930
that's really it for that.

10:52.950 --> 10:56.370
And there's only there's only three states that can get in.

10:56.370 --> 11:01.320
And there is a board for your your ships.

11:01.320 --> 11:02.300
Right.

11:02.340 --> 11:07.710
So in or for ships

11:10.320 --> 11:23.100
so this will just contain all the players ships at certain locations.

11:26.500 --> 11:35.650
So we don't really know what that means but also there is one other part of that which is you know in

11:35.650 --> 11:40.810
the traditional game the place markers

11:44.120 --> 11:54.020
on the spots where our ships have been hit

11:57.660 --> 12:02.400
so you hit so your opponent guessed and they guessed correctly.

12:02.680 --> 12:13.790
We as the attack player also mark our ships as being hit right so so so so the gas was hit the attack

12:13.800 --> 12:17.200
where I will mark the ship hit the guest location.

12:17.220 --> 12:17.650
Right.

12:17.850 --> 12:23.670
So we also do this just so we know what's been hit and what what hasn't.

12:24.040 --> 12:25.670
OK.

12:25.880 --> 12:31.660
So that's kind of it for the Bortz.

12:32.130 --> 12:38.560
The other thing was here's.

12:39.210 --> 12:43.980
So the players have kind of.

12:44.040 --> 12:50.550
So we're just going to say how I want the players to have a name and name

12:57.270 --> 13:00.190
and they have all their ships.

13:00.870 --> 13:10.140
The ships and they have board or and they have the ship board.

13:10.160 --> 13:10.620
Right.

13:14.940 --> 13:18.030
So they actually contain all these things.

13:22.140 --> 13:33.490
And of course the last thing I notice or I put down here which is guess really I guess is just a position

13:35.990 --> 13:37.860
on the board.

13:48.450 --> 13:50.340
And those position

13:53.590 --> 13:58.180
has a row which goes for a to J right.

13:58.180 --> 14:06.640
That's from you know if it was one in ten or eight and from columns

14:10.590 --> 14:10.960
1

14:18.180 --> 14:25.220
in that's kind of really it's so sort of broken down now.

14:25.330 --> 14:26.020
The

14:28.570 --> 14:29.780
what.

14:30.030 --> 14:36.540
What they have and notice or what battleship has you know so we're really just kind of describing the

14:36.540 --> 14:44.310
problem again but we're just describing the problem again kind of more broken down into its individual

14:44.370 --> 14:45.780
elements.

14:45.780 --> 14:55.110
And in the next lecture I'm going to take everything that we have here and turn it into actual user

14:55.110 --> 15:04.250
defined types and so that we can actually describe our problem in those types and actually writing code

15:04.250 --> 15:06.130
in those types.

15:06.320 --> 15:08.120
So I'll see you in the next lecture.
