Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > vim中的五子棋游戏gomoku.vim
【标  题】:vim中的五子棋游戏gomoku.vim
【关键字】:vim,gomoku.vim
【来  源】:http://blog.chinaunix.net/article.php?articleId=36565&blogId=8484

vim中的五子棋游戏gomoku.vim

Your Ad Here

我玩游戏的水平很差,至今还停留在五子棋的阶段。以前不喜欢emacs,所以想把emacs的gomoku.el移植到vim中。后来逐渐习惯emacs了,这个程序也就只完成一半就停下了。等有时间在继续吧。或者谁有兴趣继续,请别忘记告诉我啊。

我玩游戏的水平很差,至今还停留在五子棋的阶段。以前不喜欢emacs,所以想把emacs的gomoku.el移植到vim中。后来逐渐习惯emacs了,这个程序也就只完成一半就停下了。等有时间在继续吧。或者谁有兴趣继续,请别忘记告诉我啊。

" Gomoku Game in VIM vi improved
" v0.1 2005-03-13 Jerry Fleming<jerryfleming@etaang.com>
" gomoku.el by: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
" adapted by: ESR, Daniel Pfeiffer <occitan@esperanto.org>

" COMMENT
" This game adopts the idea and algorithm of gomoku.el, which may be found
" in standard GNU Emacs, Editor of Macros distribution. No restriction is made on the squares one
" may move to disable _force win_ in the TRUE Gomoku, because I have no idea
" how one can force win at all. If you guys do, please let me know.

" some vars that you may change to fix your screen
let s:width = 128         " columns of text your screen can display
let s:height = 48         " rows of text your screen can display
let s:player = "X"        " the piece-shape for a play
let s:robot = "0"         " the piece-shape for the robot
let s:grid = "."          " the mark of a square position
let s:gridwidth = 3       " the width of the grid, which should be less than 5;
                          " otherwise you can only see a very small set of grids

" PLAYING
" use h,l,j,k keys to move around as you would normally do in vimming, and press
" space bar where you see you are likely to win


"""
""" IMPORTANT: you should not edit below whithout aware what you are doing
"""

" since we deliberately makes the board four times of the screen, we should turn
" wrap off to see only a _windowed_ central part of the board
set wrap!
" we'd better set whichwrap so as to move freely with h,l,j,k
set ww=h,l,b,s
" the cmdheight might be changed, so we set it back
set ch=1

" initialize the board
let s:count= 0
while s:count < s:gridwidth - 1
  let s:grid = s:grid . " "
  let s:count = s:count + 1
endwhile

let @" = s:grid
let s:count = 0
while s:count < s:width / s:gridwidth
  normal p
  let s:count = s:count + 1
endwhile

let s:count=0
normal yy
while s:count < s:height - 1
  normal p
  let s:count = s:count + 1
endwhile

normal gg
let s:count=0
while s:count < s:height - 1
  let s:i = s:gridwidth - 2
  while s:i > 0
    normal jd$
    let s:i = s:i -1
  endwhile
  normal j
  let s:count = s:count + 1
endwhile

normal gg0

" keymap to move s:gridwidth at a time and make your turn
let @x = s:player
noremap <Space> x"xPh
noremap l e
noremap h ge
" Gary Johnson <garyjohn@spk.agilent.com> contributed the following maps
noremap j :let q=col(".")<CR>$:call search('\S','W')<CR>:exec "normal" q."\|"<CR>:echo ""<CR>
noremap k :let q=col(".")<CR>0:call search('\S','bW')<CR>:exec "normal" q."\|"<CR>:echo ""<CR>
" save game session
noremap s :w! .vimgomoku<CR>
" abort game
noremap q :q!<CR>
" save and exit
noremap x :wq! .vimgomoku<CR>
" read saved session
noremap r ggdG:r .vimgomoku<CR>
" new game
noremap n ggdG:source gomoku.vim<CR>

自己写的一个UBB转换的函数:【上一篇】
<Expert C Programming>读书笔记(1):【下一篇】
【相关文章】
  • Vim 的repeat功能
  • VIM中二进制文件编辑
  • vim 使用经验
  • vim quick ref card
  • vim中编写代码的缩进
  • gd and gD in vim
  • gvim学习
  • vim中获得帮助的方法
  • VIM 用户手册
  • gvim 使用技巧
  • 【随机文章】
  • Sun E450 安装 Solaris 10 SPARC 工作日志
  • SQL中char和varchar的效率分析
  • 关于数据文件头的检查点SCN.
  • several hash functions
  • Oracle 8 的函数介绍
  • 虚拟社会,做尽天下业务(集思广义,以求大同)
  • 用Word两步制作作文稿纸
  • [Perl]用Jabber做系统监控和报警(可使用Google Talk)
  • 如何设计出具有GUI特色的“纯”JAVA程序
  • Struts Validation 需要注意的一些细节
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.