标题 | 阅读 | 评论 | 转发 | 发布日期 | |
---|---|---|---|---|---|
博客已升级,请注意变更地址 | 1819 | 0 | 0 | 2011-07-31 | |
流年不利 | 2253 | 1 | 0 | 2010-02-14 | |
舞啥狮子啊 | 2319 | 0 | 0 | 2010-02-14 | |
随便写写 | 2227 | 0 | 0 | 2010-02-12 | |
刚地弓形虫对胎儿的威胁 | 2271 | 2 | 0 | 2009-03-03 | |
06 级实习 | 2288 | 0 | 0 | 2008-11-25 | |
NMB RT8755C+ | 2363 | 0 | 0 | 2008-10-30 | |
[阅读标准之乐趣] 奇怪的字符 | 2281 | 0 | 0 | 2008-10-17 | |
用 GAP 计算有限域 | 2141 | 2 | 0 | 2008-10-15 | |
ChinaCrypt'2008 | 1202 | 4 | 0 | 2008-10-14 | |
1865 青 | 981 | 0 | 0 | 2008-09-23 | |
Doctor House 回归,第 5 季今天播出 | 1403 | 1 | 0 | 2008-09-16 | |
[SICP 3] Modularity, Objects, and State | 1394 | 0 | 0 | 2008-09-13 | |
Henri Cartan 去世 | 1374 | 0 | 0 | 2008-08-31 | |
得了一个 g80-2100 | 1666 | 4 | 0 | 2008-08-03 | |
得了几个好魔方 | 1330 | 0 | 0 | 2008-07-26 | |
Unicomp Customizer 101 | 1919 | 1 | 0 | 2008-07-13 | |
新大陆终端键盘 | 2848 | 6 | 0 | 2008-06-18 | |
DELL AT102W | 2600 | 3 | 0 | 2008-06-12 | |
史上最黑淘宝购物者 | 1179 | 2 | 0 | 2008-06-10 |
chinaunix网友2010-10-25 06:21
Win_hate大哥,我这里有一个非常棘手的问题,您能帮我解决以下吗? Develop the Bin-Packing game. In this game there are seven kinds of tetras (4 block pieces). A tetra falls from just above the top of the 10x20 block grid at a constant rate and as it falls the user can navigate the tetra left and right and rotate the tetra. The tetra cannot be moved off of the grid and once it lands on the base of the grid or another tetra, it is frozen in position and a new tetra, of randomly selected kind, falls from the ceiling. The game is over as soon as a tetra lands but extends beyond the top of the grid. The game is scored by counting the number of blocks that have been fit onto the grid. Your game should support at least these keyboard commands: left arrow: Shift the current piece left. right arrow: Shift the current piece right. s: Rotate the current piece 90 degrees clockwise. a: Rotate the current piece 90 degrees counterclockwise. Here are the seven kinds of tetras and their names: "O" "I" "L" "J" "T" "Z" "S" This game is unlike Tetris in that blocks never go away. The following data definitions may or may not be useful (and indicative of the kind of operations you might want to develop) for writing this program: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data Definitions ;; A Block is a (make-block Number Number Color) (define-struct block (x y color)) ;; A Tetra is a (make-tetra Posn BSet) ;; The center point is the point around which the tetra rotates ;; when it spins. (define-struct tetra (center blocks)) ;; A Set of Blocks (BSet) is one of: ;; - empty ;; - (cons Block BSet) ;; Order does not matter. Repetitions are NOT allowed. ;; A World is a (make-world Tetra BSet) ;; The BSet represents the pile of blocks at the bottom of the screen. (define-struct world (tetra pile)) Rotations are difficult, so assuming the above data definitions, this code will perform a counterclockwise rotation of a block around a given point: ;; block-rotate-ccw : Posn Block -> Block ;; Rotate the block 90 counterclockwise around the posn. (define (block-rotate-ccw c b) (make-block (+ (posn-x c) (- (posn-y c) (block-y b))) (+ (posn-y c) (- (block-x b) (posn-x c))) (block-color b))) A clockwise rotation is just the same as three counterclockwise rotations. Some advice: Note that you must choose the rotation point for each tetra carefully: if the tetra's blocks are all grid aligned before the rotation, you want them to be grid-aligned after the rotation, too. For example, if you rotate the "long" tetra (four blocks in a horizontal straight line) around its exact center-point, it will wind up between two columns of the grid. If you set the rotation point as the center of either block 2 or block 3 in the tetra, then the long tetra will rotate a bit eccentrically, but blocks will always land on grid squares. You may implement more features, if you like (e.g., scoring, increasing difficulty, game pausing). However, extra features won't save you from points taken off if your code has bugs or isn't well written. You will not receive 100% credit simply for having code that works. For full credit, your code must work and be well written. So you should put your effort into writing clean, readable, bug-free code. You will be upgrading the game to full Tetris in a future assignment. So effort expended in making sure that your code is clean and well-written will be rewarded when you have to extend it later -- it is quite difficult to modify and extend code that is a snarled-up, confused pile of chaos. As always, we advise you that the Design Recipe will help you get your code written. 这是我们老师留给我们的一项作业,我们初学Scheme,这种问题对我来说有点难。。。希望您能帮我解决一下。。