zkt25/manual.html

107 lines
4.3 KiB
HTML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Karel Simulator — User Manual</title>
<style>
body {
background: #121212;
color: #e0e0e0;
font-family: monospace;
padding: 20px;
max-width: 800px;
margin: auto;
line-height: 1.4;
}
h1,h2 { color: #0f0; }
a { color: #0f0; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #1e1e1e; padding: 2px 4px; border-radius: 3px; }
pre { background: #1e1e1e; padding: 10px; border-radius: 4px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { border: 1px solid #2a2a2a; padding: 6px; text-align: left; }
th { background: #1e1e1e; }
</style>
</head>
<body>
<h1>Karel the Robot Quick-Start User Guide</h1>
<h2>1. What Is Karel?</h2>
<p>
Karel lives in a 2-D grid (“world”) of square cells.
He can face North/East/South/West, move one cell at a time,
pick up or put down “beepers,” and detect walls.
</p>
<h2>2. Simulator Interface</h2>
<ul>
<li><strong>Code Editor</strong>: Write your program here.</li>
<li><strong>Compile &amp; Run</strong>: Lex, parse, and execute step-by-step.</li>
<li><strong>Stop</strong>: Immediately halt execution (for infinite loops).</li>
<li><strong>Console</strong>: Logs moves, errors, and debug messages.</li>
<li><strong>Upload Map</strong>: Load a <code>.txt</code> or <code>.kw</code> world file.</li>
<li><strong>Map View</strong>: ASCII display of walls (red), beepers, and Karel (green).</li>
<li><strong>Manual Editor</strong>: Draw your own world, then import it.</li>
</ul>
<h2>3. Syntax Essentials</h2>
<ul>
<li>Every statement ends with a semicolon <code>;</code>.</li>
<li>Every command or condition <strong>must</strong> have parentheses <code>()</code>.</li>
<li>Use <code>if (…){…} [else{…}]</code> and <code>while (…){…}</code>.</li>
<li>Comments begin with <code>//</code>.</li>
</ul>
<h2>4. Built-in Commands</h2>
<h3>Movement</h3>
<table>
<tr><th>Command</th><th>Effect</th></tr>
<tr><td><code>move()</code></td><td>Step forward if no wall ahead.</td></tr>
<tr><td><code>turnLeft()</code></td><td>Rotate 90° counter-clockwise.</td></tr>
</table>
<h3>Beeper Handling</h3>
<table>
<tr><th>Command</th><th>Effect</th></tr>
<tr><td><code>pickBeeper()</code></td><td>Pick one beeper from current cell.</td></tr>
<tr><td><code>putBeeper()</code></td><td>Place one beeper into current cell.</td></tr>
</table>
<h3>Sensors &amp; Conditions</h3>
<table>
<tr><th>Condition</th><th>True When…</th></tr>
<tr><td><code>frontIsClear()</code></td><td>No wall immediately in front.</td></tr>
<tr><td><code>frontIsBlocked()</code></td><td>Wall immediately in front.</td></tr>
<tr><td><code>leftIsClear()</code></td><td>No wall on Karels left.</td></tr>
<tr><td><code>leftIsBlocked()</code></td><td>Wall on Karels left.</td></tr>
<tr><td><code>rightIsClear()</code></td><td>No wall on Karels right.</td></tr>
<tr><td><code>rightIsBlocked()</code></td><td>Wall on Karels right.</td></tr>
<tr><td><code>nextToABeeper()</code></td><td>One or more beepers in this cell.</td></tr>
<tr><td><code>notNextToABeeper()</code></td><td>No beepers in this cell.</td></tr>
<tr><td><code>facingNorth()</code>, <code>facingEast()</code>, …</td>
<td>Karels orientation matches the named direction.</td></tr>
<tr><td><code>anyBeepersInBeeperBag()</code></td><td>Bag contains ≥ 1 beeper.</td></tr>
<tr><td><code>noBeepersInBeeperBag()</code></td><td>Bag is empty.</td></tr>
</table>
<h2>5. Example</h2>
<pre><code>while ( notNextToABeeper() ) {
move();
}
pickBeeper();
turnLeft();
move();
putBeeper();</code></pre>
<h2>6. Tips</h2>
<ul>
<li>Sketch Karels path on graph paper first.</li>
<li>Always check <code>frontIsClear()</code> before <code>move()</code>.</li>
<li>Use the <strong>Stop</strong> button to escape accidental infinite loops.</li>
<li>Combine <code>if</code> and <code>while</code> for complex behaviors.</li>
</ul>
<p><a href="index.html" style="color:#0f0;">← Back to Simulator</a></p>
</body>
</html>