Reflection of class on Nov. 3rd
As we all know, most
interactive games utilize powerful logical system to improve players’
participation and interest, that is, they provide different modes or choices for
players to choose and each one could lead to a unique consequence just like the
Raspi’s Cave Adventure.
But designing a
complex logical interactive game and achieve it by programming are not easy, we
should consider comprehensively and be prudent to every line of codes we would
create. So, we need to work out a plan by drawing a flow diagram for the whole
game first to make the later programming process a little clearer. We can use a
diamond shape to represent each decision, a rectangle shape to represent each
consequence and a round rectangle shape to represent each final output of
decision. Absolutely, these different shapes are connected by arrows which
represent the possible available choices and point to the result of each
choice.
After the flow diagram was finished, we should
use Python 3 to program the whole game. We are programming a complex logical
game, so the if statement is the most
important statement to help us get an anticipated result. But the problem is
that sometimes players may input some unexpected information which could lead
to the wrong result, so we need to use Boolean logic operators such as and, or
and not to maximize the inclusion of if statement by correctly identifying
the choice of players automatically.
And what’s more, the
simple if statement is completely not
useful for the complex game, so we need to use nested if statements to check three or more available choose given by
players. The key point here is that we must pay attention to the format of each
line of nested if statements inside that
each line of sub-statements should be indented four spaces from the beginning
of if or elif command words. In addition, do not forget to add colon in the
first line of each nested if statements
otherwise the wrong mention sentence would display on the screen if we debug
the program.
Actually, what I
feel excited in this chapter 5 is that I can make my own functions to organize
code and avoid repeating codes by using def
command. I can decide if my own function could output a return value or not and
customize the details inside to achieve some particular purpose. I just define
some particular functions and utilize them for practice when I explore the
right cave in Cave Adventure. As you know, I spent a little more time on
programming the right cave to practice my own functions. Fortunately, the
entire program I have coded works very well. An excellent class!
Good job!
ReplyDelete