作者enthos (影斯作业系统)
看板GameDesign
标题Re: [程式] 类似动物管理员的邻近颜色判断?..
时间Thu Sep 20 16:16:21 2012
纪念国中时的想法,做了一个 printf 版本:
https://dl.dropbox.com/u/27670170/myidea.c
https://dl.dropbox.com/u/27670170/myidea.exe
(With mingw.)
按键: Q 离开。
Q w
asd o
在 Windows 中,须要按键之後多加一个 [Enter] 才能读到。
存放真正颜色的表格:
unsigned char arrays[MAX_X][MAX_Y];
依不同颜色,存放统计数值,上下左右各扩展一格:
unsigned char carrays[MAX_COLOR][MAX_X + 2][MAX_Y + 2];
在这个题目中,只有相邻的位置有用,所以主位置是5时,
除了本身加一之外,2,4,6,8的计数也要加一。
扩展一格的原因:假设在边界或角落,不需要特别处理。
123
456
789
找出哪些位置应该清除:
unsigned char sarrays[MAX_X][MAX_Y];
为了展示,目前只有按空白键才会尝试清除。
过程中,MAX_COLOR(5)会被填入被清除的格子,
计分之後,会有新的乱数颜色产生。
没有做掉落功能,也不能让格子保持被清除状态(程式码不支援)。
x,y,color都是从零开始。
C:\dropbox\Dropbox\Public>myidea.exe
w UP, s DOWN, a LEFT, d RIGHT, [space] CLEAR , Q QUIT, o SHOW_DEBUGS
Main blocks:
14011
23004
43122
02223
[44112]
Scores is 200
Main blocks:
14511
23554
43155
05553
[44112]
Main blocks:
14111
23104
43121
02313
[44112]
w
Main blocks:
14111
23104
43121
[02313]
44112
a
Main blocks:
14111
23104
43121
[23130]
44112
Scores is 490
Main blocks:
14555
25504
45521
[25530]
44552
Main blocks:
14213
23404
44021
[22430]
44322
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 106.187.100.117
1F:推 lf21201:看懂推0.0 09/21 01:02