Trafficsamples.pas
Un article de Wikipedia.
Solution minimale du jeu Traffic!
function initplateau(n:byte):plistebloc; type tableau=array [1..18] of string; var s:tableau; i:byte; function conversion:plistebloc; var lb:plistebloc; k:byte; procedure ajoute(v:string); var t:taille; dir:direction; g:genre; x,y:byte; begin x:=StringToInt(v[1]); y:=StringToInt(v[2]); case v[3] of 'h': dir:=hori; 'v': dir:=verti; end; case v[4] of '2': t:=deux; '3': t:=trois; end; case v[5] of 'n': g:=normal; 'p': g:=principal; end; lb := ajouterbloc(lb,creerbloc(x,y,dir,t,g)); end; begin lb:=nil; for k:=1 to 18 do begin if length(s[k]) <> 0 then begin if s[k][5] = 'n' then ajoute(s[k]); end; end; for k:=1 to 18 do begin if length(s[k]) <> 0 then begin if s[k][5] = 'p' then ajoute(s[k]); end; end; conversion:=lb; end; begin for i:=1 to 18 do s[i]:=''; case n of 1: begin s[1]:='11v2n'; s[2]:='31h3n'; s[3]:='52h2n'; s[4]:='13v3n'; s[5]:='43v3n'; s[6]:='24h2p'; s[7]:='64v3n'; s[8]:='16h2n'; end; 2: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='41h2n'; s[4]:='52h2n'; s[5]:='13h3n'; s[6]:='53v2n'; s[7]:='63v3n'; s[8]:='14h2p'; s[9]:='44v2n'; s[10]:='15v2n'; s[11]:='46h3n'; end; 3: begin s[1]:='21v2n'; s[2]:='31h2n'; s[3]:='61v3n'; s[4]:='42v3n'; s[5]:='23h2n'; s[6]:='24h2p'; end; 4: begin s[1]:='31h3n'; s[2]:='61v2n'; s[3]:='32v2n'; s[4]:='43h3n'; s[5]:='14v3n'; s[6]:='24h2p'; s[7]:='44v3n'; end; 5: begin s[1]:='11v2n'; s[2]:='51h2n'; s[3]:='52h2n'; s[4]:='13v3n'; s[5]:='23h3n'; s[6]:='53v3n'; s[7]:='63v2n'; s[8]:='24h2p'; s[9]:='44v3n'; s[10]:='65v2n'; s[11]:='16h2n'; end; 6: begin s[1]:='11v2n'; s[2]:='41h3n'; s[3]:='32v2n'; s[4]:='42v3n'; s[5]:='13h2n'; s[6]:='53v3n'; s[7]:='63v3n'; s[8]:='24h2p'; s[9]:='15h2n'; s[10]:='45v2n'; s[11]:='16h2n'; end; 7: begin s[1]:='41v2n'; s[2]:='33h2n'; s[3]:='63v2n'; s[4]:='24h2p'; s[5]:='44v2n'; s[6]:='25v2n'; s[7]:='55v2n'; s[8]:='65v2n'; s[9]:='36h2n'; end; 8: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='41h3n'; s[4]:='12h2n'; s[5]:='42h3n'; s[6]:='13h2n'; s[7]:='33v2n'; s[8]:='43v2n'; s[9]:='53h2n'; s[10]:='14h2p'; s[11]:='54v2n'; s[12]:='64v3n'; s[13]:='35h2n'; s[14]:='46h2n'; end; 9: begin s[1]:='11v3n'; s[2]:='31v2n'; s[3]:='61v2n'; s[4]:='52v3n'; s[5]:='23h3n'; s[6]:='63v2n'; s[7]:='14h2p'; s[8]:='44v2n'; s[9]:='25v2n'; s[10]:='55h2n'; s[11]:='36h2n'; s[12]:='56h2n'; end; 10: begin s[1]:='11h2n'; s[2]:='41v2n'; s[3]:='51h2n'; s[4]:='12v3n'; s[5]:='52h2n'; s[6]:='23h3n'; s[7]:='63v3n'; s[8]:='24h2p'; s[9]:='15h2n'; s[10]:='35v2n'; s[11]:='16h2n'; s[12]:='56h2n'; end; 11: begin s[1]:='31h3n'; s[2]:='61v2n'; s[3]:='32v2n'; s[4]:='43h3n'; s[5]:='14v3n'; s[6]:='24h2p'; s[7]:='44v3n'; s[8]:='26h2n'; end; 12: begin s[1]:='11h3n'; s[2]:='51v2n'; s[3]:='33v3n'; s[4]:='43h3n'; s[5]:='14h2p'; s[6]:='64v3n'; s[7]:='15v2n'; s[8]:='26h2n'; end; 13: begin s[1]:='11v3n'; s[2]:='21h2n'; s[3]:='41v2n'; s[4]:='51h2n'; s[5]:='52h2n'; s[6]:='23v2n'; s[7]:='43h2n'; s[8]:='63v3n'; s[9]:='34v2n'; s[10]:='44h2p'; s[11]:='55v2n'; s[12]:='16h2n'; s[13]:='36h2n'; end; 14: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='52h2n'; s[4]:='13v2n'; s[5]:='23v2n'; s[6]:='33h2n'; s[7]:='53v2n'; s[8]:='63v2n'; s[9]:='34h2p'; s[10]:='35v2n'; s[11]:='55h2n'; s[12]:='16h2n'; end; 15: begin s[1]:='21h2n'; s[2]:='41h2n'; s[3]:='12v3n'; s[4]:='22v3n'; s[5]:='32v2n'; s[6]:='42v2n'; s[7]:='52h2n'; s[8]:='53v3n'; s[9]:='63v3n'; s[10]:='34h2p'; s[11]:='15h2n'; s[12]:='35h2n'; s[13]:='26h2n'; s[14]:='46h2n'; end; 16: begin s[1]:='11h2n'; s[2]:='32v3n'; s[3]:='23v2n'; s[4]:='43h3n'; s[5]:='14v2n'; s[6]:='44h2p'; s[7]:='64v3n'; s[8]:='35h2n'; s[9]:='55v2n'; s[10]:='16h2n'; s[11]:='36h2n'; end; 17: begin s[1]:='11h3n'; s[2]:='41v3n'; s[3]:='51v2n'; s[4]:='61v2n'; s[5]:='12h3n'; s[6]:='13h2n'; s[7]:='33v2n'; s[8]:='14h2p'; s[9]:='15v2n'; s[10]:='35h2n'; s[11]:='55h2n'; s[12]:='26h3n'; end; 18: begin s[1]:='11h3n'; s[2]:='12v3n'; s[3]:='22h2n'; s[4]:='23h3n'; s[5]:='24h2p'; s[6]:='44v3n'; s[7]:='15h2n'; s[8]:='35v2n'; s[9]:='16h2n'; end; 19: begin s[1]:='12h3n'; s[2]:='52v2n'; s[3]:='23v2n'; s[4]:='33h2n'; s[5]:='34h2p'; s[6]:='54v2n'; s[7]:='35v2n'; s[8]:='46h2n'; end; 20: begin s[1]:='31v2n'; s[2]:='41h3n'; s[3]:='42h2n'; s[4]:='62v3n'; s[5]:='14h2p'; s[6]:='44v2n'; s[7]:='15v2n'; s[8]:='25h2n'; s[9]:='46h3n'; end; 21: begin s[1]:='41h3n'; s[2]:='13v3n'; s[3]:='23h3n'; s[4]:='24h2p'; s[5]:='44v3n'; s[6]:='35v2n'; s[7]:='16h2n'; end; 22: begin s[1]:='11v2n'; s[2]:='21h3n'; s[3]:='61v2n'; s[4]:='22v2n'; s[5]:='32h2n'; s[6]:='43v3n'; s[7]:='53h2n'; s[8]:='14v2n'; s[9]:='24h2p'; s[10]:='35v2n'; s[11]:='55h2n'; s[12]:='46h3n'; end; 23: begin s[1]:='31h3n'; s[2]:='32v2n'; s[3]:='42v2n'; s[4]:='52h3n'; s[5]:='53h3n'; s[6]:='34v2n'; s[7]:='44h2p'; s[8]:='64v3n'; s[9]:='45h2n'; s[10]:='36h3n'; end; 24: begin s[1]:='11h2n'; s[2]:='51v2n'; s[3]:='12h3n'; s[4]:='13v2n'; s[5]:='23h2n'; s[6]:='53v2n'; s[7]:='24v2n'; s[8]:='34h2p'; s[9]:='35v2n'; s[10]:='46h2n'; end; 25: begin s[1]:='21v2n'; s[2]:='41v2n'; s[3]:='51h2n'; s[4]:='12v3n'; s[5]:='52h2n'; s[6]:='23h3n'; s[7]:='53v2n'; s[8]:='63v3n'; s[9]:='24h2p'; s[10]:='15h2n'; s[11]:='35v2n'; s[12]:='16h2n'; s[13]:='56h2n'; end; 26: begin s[1]:='31v2n'; s[2]:='41h2n'; s[3]:='61v2n'; s[4]:='12v2n'; s[5]:='23h3n'; s[6]:='53v3n'; s[7]:='63v2n'; s[8]:='14v2n'; s[9]:='24h2p'; s[10]:='44v2n'; s[11]:='25v2n'; s[12]:='46h3'; end; 27: begin s[1]:='31v2n'; s[2]:='41h3n'; s[3]:='62v3n'; s[4]:='33v2n'; s[5]:='43h2n'; s[6]:='14h2p'; s[7]:='44v3n'; s[8]:='15v2n'; s[9]:='25h2n'; s[10]:='26h2n'; end; 28: begin s[1]:='11h2n'; s[2]:='31h2n'; s[3]:='61v3n'; s[4]:='12v2n'; s[5]:='22v2n'; s[6]:='32h3n'; s[7]:='33v3n'; s[8]:='43h2n'; s[9]:='14h2p'; s[10]:='45v2n'; s[11]:='55h2n'; s[12]:='16h3n'; end; 29: begin s[1]:='11h3n'; s[2]:='41v2n'; s[3]:='61v2n'; s[4]:='12v2n'; s[5]:='22h2n'; s[6]:='23h2n'; s[7]:='43h2n'; s[8]:='63v2n'; s[9]:='14h2p'; s[10]:='34v2n'; s[11]:='54v3n'; s[12]:='16h3n'; end; {30: begin s[1]:='11h2n'; s[2]:='31h2n'; s[3]:='61v3n'; s[4]:='13h2n'; s[5]:='33h2n'; s[6]:='14v3n'; s[7]:='24h2p'; s[8]:='44v2n'; s[9]:='35v2n'; s[10]:='46h3n'; end; 31: begin s[1]:='31v3n'; s[2]:='41h3n'; s[3]:='12h2n'; s[4]:='62v3n'; s[5]:='13v2n'; s[6]:='43h2n'; s[7]:='24h2p'; s[8]:='44v2n'; s[9]:='55h2h'; s[10]:='16h2n'; s[11]:='46h3n'; end; 32: begin s[1]:='11h2n'; s[2]:='41v2n'; s[3]:='61v3n'; s[4]:='12v2n'; s[5]:='23h2n'; s[6]:='43h2n'; s[7]:='14h2p'; s[8]:='34v3n'; s[9]:='45v2n'; s[10]:='16h2n'; s[11]:='56h2n'; end; 33: begin s[1]:='11h3n'; s[2]:='41v2n'; s[3]:='51v2n'; s[4]:='61v3n'; s[5]:='12v2n'; s[6]:='22h2n'; s[7]:='23h2n'; s[8]:='43h2n'; s[9]:='14h2p'; s[10]:='34v3n'; s[11]:='25v2n'; s[12]:='56h2n'; end; 34: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='41h2n'; s[4]:='42v2n'; s[5]:='52h2n'; s[6]:='13h3n'; s[7]:='53v2n'; s[8]:='63v3n'; s[9]:='14h2p'; s[10]:='44v2n'; s[11]:='15v2n'; s[12]:='46h3n'; end; 35: begin s[1]:='11h2n'; s[2]:='41v2n'; s[3]:='51v2n'; s[4]:='12v2n'; s[5]:='22h2n'; s[6]:='23h3n'; s[7]:='14h2p'; s[8]:='34v3n'; s[9]:='44v2n'; s[10]:='64v3n'; s[11]:='46h2n'; end; } 36: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='42v2n'; s[4]:='52h2n'; s[5]:='13h3n'; s[6]:='63v3n'; s[7]:='14v3n'; s[8]:='24v2n'; s[9]:='34h2p'; s[10]:='35h2n'; s[11]:='26h3n'; s[12]:='56h2n'; end; 37: begin s[1]:='11h2n'; s[2]:='41v2n'; s[3]:='51h2n'; s[4]:='12v3n'; s[5]:='52h2n'; s[6]:='23h3n'; s[7]:='53v3n'; s[8]:='63v3n'; s[9]:='24h2p'; s[10]:='15h2n'; s[11]:='35v2n'; s[12]:='16h2n'; s[13]:='56h2n'; end; 38: begin s[1]:='31v2n'; s[2]:='41h3n'; s[3]:='42h2n'; s[4]:='62v3n'; s[5]:='33v2n'; s[6]:='43h2n'; s[7]:='14h2p'; s[8]:='44v2n'; s[9]:='15v2n'; s[10]:='25h2n'; s[11]:='46h3n'; end; 39: begin s[1]:='11v2n'; s[2]:='21v2n'; s[3]:='31h2n'; s[4]:='32h2n'; s[5]:='62v3n'; s[6]:='13h2n'; s[7]:='33v2n'; s[8]:='43h2n'; s[9]:='14h2p'; s[10]:='44v2n'; s[11]:='35v2n'; s[12]:='46h3n'; end; 40: begin s[1]:='11h2n'; s[2]:='31v2n'; s[3]:='41h2n'; s[4]:='42v2n'; s[5]:='52h2n'; s[6]:='13h3n'; s[7]:='63v3n'; s[8]:='14v3n'; s[9]:='24v2n'; s[10]:='34v2n'; s[11]:='44h2p'; s[12]:='55v2n'; s[13]:='26h2n'; end; else begin s[1]:='14h2p'; s[2]:='34v2n'; end; end; initplateau:=conversion; end;
Catégories: Source | Logiciel | Pascal | Palm