Authoring week 3

SNAKE AND LADDER

Answers

________________________________________

Decides who start the game.

 

Repeat while the game is not ended.

Roll the dice, do not roll again if you roll a six.

if currently on square 94 or above, and rolled exact number then

move the piece to square 100 to win.

Else if currently on square > 94 and rolled more than exact then

do nothing.

 

 

Else if (currently on square >= 94 and rolled less than exact) or currently on square<94 then

Move the piece.

Move the piece according to the number rolled on the dice. more then one piece can share a square.

 

if the piece is at a ladder and it is not the top of the ladder then

move up the ladder

 

Else if the piece is at a snake and it is not the tail of the snake then

move down the snake

 

End If.

End if.

End Repeat.

Advertisements

Authoring Week 02 Homework.

1. Write the algorithm for the snake and ladders game, following these game rules.

Decide who starts the game.
Roll dice. There is no extra turn for rolling a six.
Move your playing piece.
If your piece lands on the base of a ladder, move up the ladder.
If your piece lands on the top of a ladder, do not move down
 the ladder.
If your piece lands on the head of a snake, move down the snake.
If your piece lands on the tail of a snake, do nothing.
More than one piece can share a square.
The exact number needs to be rolled on the die, by remaining
 on a square of 94 or above,
 and waiting until the required number is rolled. Eg. If you are
 on square 95, you need to
roll a 5 before you can move to square 100 to complete the game.

Semi Syntax for Snake and Ladder.

Decides who start the game.

Repeat if you have not completed the game by landing exactly at box 100.

If it is your turn to roll the dice then

Roll it.
if it lands on the base of a ladder then
move up the ladder
else if you land on the head of a snake then
move down the snake
else if your piece lands on top of a ladder or on the tail of a snake then
do nothing.

End If.
End Repeat.

2. Write the query to get the following celebs appear as highlighted. Use the celeb application given

1. Pay is > $1m and Attribute 1 is attractive and Attribute 2 is talented

2. Pay is > $17m and Attribute 1 is Attractive and Attribute 2 is talented.

3. Pay is < $42m and Attribute 1 is Physically Fit or Attribute 2 is physically fit.

4. Pay is > $15m and Attribute 1 is Beautiful.

5. Pay is < $91m and Attribute 1 is Talented or Attribute 2 is distinctive voice.

Authoring Week 02 Homework: Semi-Syntax

Semi Syntax.

(IF... then.... Else.... End if)+(Repeat) version.

Repeat while is still holes

  • if the left hole is empty then

hold the right string and put it through the left hole

  • Else

hold the left string and put it through the right hole.

  • End if

Else

Tie a dead knot with the two strings.

End Repeat.


Semi Syntax II.

(IF... then.... Else.... End if)+(OR/and)  version.

  • If the left hole or the right hole is not slotted then

hold the string end at the opposite side

slot it through

  • else

tie a dead knot.

  • end if

Authoring Lesson 02:

Semi-Syntax

Today, we learnt 9 simple vocabularies:
  1. “And”
  2. “Or”
  3. “If”
  4. “Then”
  5. “Else”
  6. “Else if”
  7. “End if”
  8. “Repeat”
  9. “End repeat”

These are the semi-syntax which we learnt after algorithms.

From the online dictionary, syntax is actually,

1.

a. The study of the rules whereby words or other elements of sentence structure are combined to form grammatical sentences.

b. A publication, such as a book, that presents such rules.

c. The pattern of formation of sentences or phrases in a language.

d. Such a pattern in a particular sentence or discourse.

2. Computer Science The rules governing the formation of statements in a programming language.

3. A systematic, orderly arrangement.

  • One example of a semi-syntax is actually the ( If- then- else- end if)

If ________________________________________ then

______________STATEMENT_____________________

_____________________________________________

Else

_____________________________________________

_____________________________________________

End if.

The objective to create the semi-syntax is that,

  • Once an if statement is true, the rest will be skipped.

This enables to save time be skip the unnecessary checks.

One example of a semi-syntax will be a exercise of buying a drink from the vending machine from week 1.

  • This is the flowchart.

drink

This is the semi-syntax.

>>if the machine is working then

-if drink is sold out then

get drink from somewhere else

-else

-if change is given then

insert coins

press button to select drink

take drink

-if there is change then

take change

end if

-else

-prepare exact change

-end if

-end if

>>else

-get drink from somewhere else

>>end if

For another example, it would be the tic tac toe game.

  • This is the flow chart,

tictactoe

This is the semi-syntax,

Repeat while there is still moves

if this is winning move then

make winning move

else if is opponent next winning move then

block opponent move

else

make high prob to win move

end if

end Repeat

This is a summary of Authoring week02 lesson.

Authoring Lesson 01: Everyday Life Algorithms

Authoring Lesson 01: Everyday Life Algorithms

( tying shoelaces)

This is the video for the homework on our everyday life algorithms.

  • Repeat while there is still holes to be slot thru.

-Hold one side of the shoelace and slot in thru

the other side.

-if the right shoelace is already slotted in.

-slot the left side up.

-End if.

  • End repeat.
  • Tie a butterfly knot.