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

📄 ehamster.tex

📁 数据挖掘中de一个算法 hamster的实例
💻 TEX
字号:
\documentstyle[german,a4]{article}\pagestyle{empty}\advance\topmargin-10mm\advance\textheight10mm\textwidth150mm\oddsidemargin5mm\begin{document}\begin{verbatim}----------------------------------------------------------------------------- File    : control.e-- Contents: customized hamster control class-- Authors : Ilona Bl"umel and Christian Borgelt-- History : 11.03.1999 file created---------------------------------------------------------------------------class CONTROLinherit CLIENT  redefine controlendcreation  make----------------------------------------------------------------------------- Methods--------------------------------------------------------------------------- feature                   control (hamster: HAMSTER) is   -- hamster control function (random)local  movecnt: INTEGER;             -- number of moves made  turn   : INTEGER;             -- turn direction (left/right)  d      : INTEGER;             -- dummy variable for resultsdo  from    movecnt := 0;               -- initialize the move counter  until    movecnt = 50                -- make 50 field to field moves  loop    if     hamster.get_x = 0    -- if we are at home (initial position),    and    hamster.get_y = 0    -- drop all the corn we have    then   d := hamster.drop(hamster.max_load);    elseif hamster.get_corn > 0 -- if there is corn on the field    then   d := hamster.take(hamster.max_load);    end                         -- take as much as he can carry    if hamster.get_look = hamster.wall  -- if the way is blocked    or else random(4) <= 1      -- or just because it's funny (25%)    then if random(2) <= 1      -- randomly choose a turn direction         then turn := hamster.left;         else turn := hamster.right;         end                    -- (50% either way)         from           hamster.turn(turn);  -- turn the hamster         until                  -- in the chosen direction           hamster.get_look /= hamster.wall         loop                   -- repeat turning the hamster around           hamster.turn(turn);  -- until no wall blocks the way         end    end    d := hamster.move;          -- move the hamster forward    movecnt := movecnt +1;      -- and count the move made  endend  -- control------------------------------------------------------------------------end  -- CONTROL\end{verbatim}\end{document}

⌨️ 快捷键说明

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