Past-paper question · 2016 May-June · Paper 41 · Q6(b)(ii)

Question 6(b)(ii) 2016 · May-June · Paper 41 · 0 marks

Original past-paper question for 6(B)(II)
Original past-paper question for 6(B)(II)
Original past-paper question for 6(B)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 6(B)(II)

Official answer for Question 6

Part (b)

(ii)

Part (b)

(ii)

✓
VB.NET
✓
Sub ValidMoves(ByVal PieceColour As Char, ByVal xCurrent As Integer,
✓
ByVal yCurrent As Integer)
✓
Dim i As Integer
✓
Dim StopperColour As Char
✓
Dim NoFurther As Boolean
✓
If PieceColour = "B" Then
✓
StopperColour = "W"
✓
Else
✓
StopperColour = "B"
✓
End If
✓
Console.WriteLine("Possible moves are : ")
✓
If xCurrent <> 1 Then
✓
Console.WriteLine("Moving LEFT . . .")
✓
i = xCurrent – 1
✓
NoFurther = False
✓
do
✓
if Board(i, yCurrent) = "E" Then
✓
Console.WriteLine(i & " " & yCurrent)
✓
End If
✓
if Board(i, yCurrent) = StopperColour Then
✓
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
✓
NoFurther = True
✓
End If
✓
i = i – 1
✓
Loop Until i = 0 Or NoFurther = True
✓
End If
✓
if xCurrent <> 8 Then
✓
Console.WriteLine("Moving RIGHT . . .")
✓
i = xCurrent + 1
✓
NoFurther = False
✓
do
✓
if Board(i, yCurrent) = "E" :
✓
Console.WriteLine(i & " " & yCurrent)
✓
End If
✓
if Board(i, yCurrent) = StopperColour Then
✓
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
✓
NoFurther = True
✓
End If
✓
i = i + 1
✓
Loop Until i = 9 Or NoFurther = True
✓
End If
✓
End Sub
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International A Level – May/June 2016
✓
9608

Question 41

✓
PASCAL
✓
procedure ValidMoves(PieceColour : char; xCurrent, yCurrent : integer);
✓
var StopperColour : char;
✓
i : integer;
✓
NoFurther : boolean;
✓
begin
✓
if (PieceColour = 'B') then
✓
StopperColour := 'W'
✓
else
✓
StopperColour := 'B';
✓
writeln('Possible moves are : ');
✓
if (xCurrent <> 1) then
✓
begin
✓
writeln('Moving LEFT . . . ');
✓
i := xCurrent – 1;
✓
NoFurther := false;
✓
repeat
✓
if (Board[i, yCurrent] = 'E') then
✓
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
✓
if (Board[i, yCurrent] = StopperColour) then
✓
begin
✓
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
✓
PIECE');
✓
NoFurther := true;
✓
end;
✓
i := i – 1;
✓
until ((i = 0) or (NoFurther = true));
✓
end;
✓
if (xCurrent <> 8) then
✓
begin
✓
writeln('Moving RIGHT . . . ');
✓
i := xCurrent + 1;
✓
NoFurther := false;
✓
repeat
✓
if (Board[i, yCurrent] = 'E') then
✓
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
✓
if (Board[i, yCurrent] = StopperColour) then
✓
begin
✓
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
✓
PIECE');
✓
NoFurther := true;
✓
end;
✓
i := i + 1;
✓
until ((i = 9) or (NoFurther = true));
✓
end;
✓
end;
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International A Level – May/June 2016
✓
9608

Question 41

✓
PYTHON
✓
def ValidMoves(PieceColour, xCurrent, yCurrent) :
✓
if PieceColour == "B" :
✓
StopperColour = "W"
✓
else :
✓
StopperColour = "B"
✓
print("Possible moves are : ")
✓
if xCurrent != 1 :
✓
print("Moving LEFT . . .")
✓
i = xCurrent – 1
✓
NoFurther = False
✓
while i > 0 and NoFurther == False :
✓
if Board[i][yCurrent] == "E" :
✓
print(str(i) + " " + str(yCurrent))
✓
if Board[i][yCurrent] == StopperColour :
✓
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
✓
NoFurther = True
✓
i = i – 1
✓
if xCurrent != 8 :
✓
print("Moving RIGHT . . .")
✓
i = xCurrent + 1
✓
NoFurther = False
✓
while i < 9 and NoFurther == False :
✓
if Board[i][yCurrent] == "E" :
✓
print(str(i) + " " + str(yCurrent))
✓
if Board[i][yCurrent] == StopperColour :
✓
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
✓
NoFurther = True
✓
i = i + 1

Mark scheme 9608_s16_ms_41.pdf →

Show text version of question

Question 6

Part (b)

(ii)

Question 6

In a board game, one player has white pieces and the other player has black pieces. Players take alternate turns to move one of their pieces. White always makes the first move. The game ends if: • a player is unable to make a move when it is their turn. In this case, there is no winner. This is called ‘stalemate’. • a player wins the game as a result of their last move and is called a ‘winner’.

Part (b)

The layout of the board at the start of the game is shown below:

x y

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

Question 15

The programmer decides to use a 2D array to represent the board. The index numbering to be used is as shown. Each square on the board is either occupied by one piece only, or is empty. The data stored in the array indicate whether or not that square is occupied, and if so, with a black piece or a white piece.

(ii)

When a piece is to be moved, a procedure will calculate and output the possible destination squares for the moving piece.

A
piece can move one or more squares, in the x or y direction, from its current position.

This will be a move: • either to an empty square, with no occupied squares on the way • or to a square containing a piece belonging to another player, with no occupied squares on the way. The other player’s piece is then removed. For example, for the circled black piece there are nine possible destination squares. Each of the two destination squares contains a white piece which would be removed. x y

Question 1

Question 2

Question 3

Question 4

Question 5

Question 6

Question 7

Question 8

The program requires a procedure ValidMoves.

Question 1

It needs three parameters:

Question 2

Question 3

• PieceColour – colour of the moving piece • xCurrent

  • current x position

Question 4

• yCurrent

  • current y position

Question 5

The procedure will calculate all possible destination squares in the x direction only.

Question 6

Topic relevance

Why this question appears here

72% assigned-topic match · Hardware › Logic gates and logic circuits

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s16_qp_41.pdf

Keep practising this topic