Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÉîÈë GalCon£ºPython¡¢ÓÎÏ·¿ª·¢ºÍÈ˹¤ÖÇÄÜ

Alex. J. Champandard
ÀµÓºƣ¨http://laiyonghao.com£© Òë
Ô­ÎĵØÖ·£ºhttp://aigamedev.com/open/interviews/inside-galcon-python-ai/
AiGameDev.comÔÚÕâ¸öÖÜÒ»µÄ pratical insights ÊǶÔPhil Hassey²É·Ã¡£Phil ÊÇÒ»¸ö¶ÀÁ¢ÓÎÏ·¿ª·¢Õߣ¬Ò²ÊÇÓÎÏ·²úÒµÉçÇøµÄ»îÔ¾·Ö×Ó¡£ËûÔøÓ®µÃ2006Äê4Ô嵀 Ludum Dare ±ÈÈü£¨Õâ¸ö±ÈÈü¹ØעȺÌåÐÐΪ£©£¬½á¹û¾ÍÊDzúÉúÁËÃûΪ GalCon µÄ·Ç³£Á÷ÐеÄÓÎÏ·——ÉÏÊÀ¼Í 80 Äê´ú½Ð Galactic Conquest µÄÓÎÏ·µÄ¸´¿Ì°æ¡£
ÎÒ×î½ü¾­³£¸ú Phil ͨ email£¬ÎÊËûºÜ¶à¹ØÓÚ Galcon µÄÎÊÌ⣬±ÈÈçÈ˹¤ÖÇÄÜ¡¢Óà Python ¿ª·¢ÓÎÏ·µÈ¡£Äã¿ÉÒÔÔÚ·ÃÎÊËûµÄÍøÕ¾»ò GalCon µÄÍøÕ¾ÕÒµ½¹ØÓÚËûµÄÏîÄ¿µÄ¸ü¶àµÄÐÅÏ¢¡£´ËÍ⣬»¹¿ÉÒÔÏÂÔØÓÎÏ·µÄdemo ¡£
½Øͼ1£ºLudum Dare ±ÈÈüµÄ²ÎÈü×÷Æ·¡£
Alex Champandard£ºÄúºÃ£¬Phil£¬¸ÐлÄú³é³öʱ¼äÀ´»Ø´ðÕâЩÎÊÌ⣡ÄúÄÜ·ñ¼òÒªµØ½éÉÜ×Ô¼º£¬ÒÔ¼°¹ØÓÚ³ÉΪÓÎÏ·¿ª·¢Õߵı³¾°ÄØ£¿
Phil Hassey£ºÎÒ×Ô 10 ËêÒÔÀ´¾ÍÒ»Ö±ÔÚÖÆ×÷ÓÎÏ·¡£ÎÒÏë´ó¸ÅÊÇÒòΪÎÒûÓÐÆäËüÊÂÇé¿É×ö :)£¬ÎÒ×îϲ°®µÄÓïÑÔÊÇPython£¬ËùÓеÄÓÎÏ·¶¼ÊÇÓÃËü¿ª·¢µÄ¡£µ±È»ÎÒÒ²Óà C дÐÔÄÜÃô¸ÐµÄ¶«Î÷£¬Ò²»ùÓÚ PHP À´¿ª·¢ Web ÏîÄ¿¡£ÎÒµÄÓÎÏ·´ó²¿·Ö¶¼ÊÇ¿ªÔ´µÄ£¬ÎÒдÁ˲»ÉÙÊÊÓÃÓÚÓÎÏ·¿ª·¢µÄ¿ªÔ´¹¤¾ß/¿â¡£
Phil Hassey ¿ª·¢µÄÓÎÏ·£º
Imitation Pickles — Games
AC£ºGalcon ´´Òâ´ÓºÎ¶øÀ´µÄÄØ£¿ÄÜ·ñÏò²»ÖªµÀÕâ¸öÓÎÏ·µÄ¶ÁÕß¼òµ¥µØ½éÉÜÒ»ÏÂÕâ¸öÓÎÏ·£¿
PH£º2006Äê4ÔÂÓÐÒ»¸ö48СʱµÄÓÎÏ·¿ª·¢¾ºÈü³ÆΪLudum Dare¡£±ÈÈüÖ÷ÌâÊÇȺÌ壬¶øÇÒÎÒһֱϣÍûÔٶȵÞÔì“ÒøºÓÕ÷·þ”·ç¸ñµÄÓÎÏ·£¬ËùÒÔÎÒ³¢ÊÔʵÏÖ·É´¬Èº¡£ÓÎÏ·µÄÔ­ÐÍÔÚ48¸öСʱÄÚ×ö³öÀ´²¢Ó®µÃÁ˱ÈÈü¡£ºóÀ´ÎÒ½ÓÊÜÁË´ó¼ÒµÄ¹ÄÀø£¬¼ÌÐø¿ª·¢£¬È»ºó¾ÍÓÐÁË GalCon¡£
Phil Hassey µÄÏà¹Ø²ÄÁÏ£º
The Glorious History of Galcon
AC £ºÕâЩ·É´¬ÊÇÓÎÏ·µÄÖØÒª×é³É²¿·Ö£¬ÎҺܺÃÆæÄãÈçºÎʵÏÖËüÃǵġ£ÊÇ·ñ»ùÓÚ Craig Reynold µÄ²Ù¿ØÐÐΪÀíÂÛ£¿ÐèҪʵÏֺܶàÌض¨µÄËã·¨Âð£¿
PH£ºÆäʵËã·¨ºÜ¼òµ¥-¸øËùÓеķɴ¬Ö¸¶¨Ä¿µÄµØ¼´¿É¡£È»ºóÖ´ÐÐÅöײ¼ì²â£¬ÈÃËüÃÇÌÚ³öµØ·½¡£
AC £ºÄ£ÄâÕâô¶àµÄ·É´¬£¬ÄãÓöµ½ÐÔÄÜÎÊÌâÁËÂð£¿Èç¹ûÊÇÓöµ½¹ý£¬ÓÖÊÇÈçºÎ½â¾öÕâЩÎÊÌâµÄÄØ£¿
PH£ºµ±È»Óö¹ý¡£ÒÔÇ°µÄ°æ±¾Ò»ÆÁÉÏ×î¶àÄÜÓÐ 4096 ¸öÔªËØ£¬¶øÎÒÓõÄÓÖÊÇÂùÁ¦Åöײ¼ì²â¡£ËùÒÔÔÚijЩÇé¿öÏ£¬ËٶȾͱäµÃÏ൱ÂýÁË¡£µ±Ç°°æ±¾µÄ×î´óÖµÊÇ2048£¬²¢ÇÒʹÓÃÁËÍø¸ñϸ·ÖÆÁÄ»µÄÅöײ¼ì²âËã·¨¡£ÔÚ°Ñ·É´¬·Åµ½ÆÁÄ»ÉϵÄʱºò£¬ÎÒÒ²ÓÃÀ´Ð©ÐÄ˼À´³õʼ»¯ËüÃǵÄÏÔʾ£¬ÒÔ


