in py previous question my input must be a file with 5 # first line is size of board up to 26 Na2, Ne2, Ne4, Kc5 # K for king, N for Knight and a,e c, are columns Na1, Kb3, Nb4
Added by Juana T.
Step 1
The file contains the size of the board and the positions of the pieces (King and Knight) on the board. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 86 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Java please Our program should accept input in one of two ways: If a command-line argument is provided, it should read input from the file given as that argument. If no command-line arguments are provided, the program should read input directly from the terminal. Each input will be given on its own line, and will follow this format exactly: The first input will be the number of rows, mm, for the grid of squares on the board. It will be an integer value between 1 and 256 (1≤m≤256 1≤m≤256). The second input will be the number of columns, nn, for the grid of squares on the board. It will be an integer value between 1 and 256 (1≤n≤2561≤n≤256). Each following input will consist of two lines, xx and yy, giving the coordinates in the grid where that player places her or his symbol. It is guaranteed that xx and yy will reference a valid space on the board (0≤x<m0≤x<m and 0≤y<n0≤y<n). You do not need to check that these inputs are valid. Here are the rules for a more generalized form of Tic-Tac-Toe, which uses a board of varying size: The first player picks a number of rows for the grid of squares on the board. The second player picks a number of columns for the grid of squares on the board. The first player places a symbol, typically an X, in an empty square. The second player places a symbol, typically an O, in an empty square. The players alternate turns until one player is able to fill an entire row or column with her or his symbol. That player is the winner. If the number of rows and columns are equal, players may also win by filling an entire diagonal with the same symbol. If all squares are filled and no player wins, it is considered a draw. To complete this project, you’ll create a program that allows two players to play this game. Sample Input and Output Input 1 3 3 0 0 0 1 1 1 0 2 2 2 Output 1 Winning move at 2 2 Input 2
Akash M.
In chess-mates, the knight has an unusual movement. It moves to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. The knight moves alternately to light and dark squares. For example, on small chess board 3 by 3, a knight on a3 may jump to c2, or on b1. Suppose that the knight stays on a3. In how many different ways can it move from a3 to c1 in 10 steps? Hint: number 9 cells of the board with 1 to 9 and write the matrix 9 Ă— 9 such that aij = { 1, if the knight can jump from cell i to cell j; 0, if the knight can not jump from cell i to cell j Than think about different exponents of A. You may use MAPLE and return printed workbook along with your solution.
Sri K.
In an earlier assignment, you drew a 4x4 checkerboard of black-and-white squares. Back then, the code to do this was rather tedious; you needed to manually write a call to rect() for every square (or maybe for every 2nd square, depending on your approach) on the board. For this question, you will revisit this problem by drawing full-sized checkerboards of various sizes on the canvas. This time, your program must use loops and allow the user to change the size of the board with key presses. Figure 2: Four examples of checkerboards – a 2x2 board (smallest allowed), an 8x8 board (starting size), an 11x11 board (odd number) and a 16x16 board (largest allowed) Start with a dark gray background on a 400x400 pixel canvas. Your task is to draw an N-by-N black-and- white checkerboard in Processing, where N can be any integer between 2 and 16. Have the top-leftmost tile coloured white like in the figure. You should not allow the user to make the board smaller than 2x2 or larger than 16x16. A 16x16 grid will fill the entire canvas, as seen above. When the user presses the + key, one additional row and column should be added to the checkerboard, up to the maximum of 16 rows and columns. When the user presses the - key, one row and column should be removed from the checkerboard, down to the minimum of 2 rows and columns. Start the program with an 8x8 checkerboard. For this question, you must use loops to draw the checkerboard. Your code itself must use rect() no more than twice (and once is even better)! Use loops, ranges and extra variables as needed to keep track of (a) where to draw the current square, and (b) what color the current square should be (black or white). ● Hint: Good use of Model–View–Controller design makes this question easier. Use one model variable to store the number of rows and columns to be drawn. Your controller should update this variable in response to key presses. Your view is responsible for drawing the correct number of rows and columns based on the value of the model variable. ● Hint: When you did this question for A1, you may have set the background color to either white or black as a shortcut to avoid extra calls to rect(). That approach will not help for this problem, as you are required to use a dark gray background and rect() no more than twice. What To Hand In: Your code in a file named a7q2.pyde.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD