求 3*3 拼图算法,

justweiwei 2010-02-16 02:36:29
求算法, 9 张正方形卡片,每个卡片上有4个 一半的昆虫,一共有4种昆虫,每个昆虫有头有尾,

要求 把这9个正方型卡片,拼成3*3 的正方形,并且每个虫子都连好头和尾。

大家有何Idea?

暂时 我设计的数据结构,一个二维数组, 包括, 卡片 旋转信息, 什么样的虫子, 上半身还是下半身,,等等

大侠们请赐教!谢谢
...全文
366 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
justweiwei 2010-05-05
  • 打赏
  • 举报
回复
穷举法搞定了, 数据结构:
TBugSide = (
////////////////////////////////////////////////////////////////////////////
// Enumeration defining the heads and tails of the insects in the puzzle.
// Each insect has a different colour.
tbsBlackHead, //this the head of a black bug
tbsBlackTail, //this the tail of a black bug
tbsBlueHead, //this the head of a blue bug
tbsBlueTail, //this the tail of a blue bug
tbsGreenHead, //this the head of a green bug
tbsGreenTail, //this the tail of a green bug
tbsRedHead, //this the head of a red bug
tbsRedTail //this the tail of a red bug
);

TPieceSide = (
////////////////////////////////////////////////////////////////////////////
// Enumeration defining the the 4 sides of each piece which are north, east,
// south, west.
tpsNorth, //the North side
tpsEast, //the east side
tpsSouth, //the south side
tpsWest //the west side
);

9层 loop
liups 2010-02-22
  • 打赏
  • 举报
回复
各张卡片设编号,比如从1~9,第一行为1、2、3,第2行为4、5、6,第3行7、8、9,位置也同样编号。一开始打乱时位置给个随机数,角度也是随机的

另外把完整的大图设计好(可以多搞几张),虫子什么的在什么位置、虫子有多大要考虑好
liups 2010-02-22
  • 打赏
  • 举报
回复
个人看法:
1、卡片上的虫子什么的不用进入数据结构,而是每张卡片保存一个图形就行了。每个卡片上有4个 一半的昆虫这一点可以通过给图形初始化实现,比如原始的都是大图,初始化时分成9份分别赋值给相应位置的卡片就好
了,这些图片在显示前再根据旋转等信息来变换一下就是了。
2、旋转:如果不考虑翻转,只要记录转运0、90、180、270四个角度就是了。

什么情况算拼好了:各卡片都在原始位置且角度都为0就OK了
buding79 2010-02-22
  • 打赏
  • 举报
回复
有难度,帮你顶一下!

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