加载中…
个人资料
nuhuo1234
nuhuo1234
  • 博客等级:
  • 博客积分:0
  • 博客访问:16,257
  • 关注人气:9
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

zillions of game 语言1(全转开不了车文章,车兄有才

(2009-04-07 10:41:32)
标签:

杂谈

Zillions语言教程(一)
2008-07-11 20:37

第一章 走进Zillions的编程世界
Zillions of Games是一个棋类软件。通过它不仅可以玩棋类游戏,还可以设计棋类游戏。玩棋只要知道规则就能玩,这就不用讲了。而设计棋类游戏的话,就要了解Zillions的语言了。
下面将以一个简单的例子游戏,来说明Zillions的语言。
打开记事本,将这些文字输入到其中:
(game
(title "Tic-Tac-Toe")
(description "One side takes X's and the other side takes O's.
   Players alternate placing their marks on open spots.
   The object is to get three of your marks in a row horizontally,
   vertically, or diagonally. If neither side accomplishes this,  
   it's a cat's game (a draw).")
(history "Tic-Tac-Toe was an old adaptation of Three Men's Morris    to
   situations where there were no available pieces. You can draw or
   carve marks and they are never moved. It is played all over the
   world under various names, such as 'Noughts and Crosses' in
   England.")
(strategy "With perfect play, Tic-Tac-Toe is a draw. Against less
   than perfect opponents it's an advantage to go first, as having an
   extra mark on the board never hurts your position. The center is
   the key square as 4 possible wins go through it. The corners are
   next best as 3 wins go through each of them. The remaining
   squares are least valuable, as only 2 wins go through them.
   Try to get in positions where you can `trap` your opponent by
   threatening two 3-in-a-rows simultaneously with a single move. To
   be a good player, you must not only know how to draw as the second
   player, you must also be able to takes advantage of bad play.")
(players X O)
(turn-order X O)
(board
    (image "images\TicTacToe\TTTbrd.bmp")
    (grid
      (start-rectangle 16 16 112 112) ; top-left position
      (dimensions ;3x3
        ("top-/middle-/bottom-" (0 112)) ; rows
        ("left/middle/right" (112 0))) ; columns
      (directions (n -1 0) (e 0 1) (nw -1 -1) (ne -1 1))
    )
)
(piece
    (name man)
    (help "Man: drops on any empty square")
    (image X "images\TicTacToe\TTTX.bmp"
     O "images\TicTacToe\TTTO.bmp")
    (drops ((verify empty?) add))
)
(board-setup
    (X (man off 5))
    (O (man off 5))
)

(draw-condition (X O) stalemated)
(win-condition (X O)
    (or (relative-config man n man n man)
        (relative-config man e man e man)
        (relative-config man ne man ne man)
        (relative-config man nw man nw man)
    )
)
)
将文件保存为.zrf文件,这是ZoG的棋类规则文件。双击该文件,或者从Zillons的File菜单栏里选择Open Rules From File来打开该文件。这个是一个Tic-Tac-Toe游戏,即“井字棋”。双方轮流往3x3的格子里放棋子,谁将自己的三个棋子连成一条线,谁就胜利。
从上面的脚本内容可以看出来,其形式有些像VB或VC的语言。如果学过这些语言的话,就比较容易掌握ZoG语言了。
今天就说到这里,下一课将会讲到游戏主体。


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有