[Tutor] need help
S Tareq
stareq13 at yahoo.com
Sat Jan 11 15:52:07 CET 2014
how can i do this on python using py game:
Scenario 3: BotMod
BotMod is a game where a player has to guide a robot through a landscape to collect people and carry
them to a base camp before the robot’s power runs out. The landscape is represented by a 10 by 10
grid and contains a mixture of grassland, rocks and ice.
The robot always starts in the top left square of the grid. The player can move the robot one square at
a time in any of the directions shown in Figure 1.
Figure 1
The robot cannot:
make diagonal moves
move beyond any edge of the grid.
When the robot moves into a square containing a person:
if the robot has space in its passenger bay, the person is automatically picked up
if there is no space in the passenger bay, the person remains in the square and is not picked
up.
When the robot moves into the square containing the base camp all of the people in the robot’s
passenger bay are automatically unloaded.
The robot starts with 150 power units.
Before the player begins controlling their robot they should modify it by choosing the:
type of traction they want (wheels, tracks or skis)
size of the passenger bay (large, medium or small).
These modifications affect how the robot operates as it moves around the different types of terrain in
the landscape. Different choices mean that different amounts of power will be used by the robot as it
moves around the landscape. The size of the passenger bay also determines the maximum number of
people that the robot can carry at one time. Full details are given in Tables 1 and 2 on page 5.
After each move made by the robot the number of:
passengers being carried by the robot
power units the robot currently has
should be displayed to the player.
The player wins the game when all of the people are dropped off at the base camp before the robot
runs out of power.
The landscape and initial positions of the robot, people and base camp are shown in Figure 2.
Scenario 3
R P
P
B
P P
Colour of
square Type of terrain
Green Grassland
White Ice
Brown Rocks
Letter Object
R The robot
P A person
B Base camp
3
Figure 2
Key
Turn over ►
Scenario 3
4
Tasks
1) Develop a start menu for the game. This must give the user the options of modifying their robot,
playing the game or exiting the program.
2) Develop the part of the program where the player modifies their robot. The player should be
able to select their choices and return to the start menu when they have finished. They should
be able to make the following choices:
type of traction they want (wheels, tracks or skis)
size of the passenger bay (large, medium or small).
3) Develop the program so that when the player chooses to play the game from the start menu the
landscape and initial positions of the robot, people and base camp are displayed (as shown in
Figure 2).
4) Develop the part of the program to enable the player to move the robot as described in
Figure 1.
5) Develop the program so that the robot automatically picks up a person when it moves into the
square they are occupying if there is enough room in its passenger bay. It should also
automatically drop off all its passengers when it moves into the square containing the base
camp.
6) Develop the part of the program that calculates and displays the power units and number of
passengers after each move. At the start of every game the robot should have 150 power units.
Refer to Tables 1 and 2 for how these values should change after each move.
7) Develop the part of the program that checks if the player has won or lost the game.
a. The player has won if all of the people have been taken to the base camp.
b. The player has lost if the number of power units runs out.
c. If the power units run out on the last move the player has still won.
When the player finishes a game a relevant message should be displayed and they should be
returned to the start menu.
8) Extend the program by creating more levels for the game that increase the difficulty for the
player. Each time a player wins a game, they move up a level and the robot starts with fewer
power units than on the previous level.
Scenario 3
Traction type Effect when
moving onto
grassland Effect when
moving onto
rocks Effect when
moving onto
ice
Wheels Costs 1 power
unit Costs 2 power
units Costs 3 power
units
Tracks Costs 3 power
units Costs 3 power
units Costs 3 power
units
Skis Costs 3 power
units Costs 3 power
units Costs 1 power
unit
Size of passenger
bay Maximum
passengers at any
one time
Power Cost
Large passenger bay 3 Costs 2 additional power
units per move
Medium passenger
bay
2 Costs 1 additional power
unit per move
Small passenger bay 1 Costs 0 additional power
units per move
5
Table 1
Table 2
Turn over for an example of the game in action
Scenario 3
R P
P
B
P P
6
An example of the game in action
The player has made the following modifications to the robot:
Traction type: wheels
Passenger bay size: large
Number of passengers: 0
Power units: 150
Move 1 (robot moves onto grassland)
Wheels cost 1 power unit
Large passenger bay costs 2 power units
Number of passengers: 0
Power units: 150 – 1 – 2 = 147
Scenario 3
R P
P
B
P P
R
P
B
P P
7
Move 2 (robot moves onto ice to collect a person)
Wheels cost 3 power units
Large passenger bay costs 2 power units
Number of passengers: 0 + 1 = 1
Power units: 147 – 3 – 2 = 142
Move 3 (robot moves onto rocks)
Wheels cost 2 power units
Large passenger bay costs 2 power units
Number of passengers: 1
Power units: 142 – 2 – 2 = 138
R
P
B
P P
8
Move 4 (robot moves onto ice)
Wheels cost 3 power units
Large passenger bay costs 2 power units
Number of passengers: 1
Power units: 138 – 3 – 2 = 133
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140111/cebb795c/attachment-0001.html>
More information about the Tutor
mailing list