Saturday, March 29, 2008

Game Logic

(A note to myself)
  • Q. Is there an accepted method of handling game-type logic? I've never programmed a game before. What's the best way to organize the computer's playing strategy?

  • A. It's called "minimax searching" on a tree of legal moves. There's an optimization on it called "alpha beta pruning". If you do a search on Google for those terms I bet you'll find a lot of information.

http://www.cs.cornell.edu/Courses/cs312/2002sp/lectures/rec21.htm

Sunday, March 23, 2008

VI exrc and help file

.exrc

set wm=10
set showmode
set number
map #1 :!more ~/.exrc
map #2 :!more ~/.vi_help
map #3 :set number
map #4 :set nonumber
map K dwwP

.vi_help

                                                                      vi Help
----------------                        -----------------
Editing Commands                        Deleting Commands
----------------                        -----------------

 i insert    x delete character
 o open a new line (below)  X delete character to left
 O open a new line (above)  d0 delete to beginning of line
 a append    d$ delete to end of line
 A append at end of line  dd delete line
 u undo    5dd delete 5 lines
 . repeat last command

-------------------   -----------------
Cutting and Pasting   Movement Commands
-------------------   -----------------

 yy yank    H move to top of screen (high)
 5yy yank 5 lines   M move to middle
 p paste    L move to low
 P paste above current position 10G go to line 10
     w go to next word
     b go back to previous word
     0 beginning of line
     $ end of line

------------------
Searching Commands
------------------

 /fred  search for "fred"
 ?fred  search backwards for "fred"
 n  repeat the last search



----------------------------------
Function Key Mappings (Customized)
----------------------------------

 F1:  show the .exrc file 
 F2:  show .vi_help (this file) 
 F3:  set number 
 F4:  set nonumber


---------------------
Run External Commands
---------------------

 :!ls -al  list current directory (long list)
 :!pwd   print working directory



----------------------
Miscellaneous Commands
----------------------

 :r   read contents of a file into the current file
 :s/FRED/BARNEY/g swap FRED with BARNEY (current line only)
 :10,20s/FRED/BARNEY/g swap FRED with BARNEY on lines 10 through 20
 :1,$s/FRED/BARNEY/g swap every occurrence of FRED with BARNEY (entire file)
 :10,20d  delete lines 10 through 20
 :10,20y  yank (copy) lines 10 through 20 to the buffer
:r !sort somefile read contents of somefile after sorting
:r !date  read output of date command into file at cursor point
:69,72!sort  sort lines 69-72, and replace whatever was in 69-72 




----------------
Auto-Indentation
----------------

Your ~/.exrc file is configured to automatically indent each line.  
To move backwards (and eliminate indentation), hit 

 ^d


----------------
MISC
----------------

shell script from "Learning the VI Editor" Chapter 7/Advanced Editing/Here Documents/page 124
----
for file in $*
do
ex - $file << E_O_F
g/thier/s/ /their/g
g/writeable/s/ /writable/g
g/qoute/s/ /quote/g
g/blockqoute/s/ /blockquote/g
wq
E_O_F
done
----

Monday, March 17, 2008

XServe CLI Web Status

note: the serveradmin command is not in executable path,you must include path to it, or
PATH=${PATH}:/usr/sbin

sudo /usr/sbin/serveradmin fullstatus web | less
tail /var/log/httpd/access_log