Chinaunix首页 | 论坛 | 博客
  • 博客访问: 44329
  • 博文数量: 20
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 230
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-21 22:20
文章分类
文章存档

2011年(1)

2009年(19)

我的朋友
最近访客

分类:

2009-01-31 12:11:14

怎样把华容道的全部场景进行分类
 
    在上一篇文章里,经过好几个小时的苦苦搜索,终于把华容道的全部场景全部记录下来了。现在要把这些场景数据进行分类,分成“无横场景”,“一横场景”,“二横场景”,“三横场景”,“四横场景”与 “五横场景”。再在每个类中提取出“对称场景”,然后再分拆成“正像场景”与“镜像场景”。为以后求出每个场景的“最佳步数”以及“复杂指标”作一些工作。
 
    再说一下,本人是 Vb 爱好者。
 
'打开程序,然后点击窗体开始工作。

Private Sub Form_Click()
 Dim d As String, l As Long, i As Long, a As Long, b As Integer, dc As Boolean
  
 a0 = 0: a1 = 0: a2 = 0: a3 = 0: a4 = 0: a5 = 0
 Open App.Path & ("\全部场景.dat") For Random As #1 Len = 22 '打开“全部场景”文件。
  For l = 1 To 338700
   Get #1, l, d '......取出一个场景数据

   b = 0
   For i = 1 To 20 '......统计 20 个字符中有多少个 “3”
    If Mid$(d, i, 1) = "3" Then b = b + 1
   Next i

   Select Case b '......分别存入到各个文件里去
    Case Is = 0
     a0 = a0 + 1: Text1(0).Text = a0
     Open App.Path & "\无横场景.dat" For Random As #2 Len = 22
      Put #2, a0, d
     Close #2
    Case Is = 2
     a1 = a1 + 1: Text1(1).Text = a1
     Open App.Path & "\一横场景.dat" For Random As #2 Len = 22
      Put #2, a1, d
     Close #2
    Case Is = 4
     a2 = a2 + 1: Text1(2).Text = a2
     Open App.Path & "\二横场景.dat" For Random As #2 Len = 22
      Put #2, a2, d
     Close #2
    Case Is = 6
     a3 = a3 + 1: Text1(3).Text = a3
     Open App.Path & "\三横场景.dat" For Random As #2 Len = 22
      Put #2, a3, d
     Close #2
    Case Is = 8
     a4 = a4 + 1: Text1(4).Text = a4
     Open App.Path & "\四横场景.dat" For Random As #2 Len = 22
      Put #2, a4, d
     Close #2
    Case Is = 10
     a5 = a5 + 1: Text1(1).Text = a5
     Open App.Path & "\五横场景.dat" For Random As #2 Len = 22
      Put #2, a5, d
     Close #2
   End Select
  Next l
 Close #1
 Text2.Text = "End" '......当任务完成时,通知
End Sub

 
    未完待续
                                            自然牛 2009年1月31日
 
  
阅读(625) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~