For my own use Swift 2 Wrote a rudimentary Karel Robot

Screenshot 2015-08-22 10.36.04 PM

Update it!

This update adds a branch,Goal is to create the "Next" function,In addition to repair the ugly side of the white block interface!

Currently no more modifications,run.swift file more refreshing,No more double thread it!

With an array of state of static storage Karel,Thanks for the banana king!

Adjust the speed of the great dream is within reach!?


 

Write the software I spent a total of 11 hours,Intermediate pit live countless times。And now I do not know why it can achieve multi-queue pause,Do not know why this stock can not adjust the speed ......

Stop button is invalid,I think one is not need it,Another is I can not do?

The most difficult thing is to how to move Karel,Point is that to solve this problem

You can not rely on storyboard,The key moment will have to use the code to draw View!

After coordinate how to solve this problem in a predetermined drop Beeper became puzzles! Finally, I simply lamb,Code to be filled with pictures Beeper! Then hide,She made an array,Which is displayed with which ..................

This egg pain algorithm afraid it was only myself!


All right,Here to introduce the usage of this thing right!

Karel for learning Java,I will find time alone to write an article to say something about its history,Here, I would say first direct usage:

Karel is a robot,Only the most simple instructions:

  • move forward
  • turnLeft left
  • putBeeper put a mark
  • pickBeeper picked up a marker

Due to my limited level,So I can not let you do it in a separate file in writing these instructions,You can only be in a position reserved for me to write it?

Other,Since the issue of the queue,In fact, you write the code basically looks like this:

Use the slider at the bottom of the window,The default is left in the fast mode,Allowing you to directly see the results;On the right is one second a motion,Allowing you to look at the process。

I noted a map initialization code,You should be able to find the following section in the Karel.swift:

All right,After I somehow git I'll be here Paste Link

I finally successfully created git directory,You can go toHereView

 

Original article written by LogStudio:R0uter's Blog » For my own use Swift 2 Wrote a rudimentary Karel Robot

Reproduced Please keep the source and description link:https://www.logcg.com/archives/1088.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *