13.07.2015 Views

The PowerPC 604 RISC Microprocessor - eisber.net

The PowerPC 604 RISC Microprocessor - eisber.net

The PowerPC 604 RISC Microprocessor - eisber.net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Printed by andi from a0.complang.tuwien.ac.atMar 29 1996 16:42 Karel<strong>The</strong>Robot.java Page 5instruction • program;DackBuffer.resetll:DefineNode reset();IterateNode.reset41;ch ■ 'c';while ((error instruction.exec_step()) - *orld.lengthlx ■ world length - 1;KarelsWorld.x • x;if (y < 0)y • 0;it (y >• world(0).1ength)y world(0).1ength - 1;KarelsWorld.y • y;Karelsworld.facing ■ facing_north;it ((facing facing_north) II(facing (acing_east)(facing facing_nouth)(facing facing_west11KarelsWorld.facing - facing;static void fill_bag(int count) (if (count < 0)count • 0:bag • count:private static boolean position_out_of_boundslint x. int y)if ((x < 0) II (x >. world.length) 11return true;return false;static void set_north_wall(int x. int y) (if (position_out_of_boundslx, y))return;world(x)(y) I. north_wall;static void set_east_wall(int x, int yl ((Y < 0) II (y >° world(0).1ength11static boolean test(int test)switch (test) (case front_is_clear:switch (facing)(case facing_north:return ((world(x)ly1 & north_wall) 0):case facing_enst:return ((world(x)(Y1 & eent_well) n. 01:case facing_south:if (y 0)return false;return (Iworld(x)(y-1) & north_wall) 01:case facing_west:if (x 0)return false;return ((world(x-1)(y) & east_wall) 0);break;case left_is_clear:switch (facing))case facing_north:if (x 0)return false;return ((worldlx-1((Y) & east_wall) 01:case facing_east:return ((world(x)(y) & north_wall) 01:case facing_south:return ((world(x)(y) G east_well) 0);case facing_west,if (y 0)return false;return ((world(x)(y-1) & north_well) 0);break;case right_is_clear:switch (facing)(case facing_north:return ((world(x)(y) & east_wall) 0),case facing_east:if (y om 01return false;return ((world(x)(y-1) & north_wall) == 01)case facing_south:if (x -- 01return false;return Ilworld(x-11(Y 1 & east_wall) 0):case facing_west:return lIworld(x)iy) & north_wall) -- 0).break;cone next_to_a_beeper:return ((world(x)(y) >» 2) > 0);Karol<strong>The</strong>Robot.java

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!