You have to make a golf game with the following specification :-
The field is 10 X 10 characters without spaces.
Free ground is represented by
.
A hole generated at random(not at
0,0
) is shown byO
(its alphabet and not zero).The ball starts at
0,0
represented byX
.You can hit the ball with input
d 4
(meaning direction to the bottom with magnitude of 4 characters after the ball more like vectors in physics).Example:
X......... .......... .......... .......... .......... .......... .......... .......... .......... .........O score : 0 b 4
But, since you are not so good at golfing therefore the force you think is applied is often only close to the actual force that is applied !(if
x
the offset in force then -2 < X < +2)you should have to tell the real force applied and display the ball moved to that real force like this :-
lets say the ball actually moved by 3. .......... .......... .......... X......... .......... .......... .......... .......... .......... .........O score : 1 applied force : 4 real force : 3
The four directions are
U (up), D (down), l (left), r (right)
and magnitude of force should be between 0 and 10 (excluding both 0 and 10).The ball should not bounce off the edges, if the force reaches that much then the the ball stops at the last point at the boundary.
r 9 .......... .......... .......... .........X .......... .......... .......... .......... .......... .........O score : 2 applied force : 9 real force : 11
In the end when the game is finished you have to display
Par in <n> shots!
(where n is score)
Coding:
- You have to design a working program showing the exact output.
- post the code in
golfed
andungolfed
versions. - also post a successful test run (images if possible).
- No use of functions or languages excessively specialized to this task (I don't know if they really exist!)
Winner:
Winner will be chosen 1 week from now. Winner is the submission with least characters.
And, most important thing
Best of luck :)
D 1
) and not move it at all (X=-1
). Most of the spec is intelligible, but you haven't said what to do if a) the intended stroke would place the ball out of bounds; b) the intended stroke wouldn't, but withX
taken into account it would. \$\endgroup\$