Ïà¹ØÎĵµ£º

Python sqlite3ºÍµ¥Ôª²âÊÔ

 
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
......

Python Ï̳߳Ø


import Queue, threading, sys
from threading import Thread
import time,urllib
# working thread
class Worker(Thread):
   worker_count = 0
   def __init__( self, workQueue, resultQueue, timeout = 0, **kwds):
       Thread.__init__( self, **kwds ) ......

eat python 002

 Ä¿Ç°ÎªÖ¹£¬¾ÝÎÒËùÖª£¬ÔÚpythonÖжÔÏó³Ö¾Ã»¯ÓÐÒÔϼ¸ÖÖ·½·¨£º
1. ʹÓÃ(dbhash/bsddb, dbm, gdbm, dumbdbm µÈ£©ÒÔ¼°ËüÃǵÄ"¹ÜÀíÆ÷"( anydbm )¡£Ö»ÌṩÁË Python ×Ö
·û´®µÄÓÀ¾ÃÐÔ´¢´æ. Ìṩһ¸öÀàËÆ×ÖµäºÍÎļþµÄ¶ÔÏ󣬿ÉÒÔÍê³É×Ö·û´®µÄÓÀ¾ÃÐÔ´æ´¢¡£
2. ʹÓÃmarshalºÍpickleÀ´ÐòÁл¯python¶ÔÏ󣬲¢¾ß±¸´æ´¢µ½½éÖÊÉϵĹ ......

Python¼àÊÓ½ø³Ì


ÓÉsubprocess´´½¨Ò»¸ö½ø³Ì£¬È»ºó½øÐмàÊÓ
ÿһÃëÖӲ鿴һ´Î£¬Èç¹ûÕýÔÚÔËÐУ¬´òÓ¡pidºÍrunning£¬Èç¹ûÒÑÍ£Ö¹£¬,¼ÌÐøÖ´ÐÐÈÎÎñ²¢´òÓ¡Termined
shellºÍstdout¾ùÉèÖÃΪFalse
Ò²ÐíÕâ¶Ô×ö²¡¶¾µÄÊØ»¤½ø³ÌºÜºÃ
#!/usr/bin/env python
import subprocess , sys , time
p=subprocess.Popen(['ping','127.0.0.1','-n','10'], she ......

opencv python cool

µ±Äê×ö±ÏÒµÂÛÎĵÄʱºòopenCV¾ÍÏñÊÇÎÒµÄÈðÊ¿¾üµ¶£¬Ì«ÓиÐÇéÁË¡£Èç½ñÓÃÁËÒ»Äê¶àµÄpython£¬·¢ÏÖopenCVÒ²ÓÐpython°æ±¾ÁË£¬ÕæÊÇÌ«¿áÁË£¡µ±È»pythonÔÚ´¦ÀíͼÏñʱ»¹¿ÉÒÔÓÃÆäËü¿âÀýÈçPIL(Python Imaging Library )£¬Ò»ÖÖÇáÁ¿¼¶µÄͼÏñ¿â¡£Ä¿Ç°openCV1.0°æ±¾¶ÔÓ¦µÄpython°æ±¾Îª2.5£¬openCV2.0¶ÔÓ¦python 2.6¡£
¸½Â¼£º
1. һƪ½éÉÜͼ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