Teaching Blog of Mr.Zhang
Tuesday, November 29, 2016
Programming Club: Fill-in the missing code
Instructions:
a) Download the projects here from my google drive.
b) Choose a game you would like to work on.
c) Run the complete solution in cmd without looking at the code.
d) Choose a version of the problem you would like to do:
Option 1 "Easy":
- Certain parts of the code are cut out with instructions provided. Your task is to fill out those missing pieces of code. The challenge is not too difficult.
Option 2 "Hard":
- Certain parts of the code are cut out with instructions provided. Your task is to fill out those missing pieces of code. The challenge is quite difficult.
Option 3 "Bug":
- There are 2 or 3 bugs in the code. Your task is to locate and fix these bugs.
Option 4: Start from scratch
Implement the game your own way that does the same thing as the sample program.
It's ok if the display or wording is slightly different
e) After you have decided which version to tackle, open up the .py file in that folder and read the existing code first. Figure out what the existing code does before you start editing. Reading other people's code is an important skill. (Therefore writing code that is easy for other's to read is equally important)
f) After you have completed the tasks. You may choose to tackle a different option, or work on extensions, or go back to step b).
List of available game project
1. Nim Single Heap
Description:
In this game, there is a stack of 100 objects. Two players take turns removing 1 - 10 objects from the stack. Whoever cannot remove any more objects (i.e. no objects left) loses the game.
Difficulty:
★
Length:
~100 lines
Extension Ideas:
a) Implement a "restart" option at the end of the game.
b) Implement an AI that makes random choices.
c) Change the available choices of objects to remove. E.g. instead of 1-10, do odd numbers between 1 - 10. (Does that change the strategy?)
d) Implement the game with two heaps.
- Start with two stacks of 100 objects
- Each player must choose a stack, then remove 1-10 objects from that stack
e) Make it so that names of players can be customized.
f) Improve the user interface.
2. Kopek Game
Description:
This is a turn-based game with the following rules:
- The game starts off with a collection of 25 coins, worth 1 - 25 kopeks respectively (so, not just the coins in the picture above).
- Each move, the player with more kopeks chooses a coin, and the other player decides who may take the coin.
- In the case that both players have the same amount of kopeks, the player who chose the coin in the last turn chooses again.
- After all the coins have been taken, the player with more kopeks wins.
- Player 1 will start off the game by choosing the coin, with Player 2 choosing who gets it.
Difficulty:
★★
Length:
~125 lines
Extension Ideas:
a) Implement a "restart" option at the end of the game.
b) Implement an AI that makes random choices.
c) Improve the user interface.
3. Connect Four
Description:
"Connect Four is a two-player connection game in which the players first choose a color and then take turns dropping colored discs from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the next available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs." -- Connect Four Wikipedia
Difficulty:
★★
Length:
~125 lines
Extension Ideas:
a) Change the dimensions of the board.
b) Implement a "restart" option at the end of the game.
c) Implement an AI that makes random choices.
d) Make it so that the program can identify a winning state (i.e. detects 4 in a row) and stops the game.
e) Implement an option that changes the direction of gravity (changing direction of gravity will cost a turn)
f) Make it so that names of players can be customized.
g) Improve the user interface.
4. Sliding Blocks Game (15 puzzle)
Description:
The 15-puzzle is a sliding puzzle that consists of a frame of numbered square tiles in random order with one tile missing. The object of the puzzle is to place the tiles in order (see diagram) by making sliding moves that use the empty space.
Difficulty:
★★★
Length:
~150 lines
Extensions:
a) Change the dimensions of the board.
b) Implement a "restart" option at the end of the game.
c) Implement a counter that tracks the number of moves.
d) Improve the user interface.
Wednesday, November 23, 2016
Thanks!
Thank you wonderful students at Killarney!
I had an amazing time with you during the past 2 months.
Take care, have fun, do math, enjoy math, love math, become obsessed with math, and eat well!
I had an amazing time with you during the past 2 months.
Take care, have fun, do math, enjoy math, love math, become obsessed with math, and eat well!
Saturday, October 29, 2016
Two Challenging Math Game Problems
(People say the wording is confusing. Fine.)
Problem 1
Problem 1
Alphonse and Beryl have decided to put on a mathemagical show one evening!
The audience shuffles a deck of 36 cards, containing 9 cards in each of the suits spades, hearts, diamonds and clubs. Alphonse predicts the suit of the cards, one at a time, starting with the uppermost one in the face-down deck. The design on the back of each card is an arrow. Beryl examines the deck without changing the order of the cards, and points the arrow on the back of each card either towards or away from Alphonse, according to some system agreed upon in advance. Is there such a system which enables Alphonse to guarantee the correct prediction of the suit of at least 19 cards?
Problem 2
Alphonse and Beryl have planned an exotic vacation in the Pacific. To pass the time on the plane ride, they decide to play a game. Alphonse and Beryl wish to divide 25 coins of denominations 1, 2, 3, . . . , 25 kopeks. In each move, one of them chooses a coin, and the other player decides who must take this coin. Alphonse makes the initial choice of a coin, and in subsequent moves, the choice is made by the player having more kopeks at the time. In the event that there is a tie, the choice is made by the same player in the preceding move. After all the coins have been taken, the player with more kopeks wins. Which player has a winning strategy?
(Source: Tournament of Towns Contest)
(Source: Tournament of Towns Contest)
Monday, October 3, 2016
Subscribe to:
Posts (Atom)