PL0编译器TurboPascal版再现

如何解决FPS/RTS/赛车类游戏的同步问题 算法简述   动作类游戏如何在高延迟下实现同步?不同的客户端网络情况,如何实现延迟补偿?十年前开始关注该问题,转眼十年已过,看到大家还在问这类问题,旧文一篇,略作补充(关于游戏同步相关问题还可以见我写于2005年的另外两篇文章,帧锁定算法 和 网游同步法则): 影子跟随算法由普通DR(dead reckoning)算法发展而来,我将其称为“影子跟随”意再表示算法同步策略的主要思想 阅读详情
(********************* PL0 编译程序Turbo Pascal代码 *********************)
program pl0(fa,fa1,fa2
);
(* PL0 compile with code generation *)
 
label 99
;
     
(* Turbo Pascal do not support goto between different
         blocks so, the 'goto' command in getch are replaced
         by procedure exitp !! in another way, 'label 99' do
         not work !!                  Lin Wei       2001  *)
 
const norw=13;      
(* of reserved words *)
     
txmax=100;    
(* length of identifier table *)
     
nmax=14;      
(* max number of digits in numbers *)
     
al=10;        
(* length of identifiers *)
     
amax=2047;    
(* maximum address *)
     
levmax=3;     
(* max depth of block nesting *)
     
cxmax=200;    
(* size of code array *)
 
type symbol=(nul,ident,number,plus,minus,times,slash,oddsym
,
            
eql,neq,lss,leq,gtr,geq,lparen,rparen,comma
,
            
semicolon,period,becomes,beginsym,endsym,ifsym
,
            
thensym,whilesym,writesym,readsym,dosym,callsym
,
            
constsym,varsym,procsym
);
    
alfa=packed array[1..al] of char
;
    
objects=(constant,variable,procedur
);
    
