[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
在这里 那个gif里的运动是谁算出来的真牛啊 很想输入看看
!scripting!

TOP

回复 9# neorobin
cmd命令怎么删掉_106.lif结尾的文件名 del .*_106.lif不行啊 你给的链接里面好多文件 我要删掉不能用的
!scripting!

TOP

回复 9# neorobin
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /r %%a in (*.lif) do (
  4. set var=%%a
  5. set var=!var:~-8!
  6. if !var!==_106.lif del %%a
  7. )
  8. pause
复制代码
有没有比这个简便的命令写法
!scripting!

TOP

Conway's Game of Life 是生命游戏中的一类, 规则可以简单描述成 23/3 或者 B3/S23, 即邻居是2或3个时继续存 ...
neorobin 发表于 2014-9-28 10:52

大神发的这个链接好多好看的矩阵,我把代码改了下,用把.lif文件拖到importGrid.cmd上就可以看矩阵的效果了
也可以直接运行cell.py,用随机矩阵玩
cell.py
  1. import sys
  2. import os
  3. import random
  4. import time
  5. cols=100
  6. rows=80
  7. dict={' ':0,'*':1}
  8. cells=[[' ' for x in range(cols)] for y in range(rows)]
  9. grid=[[' ' for x in range(cols)] for y in range(rows)]
  10. if len(sys.argv)>1:
  11.     f=sys.argv[1]
  12.     try:
  13.         txt=open(f,'r')
  14.     except:
  15.         print('file not found')
  16.         os.system('pause >nul')
  17.         exit()
  18.     y=1
  19.     for line in txt.readlines():
  20.         if y==rows-1:
  21.             print('err:too much lines')
  22.             break
  23.         if line[0]=='#':continue
  24.         for x in range(cols-2):
  25.             try:
  26.                 if line[x]=='*':cells[y][x+1]='*'
  27.             except:
  28.                 y+=1
  29.                 break
  30. else:
  31.     print('cmdline:cell.py *.lif')
  32.     while True:
  33.         level=input('larger number,less cells ( >0 ):')
  34.         try:
  35.             if int(level)>0:
  36.                 for y in range(1,rows-1):
  37.                     for x in range(1,cols-1):
  38.                         r=random.randint(0,int(level))
  39.                         if r==0:cells[y][x]='*'
  40.                 break
  41.         except:pass
  42. for y in cells:print(' '.join(y))
  43. print("press key to begin...")
  44. os.system('pause >nul')
  45. i=0
  46. while True:
  47.     for y in range(1,rows-1):
  48.         for x in range(1,cols-1):
  49.             num=dict[cells[y-1][x-1]]+\
  50.                 dict[cells[y-1][x+1]]+\
  51. dict[cells[y-1][x]]+\
  52. dict[cells[y+1][x-1]]+\
  53. dict[cells[y+1][x+1]]+\
  54. dict[cells[y+1][x]]+\
  55. dict[cells[y][x-1]]+\
  56. dict[cells[y][x+1]]
  57.             if num==3:grid[y][x]='*'
  58.             elif num==2:grid[y][x]=cells[y][x]
  59.             else:grid[y][x]=' '
  60.     for y in range(1,rows-1):
  61.         for x in range(1,cols-1):
  62.             cells[y][x]=grid[y][x]
  63.     time.sleep(0.01)
  64.     os.system('cls')
  65.     i+=1
  66.     print('time: '+str(i))
  67.     num=0
  68.     for y in range(1,rows-1):
  69.         for x in range(1,cols-1):
  70.             num+=dict[cells[y][x]]
  71.     if num==0:
  72.         print('cells all dead,press key to exit...')
  73.         break
  74.     else:
  75.         for y in cells:print(' '.join(y))
  76. os.system('pause >nul')
复制代码
importGrid.cmd:
  1. @echo off & setlocal enabledelayedexpansion & color 0a & title PYTHON CELL
  2. if "%2"=="" (
  3. for %%a in (FontSize:00080005  WindowSize:005c00c8  ScreenColors:0000000f  CodePage:000003a8  ScreenBufferSize::005c00c8) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
  4. >nul reg add HKCU\Console\PYTHON_CELL /v %%b /t reg_dword /d 0x%%c /f)
  5. start "PYTHON_CELL" /max "%ComSpec%" /c "%~s0" %1 1&goto:eof
  6. ) else (
  7. >nul reg delete HKCU\Console\PYTHON_CELL /f
  8. )
  9. python %~dp0cell.py %1
复制代码
!scripting!

TOP

返回列表