首页 > > 详细

辅导hw4留学生、讲解Python程序设计、辅导Conway's Game、Python编程讲解 辅导R语言程序|辅导Python程序

Due date: InstructionsBefore writing any code, read Gardner's article on Conway's Game of Life and this entire document.Work with your assigned partner or partners (and only with them).Unless otherwise indicated, use only the Python operations and commands we have been using thus far inclass and lab.You will need to download and unzip the starter archive. (See the section on the starter archive.)Write all your code in the supplied hw4.py and keep it named that way. In that file, replace with your names. Work in areas indicated by the comments marked with ... and onceyou have completed work on that area, remove those ... comments.Include a concise, proofread and edited comment at the top of your file that indicates how much of theassignment you were able to complete and any known bugs or limitations of your code.Submit by replying to the email officially announcing the assignment and attach only your hw4.py file.Submit only once per partnership, but CC your partners when submitting.You are encouraged to experiment with the runnable solution module (hw4x.py) which is included in thestarter archive. (See the section on making use of the runnable solution.)DetailsConway's Game of LifeYour goal for this assignment is to implement Conway's Game of Life. You are encouraged to familiarize yourselfwith the game and its history. In particular, you should read "The fantastic combinations of John Conway's newsolitaire game 'life'" by Martin Gardner from the October 1970 issue of Scientific American. (The final set ofdiagrams is not included in this version of the article, but that should not prevent you from understanding how the"game" works.) You are strongly encouraged to experiment with an existing implementation of the game such asthis JavaScript version runnable in your Web browser or Golly (a very powerful downloadable version of thegame).grids v. boards2/9For purposes of this assignment, we need to distinguish between two related ideas: A grid is a list of lists of thesame kinds of items (so a list of lists of Booleans, or of numbers, or really anything) where each interior list (row)is the same length (has the number of columns). If we refer to the dimensions of a grid as being "m by n" we meanit consists of n lists each of which consist of m values (i.e., the grid is m columns by n rows).On the other hand, for this project, we define a board as a grid of numbers where the numbers are all either 1 or 0and where the borders (the top and bottom rows and the leftmost and rightmost columns) are all 0. Because theborder is not designed to change, we describe the dimensions of the board as ignoring the borders. So if theunderlying grid is 7x5 (inclusive of the borders) then that is describing a 5x3 board. The overall grid might be:00000000101110011001000101000000000but conceptually the inside of the board is just this 10111 11001 01010and the user would think there are active cells at these (column, row) coordinates:(0, 0), (2, 0), (3, 0), (4, 0)(0, 1), (1, 1), (4, 1)(1, 2), (3, 2)The choice to use 1 and 0 instead of True and False and use the extra border of 0 values is motivated by thesimplicity it offers for counting how many active neighbors a cell has (see the count_neighbors function describedbelow).columns v. rowsIt is important to remember that when specifying the total number of columns and rows in a board, each is just aninteger, but the order matters. Likewise, when specifying the coordinate - the specific column and row of a cell inthe board - both are integers and order matters. (3, 4) is not the same as (4, 3).When using the paint method, the coordinates are specified as an ordered pair (a tuple of length two) where thefirst item in the pair is the horizontal (x) coordinate (the column number) and the second item is the vertical (y)coordinate (the row number).However, the standard convention for representing a two-dimensional array is as a list of lists and thinking of thatas a list of rows. This means we specify the row number first when accessing the elements directly in an array. Soif we have a grid g, and wanted to refer to what is at position (3, 4) - i.e., column 3 (counting from 0) and row 4(counting from 0), we would write:3/9 g[4][3]This can lead to hard to find bugs where a value intended to specify a column number is instead used as a rowindex and vice versa. To combat that problem: 1) be aware of the potential problem? 2) test as you go? and 3) usenon-square grids (usually we use more columns than rows because most computer screens are wider than they aretall) so that you either receive an index error (for instance if accidentally referring to an out-of-bounds row numberwhen you intended it to be a column number), or the visual display of the grid seems rotated by 90 degrees.ordered pairsOrdered pairs in Python are tuples (immutable lists) of length two. In this assignment, the only ordered pairs weuse will consist of two integers.When passing dimensions into a function (how wide, how high), the arguments will be separate integers. Forexample, to create an empty grid, gol_repl calls:gol_aux.make_empty_grid(columns + 2, rows + 2)When referring to a coordinate pair, we use a tuple. For example, to fill the cell at column 7, row 4 with the colorblue, we would write:gol_graphics.paint((7, 4), 'blue')Occasionally, it will be convenient to use⁵⁳⁴⡨Ⅹ⥭⁥†⁴⁳⁨⁴⁳⁥⁥⹲⁤䘠Ⱐ⁣††⁥⁴⁥⁥㩮⠩Ⱐ⁥⥣㩯⁵㐠⹯⡥ⱥ⥯
⁰†⁓⁤⁴⁴†⁩⹭⁴⁥⁩⁥⁩㑡⁲⁩⁲⁥†⁥㩮⁥㐩†⁴⁷†の⹤⁥⁴⁤⸠⁧⁩⁐†⁨†㑩⁳†⁦††⹯⁤
⁨
⁥㑡⹮⹵⁰
⁨⁲⁨⁤Ⱨ⁲⁨⁳Ⱶ⁰⁨⹣⹳ㅣ⹲⁥䍥⁵⡥ⱥ⁲⥴⁥†⁡⁵⁴⁵⁴⁨⹵⁲⁡⁣⁥⁤⁹⁥⁴⁦††⁦⁨㩣㹡㹮㸠⁩⁴㹨㹥㸠⁢⁡㵲⁤⹬⡲㥤ⱥ⁡㕣⥴㹩㹶㹡⁴⡬⹥⡣⥩⥮㹮㸠㹨⡨ⱴ‬ㄠ⥢㹵㹴㸠⁩⡡⹯⡩⥩⥥⩳⨠⩪⩵⩳⩴⨠⩮⩯⩷⨮⨠⩉⩮⩳⩴⩥⩡⩤⨬⨠⩡⨠⩴⩥⩸⩴⨭⩢⩡⩳⩥⩤⨠⩒⩅⩐⩌⨠⩡⩬⩬⩯⩷⩳㈠⹵⁳䌠†⡬ⱴ⤠⁴⁇⁌⁢⁤⁣⁵†⁢⁲†⸠䭓⁥⁲⁣Ɐ⁷⁰⁳⁳⁡⁷†⡭⹩⸠ⱓ⁰⁅†⁡⁵†⥩⹳⁹⁤⁩⁡⁳⁡⁥⁥⠠‮⁡⤠㩩㹦㸠㹹⡩ⱥ⁤ㄠ⥳㹣㹲㹥⁥⡬Ⱬ⁥〠⥯㹮㸠㹡†⡬⹬⠬⥹⥯㝥⼠㥴⨠⩢⩲⩩⩮⩧⨠⩥⨠⩯⩲⨠⩯⩲⩨⩥⨠⩯⩴⩨⩥㍮⹤䍷⁧⡤⤠⁴††⁅⁩⁩⁲⁣⁩⁥⁵⁧⁰⹧⁲†❮⁴≡≮†⁴⁥⁩⸠⁵⁴⹦†䍴†‬⁲⁣⁷†⁥†⁦⁩䕳䱡⁡†⁥⁥†⁴❮⁴⁲⡡䉰䝨䍣䰠⥮Ɽ‹⁲⁧⁳⡷䄠䍩䤠䕲䍮䰠⤠⁩⁥⡮䥤䅮䍧䥯䔠䍯䱲⥯⹭⁰䙵ⱥ⁲⁡⁥⁵⁵⁩†⁲
⁨⁲⁩†††⁴‬⁡†䕥䱦⹲㑯⹭†䍷⁰⡤Ɱ⁤ⱶ⁩㵥⥌⁩†⁥⁳⁳⁇⁥ⴠ⁅⁧⁲†⁥∠≥⁴†⁤⁥⁸≴≬⁥⁴⸠⁲⁥⁴⁢⁵⁩‮⹲⁥䠠ⱦ⁦⁴†⁳⁵⁢†⁳†⁳⹸⁡††⵩⁤†⁢⁤⹏⁡⁩†㼠
†⡯⁩‬⁲⁴⁡†⥰ⱬ⁡⁤†⁨†⁳⸠⁩⁅⁥⁲†⁳⁨≩≴†⁩⁴⹶⁥䤠⁰⁡Ⱝ⁴⡨ⱳ†⡴㕥ⱸ⁴㜠⥦⥩†⁡㡴㙲⁷†ㅡ⸠⁧⁥⁡†⁥⁡⁡††⁴†䕮䱥⹮㕴⹩⁲䍥‮⡮ⱡ⁴⥮†⁨⁴⁲⁴⁳⵩†⁩⹥†⁥‮†⁲⁲⡤⹲Ɑ⁡⁡⁥Ⱪ⁴⁩⁥⁥†⁡⁧⁵⁦⁴ⱴ⁨ⱴ⁲⁴ⱴ⁩⁥⁡⁦⥮⹳⁩䅳Ⱐ⁨⁰⁦⁲≥≴⁡⁡⹥⁔⁥⁣⁥††⁡ㅴ✠⁥⁳づ❮ⱳ†䉬⁷⹣⁨⁴†⁩†⁡䕤䱴⹥㙸⹴⁦䍩⁥⡲Ⱞ⁰⥯††⁩⁤ⴠ⁧⁲⁨‮⁳†⁴ㅮ‧⁩⁥†⁲⡧⁲⁡⁳›〠⁦⁴ㅩはの⁳ⴠ⁦⁴⁦⁰⁩⁡⁲⁹⥒⹅⁐⡯ⱳ†ぇ⥡‮›⁥㽴⡨Ⱞ⁔ㅨづ〠⥴⁥†⁧⁤‮†⹵⡰ⱴ⁡㕴ど⥯⁡⁤⁩⁲⁴⁴⁣⁲⹩†⁤⁴††䕦䱣⹥㝬⹬⁳䌠⠠ⱴ⁩ⱬ⁩㵩⤮⁧⁤†⁡⁴†⁤⁥⁩⁢†⵲⁥
⹥䍴⁨⠠Ⱪ⥵
‮†⁳⵵⁨⁴†⁩⁦⵵⁴⁴⁩⸠⁹⡯䡵㩯⁲⁦†⁰†††‶⁹⁳㼠⁴⁳†⁥⸠⥴⁨⁦⁲⁲⁥⁩⁩⁴⁡⁵⁥‮⁥䕷䱩⁴⁩⁥⁣⁥⁤⁦††⁩‮⁧⵲⁤†⁰⹭⁳䘠Ᵽ†⁨†⁲⁹⹥⹥†⡴⁤⥥⁦⁴⁹⁢⁤⁩†⁡⹮⁴⡨㩡⁰䥨⁩⁩⁴⁴⁥⁵†⁥⁴⁴⁥⁡⁍⁤⁴⁳†⁦⸠⥧㡥⹮⁥䍲⁨⡦⥩⁴⁡⁢†⁲⁴⵴†⁣⁴⁥⁷⁥†⹩⁐⁥⁨††⁵⁡⡬⁥⁨††⁣⁳⥩㽬⁥ⱶ㩥⁡㕨㝬ㅧ›⁩⁥⁡†⁰⁩†⁥⁲⡳㐺Ⱐ⁴㙨⥡⹴†⁦⁲⁴⁶⁥⁤䔠䱲⁥⁳⹯㡮⼠㤨⁣⁩⁵†䍉❴⁰䝳†䱵❩⁤⁴⁢⸠⁡Ⱨ⁨⵨⁹⁥⁴㨠⁦⁴⁣⁲   ㈀  ㌀     㼀    ⸀ 䤀         ㌀    ⸀㤀⸀ 䌀 ⠀Ⰰ ⤀           ∀∀    ⸀ 䘀 Ⰰ    㨀               ㄀    ㄀ ㄀        ㄀      ㄀   ㄀           㸀㸀㸀 ⠀Ⰰ ⠀ Ⰰ  ⤀⤀㈀㸀㸀㸀 ⠀Ⰰ ⠀㈀Ⰰ ㄀⤀⤀㌀ ⠀Ⰰ ⠀㌀Ⰰ 㔀⤀⤀     ⸀ ⠀    Ⰰ  ⸀⤀㄀ ⸀ 䌀 ⠀⤀        㨀              ⠀   ∀∀⤀Ⰰ        ⴀ     ⠀    ∀∀⤀⸀ 䘀   Ⰰ    㨀㸀㸀㸀 ⠀⤀⠀⠀㄀Ⰰ  ⤀Ⰰ ⠀㈀Ⰰ ㄀⤀Ⰰ ⠀㈀Ⰰ ㈀⤀Ⰰ ⠀㄀Ⰰ ㌀⤀Ⰰ ⠀㈀Ⰰ  ⤀Ⰰ ⠀㄀Ⰰ ㈀⤀Ⰰ ⠀ Ⰰ ㌀⤀Ⰰ ⠀㈀Ⰰ ㌀⤀⤀⠀䤀                    ⴀ             ⴀ        ⸀⤀㄀㄀⸀ 䌀 ⠀⤀     䌀✀ 䜀  䰀   ⸀ ⠀䠀㨀 Ⰰ Ⰰ  ⸀⤀         䔀䰀⸀㄀㈀⸀ 䌀 ⠀Ⰰ ⤀        ⸀ ⠀           ⸀ 䠀Ⰰ             ⸀⤀        䔀䰀⸀㄀㌀⸀ 䌀 ⠀Ⰰ Ⰰ ⤀      ⠀           ⤀              ⸀      㨀      ⠀    Ⰰ      ⤀㼀 㤀⼀㤀     ⴀ              ⸀ 䘀 Ⰰ  ⸀⸀  ⸀⸀   ⸀           㼀   ⠀ ⤀       㼀               㼀         Ⰰ          ⸀        ⠀   ⤀㼀          Ⰰ      ⸀                  䔀䰀⸀㄀㐀⸀ 䌀 ⠀Ⰰ Ⰰ ⤀                           
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!