(* wirth used the word "procedure"and"object" there, which won't work! *)
    
symset=set of symbol
;
    
fct=(lit,opr,lod,sto,cal,int,jmp,jpc
);
    
instruction=
packed record
                   
f:fct;       
(* function code *)
                   
l:0..levmax; 
(* level *)
                   
a:0..amax;   
(* displacement addr *)
                
end
;
             
(* lit 0,a load constant a
                 opr 0,a execute opr a
                 lod 1,a load variable 1,a
                 sto 1,a store variable 1,a
                 cal 1,a call procedure at level 1
                 int 0,a increment t -register by a
                 jmp 0,a jump to a
                 jpc 0,a jump conditional to a *)
 
var fa:text
;
   
fa1,fa2:text
;
   
listswitch:boolean;   
(* true set list object code *)
   
ch:char;              
(* last char read *)
   
sym:symbol;           
(* last symbol read *)
   
id:alfa;              
(* last identifier read *)
   
num:integer;          
(* last number read *)
   
cc:integer;           
(* character count *)
   
ll:integer;           
(* line length *)
   
kk:integer
;
   
cx:integer;           
(* code allocation index *)
   
line:array[1..81] of char
;
   
a:alfa
;
   
code:array[0..cxmax] of instruction
;
   
word:array[1..norw] of alfa
;
   
wsym:array[1..norw] of symbol
;
   
ssym:array[' '..'^'] of symbol
;
       
(* wirth uses "array[char]" here *)
   
mnemonic:array[fct] of packed array[1..5] of char
;
   
declbegsys, statbegsys, facbegsys:symset
;
   
table:array[0..txmax]
of record
           
name:alfa
;
           
case kind:objects
of
             
constant:(val:integer
);
             
variable,procedur:(level,adr,size:integer
)
           
(* "size" lacking in original. I think it belongs here *)
         
end
;
   
fin,fout:text
;
   
fname:string
;
   
err:integer
;
   
endf:boolean
;
 
procedure error(n:integer
);
begin
 
writeln('****','':cc-1,'!',n:2
);
 
writeln(fa1,'****','':cc-1,'!',n:2
);
 
err:=err+1
;
end;
(* error *)
 
procedure exitp
;
begin
 
endf:=true
;
 
close(fin
);
 
writeln
;
 
exit
;
end
;
 
procedure getsym
;
var i,j,k:integer
;
 
 
procedure getch
;
 
begin
    if
cc=ll
then begin
      if
eof(fin)
then begin
        
write('program incomplete'
);
        
close(fin
);
        
writeln
;
        
exitp
;
        
(*goto 99;*)
     
end
;
     
ll:=0
;
     
cc:=0
;
     
write(cx:4,' '
);
     
write(fa1,cx:4,' '
);
     
while not eoln(fin)
do begin
       
ll:=ll+1
;
       
read(fin,ch
);
       
write(ch
);
       
write(fa1,ch
);
       
line[ll]:=ch
;
     
end
;
     
writeln
;
     
ll:=ll+1
;
     
(* read(fin,line[ll]); repleaced by two lines below *)
     
line[ll]:=' '
;
     
readln(fin
);
     
writeln(fa1
);
   
end
;
   
cc:=cc+1
;
   
ch:=line[cc
];
 
end;
(* getch *)
 
begin
(* getsym *)
 
while ch=' ' do getch
;
 
if ch in ['a'..'z']
then begin
    
k:=0
;
    
repeat
       if
k<al
then begin
         
k:=k+1
;
         
a[k]:=ch
;
      
end
;
      
getch
;
    
until not(ch in ['a'..'z','0'..'9'
]);
    
if k>=kk then kk:=k
    
else repeat
           
a[kk]:=' '
;
           
kk:=kk-1
;
         
until kk=k
;
    
id:=a
;
    
i:=1
;
    
j:=norw
;
    
repeat
      
k:=(i+j) div 2
;
      
if id<=word[k] then j:=k-1
;
      
if id>=word[k] then i:=k+1
;
    
until i>j
;
    
if i-1>j then sym:=wsym[k] else sym:=ident
;
 
end else if ch in ['0'..'9'] then begin
(* number *)
   
k:=0
;
   
num:=0
;
   
sym:=number
;
   
repeat
     
num:=10*num+(ord(ch)-ord('0'
));
     
k:=k+1
;
     
getch
;
   
until not(ch in['0'..'9'
]);
   
if k>nmax then error(30
);
 
end else if ch=':'
then begin
   
getch
;
   
if ch='='
then begin
      
sym:=becomes
;
      
getch
;
   
end else sym:=nul
;
 
end else if ch='<'
then begin
   
getch
;
   
if ch='='
then begin
      
sym:=leq
;
      
getch
;
   
end else sym:=lss
;
 
end else if ch='>'
then begin
   
getch
;
   
if ch='='
then begin
      
sym:=geq
;
      
getch
;
   
end else sym:=gtr
;
 
end else begin
   
sym:=ssym[ch
];
   
getch
;
 
end
;
end;
(* getsym *)
 
procedure gen(x:fct;y,z:integer
);
begin
  if
cx>cxmax
then begin
    
write('program too long'
);
    
(*goto 99;*)
 
end
;
 
with code[cx]
do begin
      
f:=x
;
      
l:=y
;
      
a:=z
;
 
end
;
 
cx:=cx+1
;
end;
(* gen *)
 
procedure test(s1,s2:symset;n:integer
);
begin
  if not
(sym in s1)
then begin
    
error(n
);
    
s1:=s1+s2
;
    
while not(sym in s1) do getsym
;
 
end
;
end;
(* test *)
 
procedure block(lev,tx:integer;fsys:symset
);
var dx:integer;  
(* data allocation index *)
   
tx0:integer; 
(* inital table index *)
   
cx0:integer; 
(* inital code index *)
   
procedure enter(k:objects
);
   
begin
(* enter object into table *)
     
tx:=tx+1
;
     
with table[tx]
do begin
       
name:=id
;
       
kind:=k
;
       
case k
of
         
constant:
begin
                      if
num>amax then begin error(31); num:=0; end
;
                     
val:=num
;
                   
end
;
         
variable:
begin
                     
level:=lev
;
                     
adr:=dx
;
                     
dx:=dx+1
;
                   
end
;
         
procedur: level:=lev
;
       
end
;
     
end
;
   
end;
(* enter *)
 
   
function position(id:alfa):integer
;
   
var i:integer
;
   
begin
(* find identifier in table *)
     
table[0].name:=id
;
     
i:=tx
;
     
while table[i].name<>id do i:=i-1
;
     
position:=i
;
   
end;
(* position *)
 
   
procedure constdeclaration
;
   
begin
      if
sym=ident
then begin
        
getsym
;
        
if sym in [eql,becomes]
then begin
            if
sym=becomes then error(1
);
           
getsym
;
           
if sym=number
then begin
              
enter(constant
);
              
getsym
;
           
end else error(2
);
        
end else error(3
);
     
end else error(4
);
   
end;
(* constdeclaration *)
 
   
procedure vardeclaration
;
   
begin
      if
sym=ident
then begin
        
enter(variable
);
        
getsym
;
     
end else error(4
);
   
end;
(* vardeclaration *)
 
   
procedure listcode
;
   
var i:integer
;
   
begin
      if
listswitch
then begin
         for
i:=cx0 to cx-1
do
             with
code[i]
do begin
                 
writeln(i,mnemonic[f]:5,l:3,a:5
);
                 
writeln(fa,i:4,mnemonic[f]:5,l:3,a:5
);
            
end
;
     
end
;
   
end;
(* listcode *)
 
   
procedure statement(fsys:symset
);
   
var i,cx1,cx2:integer
;
       
procedure expression(fsys:symset
);
       
var addop:symbol
;
           
procedure term(fsys:symset
);
           
var mulop:symbol
;
               
procedure factor(fsys:symset
);
               
var i:integer
;
               
begin
                 
test(facbegsys,fsys,24
);
                 
while sym in facbegsys
do begin
                    if
sym=ident
then begin
                      
i:=position(id
);
                      
if i=0 then error(11
)
                      
else with table[i]
do
                         case
kind
of
                          
constant:gen(lit,0,val
);
                          
variable:gen(lod,lev-level,adr
);
                          
procedur:error(21
);
                        
end
;
                      
getsym
;
                   
end else if sym=number
then begin
                        if
num>amax
then begin
                          
error(31
);
                          
num:=0
;
                       
end
;
                       
gen(lit,0,num
);
                       
getsym
;
                   
end else if sym=lparen
then begin
                       
getsym
;
                       
expression([rparen]+fsys
);
                       
if sym=rparen then getsym
                        else error(22
);
                   
end
;
                   
test(fsys,facbegsys,23
);
                 
end
;
               
end;
(* factor *)
 
           
begin
(* term *)
             
factor([times,slash]+fsys
);
             
while sym in [times,slash]
do begin
               
mulop:=sym
;
               
getsym
;
               
factor(fsys+[times,slash
]);
               
if mulop=times then gen(opr,0,4) else gen(opr,0,5
)
             
end
;
           
end;
(* term *)
 
       
begin
(* expression *)
         
if sym in [plus,minus]
then begin
            
addop:=sym
;
            
getsym
;
            
term(fsys+[plus,minus
]);
            
if addop=minus then gen(opr,0,1
);
         
end else term(fsys+[plus,minus
]);
         
while sym in [plus,minus]
do begin
           
addop:=sym
;
           
getsym
;
           
term(fsys+[plus,minus
]);
           
if addop=plus then gen(opr,0,2) else gen(opr,0,3
);
         
end
;
       
end;
(* expression *)
 
       
procedure condition(fsys:symset
);
       
var relop:symbol
;
       
begin
          if
sym=oddsym
then begin
            
getsym
;
            
expression(fsys
);
            
gen(opr,0,6
);
         
end else begin
            
expression([eql,neq,lss,leq,gtr,geq]+fsys
);
            
if not(sym in [eql,neq,lss,leq,gtr,geq]) then error(20
)
            
else begin
              
relop:=sym
;
              
getsym
;
              
expression(fsys
);
              
case relop
of
                
eql:gen(opr,0,8
);
                
neq:gen(opr,0,9
);
                
lss:gen(opr,0,10
);
                
geq:gen(opr,0,11
);
                
gtr:gen(opr,0,12
);
                
leq:gen(opr,0,13
);
              
end
;
            
end
;
         
end
;
       
end;
(* condition *)
 
   
begin
(* statement *)
     
if sym=ident
then begin
        
i:=position(id
);
        
if i=0 then error(11
)
        
else if table[i].kind<>variable
then begin
          
error(12
);
          
i:=0
;
        
end
;
        
getsym
;
        
if sym=becomes then getsym else error(13
);
        
expression(fsys
);
        
if i<>0 then with table[i] do gen(sto,lev-level,adr
);
     
end else if sym=readsym
then begin
        
getsym
;
        
if sym<>lparen then error(34
)
        
else repeat
               
getsym
;
               
if sym=ident then i:=position(id
)
               
else i:=0
;
               
if i=0 then error(35
)
               
else with table[i]
do begin
                 
gen(opr,0,16
);
                 
gen(sto,lev-level,adr
);
               
end
;
               
getsym
;
        
until sym<>comma
;
        
if sym<>rparen
then begin
           
error(33
);
           
while not(sym in fsys) do getsym
;
        
end else getsym
;
     
end else if sym=writesym
then begin
        
getsym
;
        
if sym=lparen
then begin
            repeat
             
getsym
;
             
expression([rparen,comma]+fsys
);
             
gen(opr,0,14
);
           
until sym<>comma
;
           
if sym<>rparen then error(33) else getsym
;
        
end
;
        
gen(opr,0,15
);
     
end else if sym=callsym
then begin
        
getsym
;
        
if sym<>ident then error(14
)
        
else begin
          
i:=position(id
);
          
if i=0 then error(11) else with table[i]
do
              if
kind=procedur then gen(cal,lev-level,adr
)
             
else error(15
);
          
getsym
;
        
end
;
     
end else if sym=ifsym
then begin
        
getsym
;
        
condition([thensym,dosym]+fsys
);
        
if sym=thensym then getsym
         else error(16
);
        
cx1:=cx
;
        
gen(jpc,0,0
);
        
statement(fsys
);
        
code[cx1].a:=cx
;
     
end else if sym=beginsym
then begin
        
getsym
;
        
statement([semicolon,endsym]+fsys
);
        
while sym in [semicolon]+statbegsys
do begin
           if
sym=semicolon then getsym
           else error(10
);
          
statement([semicolon,endsym]+fsys
);
        
end
;
        
if sym=endsym then getsym else error(17
);
     
end else if sym=whilesym
then begin
        
cx1:=cx
;
        
getsym
;
        
condition([dosym]+fsys
);
        
cx2:=cx
;
        
gen(jpc,0,0
);
        
if sym=dosym then getsym else error(18
);
        
statement(fsys
);
        
gen(jmp,0,cx1
);
        
code[cx2].a:=cx
;
     
end
;
     
test(fsys,[],19
);
   
end;
(* statement *)
 
begin
(* block *)
 
dx:=3
;
 
tx0:=tx
;
 
table[tx].adr:=cx
;
 
gen(jmp,0,0
);
 
if lev>levmax then error(32
);
 
repeat
    if
sym=constsym
then begin
      
getsym
;
      
repeat
        
constdeclaration
;
        
while sym=comma
do begin
          
getsym
;
          
constdeclaration
;
        
end
;
        
if sym=semicolon then getsym else error(5
);
      
until sym<>ident
;
   
end
;
   
if sym=varsym
then begin
      
getsym
;
      
repeat
;
        
vardeclaration
;
        
while sym=comma
do begin
          
getsym
;
          
vardeclaration
;
        
end
;
        
if sym=semicolon then getsym else error(5
);
      
until sym<>ident
;
   
end
;
   
while sym=procsym
do begin
     
getsym
;
     
if sym=ident
then begin
        
enter(procedur
);
        
getsym
;
     
end else error(4
);
     
if sym=semicolon then getsym else error(5
);
     
block(lev+1,tx,[semicolon]+fsys
);
     
if sym=semicolon
then begin
        
getsym
;
        
test(statbegsys+[ident,procsym],fsys,6
);
     
end else error(5
);
   
end
;
   
test(statbegsys+[ident],declbegsys,7
);
 
until not(sym in declbegsys
);
 
code[table[tx0].adr].a:=cx
;
 
with table[tx0]
do begin
      
adr:=cx
;
      
size:=dx
;
 
end
;
 
cx0:=cx
;
 
gen(int,0,dx
);
 
statement([semicolon,endsym]+fsys
);
 
gen(opr,0,0
);
 
test(fsys,[],8
);
 
listcode
;
end;
(* block *)
 
procedure interpret
;
const stacksize=500
;
var p,b,t:integer;
(* program base topstack registers *)
   
i:instruction
;
   
s:array[1..stacksize] of integer;
(* datastore *)
 
   
function base(l:integer):integer
;
   
var bl:integer
;
   
begin
     
bl:=b;
(* find base 1 level down *)
     
while l>0
do begin
       
bl:=s[bl
];
       
l:=l-1
;
     
end
;
     
base:=bl
;
   
end;
(* base *)
 
begin
 
writeln('start pl0'
);
 
t:=0; b:=1; p:=0
;
 
s[1]:=0; s[2]:=0; s[3]:=0
;
 
repeat
   
i:=code[p
];
   
p:=p+1
;
   
with i do case f
of
     
lit: begin t:=t+1; s[t]:=a; end
;
     
opr: case a of
(* operator *)
            
0: begin
(* return *)
                 
t:=b-1
;
                 
p:=s[t+3
];
                 
b:=s[t+2
];
               
end
;
            
1: s[t]:=-s[t
];
            
2: begin t:=t-1; s[t]:=s[t]+s[t+1]; end
;
            
3: begin t:=t-1; s[t]:=s[t]-s[t+1]; end
;
            
4: begin t:=t-1; s[t]:=s[t]*s[t+1]; end
;
            
5: begin t:=t-1; s[t]:=s[t] div s[t+1]; end
;
            
6: s[t]:=ord(odd(s[t
]));
            
8: begin t:=t-1; s[t]:=ord(s[t]=s[t+1]); end
;
            
9: begin t:=t-1; s[t]:=ord(s[t]<>s[t+1]); end
;
            
10:begin t:=t-1; s[t]:=ord(s[t]<s[t+1]); end
;
            
11:begin t:=t-1; s[t]:=ord(s[t]>=s[t+1]); end
;
            
12:begin t:=t-1; s[t]:=ord(s[t]>s[t+1]); end
;
            
13:begin t:=t-1; s[t]:=ord(s[t]<=s[t+1]); end
;
            
14:begin write(s[t]); write(fa2,s[t]); t:=t-1; end
;
            
15:begin writeln; writeln(fa2); end
;
            
16:begin t:=t+1; write('?'); write(fa2,'?'); readln(s[t
]);
               
writeln(fa2,s[t]); end
;
          
end
;
     
lod: begin t:=t+1; s[t]:=s[base(l)+a]; end
;
     
sto: begin s[base(l)+a]:=s[t]; (* writeln(s[t]) *) t:=t-1; end
;
     
cal: begin (* generat new block mark *) s[t+1]:=base(l); s[t+2]:=b
;
          
s[t+3]:=p; b:=t+1; p:=a; end
;
     
int: t:=t+a
;
     
jmp: p:=a
;
     
jpc: begin if s[t]=0 then p:=a; t:=t-1; end
;
   
end;
(* with, case *)
 
until p=0
;
 
close(fa2
);
end;
(* interpret *)
 
begin
(* main *)
 
for ch:=' ' to '!' do ssym[ch]:=nul
;
 
(* changed bacause of different character set
     note the typos below in the original where
     the alfas were not given the correct space *)
 
word[1]:='begin     ';  word[2]:='call      '
;
 
word[3]:='const     ';  word[4]:='do        '
;
 
word[5]:='end       ';  word[6]:='if        '
;
 
word[7]:='odd       ';  word[8]:='procedure '
;
 
word[9]:='read      ';  word[10]:='then      '
;
 
word[11]:='var       '; word[12]:='while     '
;
 
word[13]:='write     '
;
 
 
wsym[1]:=beginsym;   wsym[2]:=callsym
;
 
wsym[3]:=constsym;   wsym[4]:=dosym
;
 
wsym[5]:=endsym;     wsym[6]:=ifsym
;
 
wsym[7]:=oddsym;     wsym[8]:=procsym
;
 
wsym[9]:=readsym;    wsym[10]:=thensym
;
 
wsym[11]:=varsym;    wsym[12]:=whilesym
;
 
wsym[13]:=writesym
;
 
 
ssym['+']:=plus;     ssym['-']:=minus
;
 
ssym['*']:=times;    ssym['/']:=slash
;
 
ssym['(']:=lparen;   ssym[')']:=rparen
;
 
ssym['=']:=eql;      ssym[',']:=comma
;
 
ssym['.']:=period;   ssym['#']:=neq
;
 
ssym[';']:=semicolon
;
 
 
mnemonic[lit]:='lit  ';  mnemonic[opr]:='opr  '
;
 
mnemonic[lod]:='lod  ';  mnemonic[sto]:='sto  '
;
 
mnemonic[cal]:='cal  ';  mnemonic[int]:='int  '
;
 
mnemonic[jmp]:='jmp  ';  mnemonic[jpc]:='jpc  '
;
 
 
declbegsys:=[constsym,varsym,procsym
];
 
statbegsys:=[beginsym,callsym,ifsym,whilesym
];
 
facbegsys:=[ident,number,lparen
];
 
 
(* page(output) *)
 
endf:=false
;
 
assign(fa1,'PL0.txt'
);
 
rewrite(fa1
);
 
write('input file? '
);
 
write(fa1,'input file?'
);
 
readln(fname
);
 
writeln(fa1,fname
);
 
(* openf(fin,fname,'r'); ==> *)
 
assign(fin,fname); reset(fin
);
 
write('list object code ?'
);
 
readln(fname
);
 
write(fa1,'list object code ?'
);
 
listswitch:=(fname[1]='y'
);
 
err:=0
;
 
cc:=0; cx:=0; ll:=0
;
 
ch:=' '; kk:=al
;
 
getsym
;
 
assign(fa,'PL0-1.txt'
);
 
assign(fa2,'PL0-2.txt'
);
 
rewrite(fa
);
 
rewrite(fa2
);
 
block(0,0,[period]+declbegsys+statbegsys
);
 
close(fa
);
 
close(fa1
);
 
if sym<>period then error(9
);
 
if err=0 then interpret else write('error in pl/0 program'
);
99:
(* this line is not work in turbo pascal so replace by
       procedure exitp: see the memo at the top *)
 
close(fin
);
 
writeln
;
end
. 
 
后端开发 Docker4.99.0 AppleSilicon 苹果芯片 Mac 安装包 本资源为 Docker Desktop 4.99.0 苹果芯片(Apple Silicon)专用安装包,原生适配 M 系列 Mac,可快速搭建本地容器开发环境,支持镜像拉取、容器编排、项目打包部署。适合后端开发、运维、全栈开发者,用于本地微服务、测试环境、项目容器化开发。 立即下载

相关推荐

EtherCAT主站视角:如何正确配置一个支持动态PDO的从站(以倍福TwinCAT为例)

本文详细解析了在TwinCAT环境下配置支持动态PDO的EtherCAT从站的全过程。通过MDP(Modular Device Profile)实现模块化配置,涵盖从站工作原理、TwinCAT工程配置、调试技巧到高级应用实践,帮助工程师快速掌握动态PDO配置技术,提升工业现场设备扩展与维护效率。

weixin_30466039的博客 267

pl0源码(可在delphi7中运行)

{$Apptype console} program pl0(fa,fa1,fa2); (* PL/0编译程序与代码生成解释运行程序 *) (* PL/0 compiler with code generation *) label 99; (* 声明出错跳转标记 *) (* 在Turbo Pascal 7.0中已不允许跨过程的GOTO转移,因此后面的GOTO语句均被我去除了,因此这里的l

diligentcat的专栏 2062

【EtherCAT实践篇一】TwinCAT 3安装、使用

FULL(XAE)安装包:包含了XAR的功能,并能进行多种语言的编程和硬件组态,通常安装在编程电脑上;XAR安装包:包含了ADS的功能,是实时运行环境,对 TwinCAT 模块进行加载、执行、管理、实时运行与调用,通常安装在PLC中;RM安装包:在装了高版本的TwinCAT 3后,发现PLC中的TwinCAT版本较低,就需要安装相应低版本的RM安装包切换版本使用(注:4024无法使用RM安装包切换到低于4022的版本,如4020/4018/4016版本。

JXES智能生态系统 5125

编译原理 | 实验任务一:在计算机上实现PL0语言的编译程序

代码及结果: github 1 找到PASCAL编译系统 下载安装free pascal,设置环境变量,然后用vscode编辑。 2 在PASCAL系统上运行PL0编译程序,需要对PL0编译程序作一些修改、调试 1.改格式(缩进、注释) 2.符号修改 ~ -&amp;amp;amp;amp;amp;amp;gt; not//~这个符号打不出来,反正就是非的意思 //procedure和object在pascal中是关键字,所以分别使用...

⊳ideal world⊲~ヽ(゚︺゚)Hi 6057

ollama服务暴露公网?三步搞定Nginx反向代理配置(避坑指南)

本文详细介绍了如何通过Nginx反向代理安全地将Ollama服务暴露到公网,避免直接修改OLLAMA_HOST带来的安全隐患。文章提供了从SSL证书部署到高级安全加固的全流程实战指南,包括IP白名单、基础认证、速率限制等企业级安全措施,帮助用户实现安全可靠的外部访问。

wood5的博客 177

科研绘图系列:R语言绘制差异蝴蝶图(Butterfly Chart)

科研绘图系列:R语言蝴蝶图(Butterfly Chart)

专注生信领域 1390

PL0编译器TurboPascal版再现时间:2009-07-20 17:24:49来源:网络 作者:未知 点击:52次

PL0编译器TurboPascal版再现时间:2009-07-20 17:24:49来源:网络 作者:未知 点击:52次 (********************* PL0 编译程序Turbo Pascal代码 *********************)(********************* PL0 编译程序Turbo Pascal代码 *********************) pr

diligentcat的专栏 1127

【华为OD机试真题】459、小扇和小船的数字游戏、数字游戏 | 机试真题+思路参考+代码解析(CD卷)(C++、Java、Py)

### 🎃题目描述 >小扇和小船今天又玩起来了数字游戏,小船给小扇一个正整数 n(1  现在求 m 的最小值

KJ.JK 1718

Pascal 编程语言:从辉煌到传承

随着时间的推移,Free Pascal不仅保持了与Turbo Pascal的兼容性,而且还引入了许多新的特性和改进,比如支持复杂类型的函数返回值等。后来他的学生Philipe Kahn毕业后和Anders Hejlsberg(Delphi之父)创办了Borland公司,靠Turbo Pascal起家,很快成为了将Borland发展成为全球最大的开发工具厂商,这一切都不得不说要归功于Pascal语言的魅力。尽管随着时间的推移,Pascal语言的流行度有所下降,但它对后续编程语言的发展产生了深远的影响。

2404_87526689的博客 3603

利用GAT(图论分析工具箱)构建并分析大脑结构协变网络学习笔记

前言 前面我学习了利用DTI构建白质纤维脑网络,并采用GRETNA计算了小世界网络属性。阅读文献发现可以利用灰质体积或皮层指标(皮层厚度、折叠指数、沟深)等构建结构协变网络再进行网络拓扑属性的计算。因此,我采用前面提取的灰质体积和皮质数据进行了结构协变网络分析,特此写下笔记以便后面的学习。 一、数据准备 二、构建结构协变网络 三、全局属性的统计分析 四、局部属性的统计分析 五、网络攻击分析 六、度的分布 ..................

weixin_52073820的博客 7496

ue 打包linux程序 在windows系统 2026

ue 打包linux程序 在windows系统 2026

jacke121的专栏 371

百行内实现五子棋人机对战

国庆没事,想看看最少多少行可以写一个人机对战起来游戏,于是有了这个Python版五子棋人机对战,仅仅几百行。 #! /usr/bin/env python # -*- coding: utf-8 -*- import sys, time #----------------------------------------------------------------------

Skywind Inside 1万+

Oracle EBS FA 创建成批增加执行时间长且报错

摘要 Oracle EBS系统在执行"创建成批增"请求时出现长时间运行并报错(ORA-00603和ORA-03114)。

陈显平的专栏-Oracle EBS 174

快速可靠协议 - KCP

快速可靠协议 URL: https://code.google.com/p/ikcp/  KCP是一个快速可靠协议,能以比 TCP浪费10%-20%的带宽的代价,换取平均延迟降低 30%-40%,且最大延迟降低三倍的传输效果。纯算法实现,并不负责底层协议(如UDP)的收发,需要使用者自己定义下层数据包的发送方式,并以 callback的方式提供给 KCP。连时钟都需要外部传递进来,内部

Skywind Inside 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

[原创] PowerPC 汇编入门与优化

PowerPC Figure – PPC入门与优化 By Skywind(2007) http://www.joynb.net/blog/ 背景介绍 PowerPC于1991年IBM/MOTO/APPLE研制,大量应用于服务器(AIX / AS400系列及苹果系列服务器),家用游戏机(PS3, Wii, XBOX, GameCube),以及嵌入式(仅次于Arm/x86排第三)。PowerPC核心在于开放系统软件标准,其应用范围仅次于x86,是除去x86外最值得开发者了解的体系。 不需要写出非常高

Skywind Inside 8915

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

体育竞技游戏的团队AI

很多人问游戏AI该怎么做?随着游戏类型的多元化,非 MMO或者卡牌的游戏越来越多,对AI的需求也越来越强了。而市面上关于 AI的书,网上找得到的文章,也都流于一些只言片语的认识,理论化的套路,和一些简单的 DEMO,离真正的项目差距甚远,无法前后衔接成一条线,更无法真正落地到编码。 国内真正做过游戏AI的少之又少,东拉西扯的人很多,真正做过项目的人很少,因为国内主要以MMO为主,RTS比较少

Skywind Inside 6225

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

【原创】快速除以255的方法

经过若干次试验修改,研究出下面这个快速/255的宏,可以在 X属于[0,65536]的范围内误差为零: #define div_255_fast(x) (((x) + (((x) + 257) >> 8)) >> 8) 传统来说,人们习惯于将 /255改为 >>

Skywind Inside 5470

业余土制:轻量级图形库 PixelLib

简述:2D抗锯齿,矢量制图,快速图形图像变换,64种不同的像素格式,色彩空间变换,SSE2/MMX优化,纯软件实现,纯C代码。 地址:http://code.google.com/p/pixellib/ 1. 图像变换: 支持仿射变换和透视变换,提供大量图像变换操作接口。 2. 抗锯齿: 所有图形绘制支持3级不同程度的抗锯齿效果。 3. 图像绘制: 图像任意拉伸,旋转,3D旋转,并且同时进行色彩空间变换。全部采用浮点数坐标,图像移动更为平滑。 4. 几何作图: 全面的抗锯齿几何作图效果。

Skywind Inside 4760

移动设备通用手势识别算法

移动设备多用手势进行输入,用户通过手指在屏幕上画出一个特定符号,计算机识别出来后给予相应的反应,要比让用户点击繁琐的按钮为直接和有趣,而如果为每种手势编写一段识别代码的话是件得不偿失的事情。如何设计一种通用的手势识别算法来完成上面的事情呢? 我们可以模仿笔记识别方法,实现一个简单的笔画识别模块,流程如下: 第一步:手势归一化 1. 手指按下时开始记录轨迹点,每划过一个新的点就记录到手

Skywind Inside 3954

Python少打字小技巧

说明:增加代码的描述力,可以成倍减少你的LOC,做到简单,并且真切有力观点:少打字=多思考+少出错,10代码行比50行更能让人明白,以下技巧有助于提高5倍工作效率1. 交换变量值时避免使用临时变量:(cookbook1.1)老代码:我们经常很熟练于下面的代码temp = xx = yy = temp代码一:u, v, w = w, v, u  有人提出可以利用赋值顺序来简化上面的三行代

Skywind Inside 2965

关于“面向显示器编程”

最近吃饭的时候听公司两位同事聊起“面向显示器编程”(screen oriented programming)。sop这个东西我虽偶有所闻,却未有什么了解。这两位同事跟我说AOP其实是退化了的SOP,这个说法让我觉得SOP会有点意思。个人觉得,OOP完成了对数据的重用,AOP完成了对算发的重用,而SOP则完成了对显示器的重用。基于对SOP的应用,我们只需要在电脑前多加一把凳子,就可以通过工作空间上的

Skywind Inside 2642

GFP-Tree 内存分配器

我也来介绍一些内存管理方面的优化算法:怎样才能根除内存碎片?有且只有如下办法:1. 只分配不释放,2. 只分配固定大小内存,3. 不分配内存,虽然,仍不妨碍我们再一次回顾各种常用的分配策略,以发掘一些新的思路: 前提:下面提及的分配技巧并不能说是“最快的”,也不能说是“最小碎片的”,但是可以保证,不管系统运行多长时间,不管分配多大内存,碎片比例趋于恒定,同时分配时间为常数(unit interval): 最后将讨论一些更进一步的优化技巧(如果愿意大量增加代码行数的话),看看在分配内存方面,哪些我们值得努

Skywind Inside 2557

再现MSN魔法表情效果

下面是播放时候的效果图:MSN的魔法表情实在是COOL,兴趣之下自己也做了一个特效演示将FLASH拖到窗口上面,然后点“特效”,如果桌面是32位的效果非常漂亮,可以拖动图形,现在就下载:演示程序 演示程序地址二 (98KB) 最好笑的事情是那天发现有些聊天软件的魔法表情居然是假的,它是把桌面抓下来然后用IE空间来播放flash, 顺便把抓下来的桌面当背景.或者直接用ColorKey -_-

Skywind Inside 2474

Extreme Game Programming

Extreme Game Programming - EXFORCEAfter enjoyed the demo "OMNISCENT" in 1997, I write another one today. simpler, and smaller :-)Run DEBUG in DOS Window, copy and paste the text below to DEBUG:-------

Skywind Inside 2111

再谈网游同步技术

根据游戏类型,选择恰当的同步方式和传输协议是最基础的问题,很多讲述网络同步的文章一般就是只会强调上述那么多种算法的其中一种方式,好像使用该方式就可以 hold 住所有游戏一样的,其实并非如此。技术需要多和策划沟通,别策划一个需求下来,技术就来一句:无法实现,这样的游戏永远没有竞争力。就像国内当时都是慢节奏 RPG,偶尔有点 ARPG 的时候,大家觉得《DNF》这样的游戏无法实现,于是韩国实现了,在市场上取得了先机,国内才慢慢跟进,再一看,哇塞,好多坑呢。

Skywind Inside 1192
上一篇: Extreme Game Programming
下一篇: MINI-FOOLFLY 游戏代码
skywind
博客等级 码龄26年 479粉丝 70原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值