⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phamster.tex

📁 数据挖掘中de一个算法 hamster的实例
💻 TEX
字号:
\documentstyle[german,a4]{article}\pagestyle{empty}\advance\topmargin-10mm\advance\textheight10mm\textwidth150mm\oddsidemargin5mm\begin{document}\begin{verbatim}{-----------------------------------------------------------------------  File    : control.p  Contents: hamster control program  Author  : Christian Borgelt  History : 24.03.1999 file created from file control.c-----------------------------------------------------------------------}UNIT control;INTERFACEUSES hamster;{-----------------------------------------------------------------------  Function Prototype-----------------------------------------------------------------------}PROCEDURE hms_ctrl (hms : HAMSTER);{-----------------------------------------------------------------------  Hamster Control Function-----------------------------------------------------------------------}IMPLEMENTATIONPROCEDURE hms_ctrl (hms : HAMSTER);VAR x, y    : INTEGER;          { coordinates of current field }    movecnt : INTEGER;          { number of moves made }    turn    : INTEGER;          { turn direction (HMS_POS/HMS_NEG) }    d       : INTEGER;          { dummy for return values }BEGIN                           { --- hamster control function }  movecnt := 0;                 { initialize the move counter }  WHILE (movecnt < 50) DO BEGIN { make 50 (field to field) moves }    hms_pos(hms, x, y);         { get current position in maze }    IF (x = 0) AND (y = 0)      { if we are at home (initial position) }    THEN d := hms_drop(hms, HC_MAXLOAD)   { drop all the corn we have }    ELSE IF (hms_corn(hms) > 0) { if there is corn on the field, take }    THEN d := hms_take(hms, HC_MAXLOAD);    { as much as we can carry }    IF (hms_look(hms) = HC_WALL)    OR_ELSE (Random(4) <= 0)    { if the way is blocked }    THEN BEGIN                  { or just because its funny, }      IF (Random(2) <= 0)       { choose a random turn direction }      THEN turn := HC_POS ELSE turn := HC_NEG;      REPEAT hms_turn(hms,turn);{ turn hamster in random direction }      UNTIL (hms_look(hms) <> HC_WALL);    END;	                { until no wall blocks the way }     d := hms_move(hms);        { move the hamster forward }    movecnt := movecnt +1;      { and count the move made }  END;END;  { hms_ctrl() }{----------------------------------------------------------------------}END.\end{verbatim}\end{document}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -