Origin, early history and other interesting things about robot Karel
you can read in
Introduction for this Karel implementation.
So there is my life ...
NOTE: I will translate this beginning to English later
last parts are in English
When I saw Karel program on 8-bit computers I wanted to make own one.
It is good for learning how to use divide and rule for problem solving.
But I didn't have any computer for long time and I used mainframes in my job.
Now I have computer, beautiful language (java) and time for my hobbies.
I wanted to learn some framework I could use as base of application for my hobby and
in my job. Man can't do everything alone. It is too time-consumming and it needs
some experience and skills.
I tried to use Swing Application Framework (JSR 296)
which is (JSR 296) supported in NetBeans. But its functionality wasn't enaugh and
API changed to next version.
NetBeans Platform offerd me great ground. It is robust, stabil. I can solve only
my domain part. Even, I can create my own file-type with full support.
Creating of NB modules is very good supported from version 6.
I had big plans, small knowledge an experience. So very long time...
I played with the Platform, I passed through tutorials. Next Sun and JUG (Roman)
aranged a good occasion - course about Platform. It was only two days without
practice but I enjoyed it. I thought what I could to create as homework.
All was clear in Prague but to use all in practice was more difficult.
So I joined both wishes together. I created very quickly prototype of Karel's
library to wrap it and use in NB module. (I tried to find some library but
nothing was suitable for me.) It was interesting process. It could be fain
to describe it as experience for other. And psychoanalysts could be useful
these weeks. You notice some part is bad designed. So you make refactoring.
Nothing runs. Than is a break good...
However, base functionality Karel knew. Atomic commands as step, turn left,
turn right, put sign, pick sign, regognized his direction and wall front of him
and if there is any sign under him. He parsed sipmle scripts and executed it.
He could visualise simple GUI for testing. All in English and in Czech
(including commands). Later there were some problems in module testing and JUnit
tests with Czech, so I put off it for this time.
I am sorry for poore graphics. I created pictures for buttons quickly
in MS Paint and converted to png in a batch.
After all came long awaited point. I created Library wrapper module,
Module soute and Module projects and KarelTopComponent. I added my
visualization (I will it create as service in the future.), buttons
and joined library functionality.
Next I created my file-types Karel .kar (by tutorial of course) and .kat
(for command script and for town content) and noticed
that I had wrong named TopComponent and file-type. Its right it was the first
prototype to learn platform usage.
I moved projects from one computer to other, I ommited some modules
I hadn't needed. There came difficulties by running and MultiView usage.
Library karel can write script, but NB module can't it.
Exception by Instal in target platform
java.lang.AssertionError
at org.netbeans.TopSecurityManager.register(TopSecurityManager.java:111)
at org.netbeans.core.execution.Install.restored(Install.java:110)
at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:419)
at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:340)
at org.netbeans.ModuleManager.enable(ModuleManager.java:936)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:428)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:364)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:174)
at org.netbeans.core.startup.Main.start(Main.java:325)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:110)
[catch] at java.lang.Thread.run(Thread.java:595)
It have happened yet
But Karel is running!
Procedure to run nbKarel :
Create (open) empty NB module project, Install it in target platform and than
install both .nbm modules into this NB instance.
It's running!
TODO:
Begin again karel module.
File .kar open in multiview editor (plain and tree).
Runtime of Karel to made as singleton component.
.kat file support - plain and visual
test localization by module using.
Localization edit, import, export.
Rebuild visualising as a service with defualt (karel-core) implementation.
Later use java 2D, NB Visual library, 3D (Brackeen, Java3D, JOGL).
refactoring of karel-core library
write a tutorial ? - step by step through module developing.
It could touch all areas / tutorials
Playng with artifical inteligence - e.g. labyrint, path finding.
generalize part of Karel library and visualising for re-use.
I created visual MultiView for Town .kat but I had troubles
how to synchronize text and visual view (and DataObject).
Finally I made it in TownEditorSupport notifyModified a notifyModifiedVisual,
but it was no clever. I must do it via change listeners.
It is necessary think out object and action placing.
Files for my filetypes are in filetyp package
but resolver, template, TopComponentSettings.xml and TopComponentWstcref.xml
are in base package ???????????? (for next)
I wanted place OpenTownInMainKarelComponent a OpenKarelInMainKarelComponent
to package of filetyp, but I must call to
"final class MainKarelTopComponent extends TopComponent " from base package
so it is not visible.
It is the reason why are these actions in base package.
???? Is it necessary to make inner packages for module ?
The first action in context menu of file (node) is runable by doubleclick.
So I need to order Open, OpenTownInMain and other.
Later add dragging.
NetBeans was angry when I removed modules in Suite module properties
because of dependencies.
Errors by instalation of module
How to determine which modules can be ommited?
It can open .kar a .kat in text editor.
Text and visual MultiView for .kat file.
I must repair robot initial position setting in visual view.
Synchronization of text and view is incorect although it works a little.
File is always signed as changed and requires save.
.kat a .kar are inserted in Main window and used in Karel runtime.
karel can execute commands, define new ones as classical Karel.
Not sufficiently tested, especialy recursion and complex command structures.
TODO:
(put sources under version control - Mercurial)
Change synchronization of views in Town MultiView
error and runtime messages to Output
dictionary as list later tree
v budoucnu tento tree pak použít k editaci .kar souběžně s textem
předělat KarelException na return state nebo message?
hlášení o chybách do Statusu a do Output
zobrazit slova ve slovníku jako list, později tree
v budoucnu tento tree pak použít k editaci .kar souběžně s textem
zavést include .kar
dlouhodobé TODOs ...
Questions
Jaký je zvyk, zkušenost nebo standard s nastavováním Action.isEnabled()?
1) GUI podle stavu komponent (např. zda má co spustit), popř. podle
listeneru na událost property "running" nastaví runAction.setEnabled.
2) RunAction překryje isEnabled() a bude jen testovat karel.engine.isRunning()
a super.isEnabled().
3) verze 2) + poříedí si listener na změnu property "running".
Tj. nastavuje se zvenku nebo se o sebe Action postará sama?
Podle mě se musí Action postarat sama - 3).
Made
editing Karel town .tar file as text or visual, synchronized
uses .kar and .kat files in main runtime window
get full dictionary script
show available commands in JList
TODO:
using KarelException change to return state or message?
Is this good idea?
But exceptions in other thread and libraries are caught by NB platform
and displayed in dialog window.
syntax coloring
code completion
Karel project support
runtime and error messagesto Output
editing dictionary and commands visual as a tree
add include otherdictionary.kar file to .kar (and tree)
check and test localization of module , karel-core is localized including commands
roadmap:
i18n - edit, import, run in chosen locale
i28n - script translation
build view of Karel and Town as service with default (karel-core) implementacÝ.
implement view service as java2D, NB visual library 2D,
3D (Brackeen, Java3D, JOGL).
refactoring karel-core library ?
tutorial - step by step creating of module
it shows all nb-platform skills needed for NB platform using
implementing of artifical inteligence
generalize part of karel-core library (runtime, visualization)
for general using as framework eg. tetris, patnßctku, wurfa (AI agents).
Recursion does not work.
It will be better make it after adding max deep or nesting property.
Syntax coloring of
CMDNAME4
is wrong - repaired.
Application has not its icon and splash.
Application size is 63 MB because of ommitting of
unnecessary modules is dificult (dependencies).
Command list is not sorted. Why?
Syntax coloring and code completion is made via
Manifest syntax coloring sample. Schlieman will
be tested later - it overwrote all till this time
implemented features.
TODO:
code completion 3 - result depending on previous words
indentation
saving comment lines into dictionary structure
there is an exception
using KarelException change to return state or message?
Is this good idea?
But exceptions in other thread and libraries are caught by NB platform
and displayed in dialog window.
setting max deep or nesting level for commands running
Karel project support
runtime and error messagesto Output
editing dictionary and commands visual as a tree
add include otherdictionary.kar file to .kar (and tree)
check and test localization of module , karel-core is localized including commands
Dynamic binding by command name for defined commands.
Recursion.
Sorting command list.
Updated syntax coloring.
Maximum run duration.
Added Output window. Better messages.
BUGS:
Output window covers script textarea.
But command list will be moved to navigation area.
Application size is 63 MB because of ommitting of
unnecessary modules is dificult (dependencies).
Syntax coloring and code completion is made via
Manifest syntax coloring sample. Schlieman will
be tested later - it overwrote all till this time
implemented features.
TODO:
Command list move to Navigation area and use tree.
code completion 3 - result depending on previous words
indentation
saving comment lines into dictionary structure
there is an exception
Karel project support
runtime and error messagesto Output
editing dictionary and commands visual as a tree
add include otherdictionary.kar file to .kar (and tree)
check and test localization of module , karel-core is localized including commands
Dificulties by commands tree programming.
Tree with commands is not refreshed when Main top component gets focus.
It is handled by global listener but it doesn't work.
Application (karlik) can not open files. It needs Java Project modules.
MADE
RSS added to Karel's web
Fresh modules to diretc download from web.
Explorer view for dictionary (.kar) content or Main Karel window dictionary content.
Size of application (karlik.zip) was reduced to 8.6 MB compressed and
24.5 MB decompressed by deselecting all modules and selecting
only modules which NB reported as necessary. Great!
It was simpler I supposed.
BUGS:
Output window covers script textarea.
But command list will be moved to navigation area.
Wrong icons of commands.
Syntax coloring and code completion is made via
Manifest syntax coloring sample. Schlieman will
be tested later - it overwrote all till this time
implemented features.
TODO:
Supply command list actions by tree view.
Sort commands in explorer view by name or dependention structure.
Edit commands in explorer.
code completion 3 - result depending on previous words
indentation
saving comment lines into dictionary structure
there is an exception
Karel project support
runtime and error messagesto Output
editing dictionary and commands visual as a tree
add include otherdictionary.kar file to .kar (and tree)
check and test localization of module , karel-core is localized including commands
I copied karel library project, I renamed it to "karel"
and made a little refactoring.
I left testing application in original library and I created
"KarelApp" project with simple swing application.
NOTE: I have some vision: to have base library, elementary
hard made swing application, application based on
Swing Application Framework, application based on NetBeans Platform.
I created empty Karel support module "nbKarel_core" to wrap
Karel's library to run as an application as the first step.
This version contains swing application and NBPlatform application.
NBPlatform application has all functions for running Karel in national
language. But opening/saving of script/town sources is by JFileChooser
in this time to illustrate this feature. But file-types are prepared
in the project.
MADE
Integrated Karel library, basic town view and scripts performing.
Basic actions - open and save town and script (clasic),
atomic commands, edit town.
localization
Simple .kar and .kat - Karel's script and town file type
is still not used.
Projects and directory structure was rebuild.
Czech version of page introduction.
Writing of tutorials is in progress now...
BUGS:
File-type support is not used to open/save sources
to illustrate simple implementation of actions.
Karel don't propagate changes of runState property.
TownPanel does not change its size if town is reloading to the bigger.
I played with Schliemann
language definition. Man defines tokens, grammar, code folding, navigation nodes
and code completion only by declaration.
NetBeans provides these features .
Schliemann is Great but still not supported. So I will use classic way -
GSF (General Scripting Framework) .
Jaroslav Tulach created web repositories and updated project for
continuous build. Thanks.
I did not use Schliemann for language support because it has
been under development yet and did not support my requirements.
I used Editor* modules to support Karel language.
Generic Language Framework module depends on Project modules and
I do not need Project modules.
Simple syntax coloring and code completion.
It is in Main Karel window too but it is dirty made, I think
(by setting of EditorKit into JTextPane. I want to ommit
dependencies which I do need - e.g. on Project modules.)
Favorites module was used as a files Explorer.
I tried to add disks to favorites because I am working on Windows
and Documents and Settings\user is to poor for me.
It is a little ugly by my opinion but it works.
To Do next
Better (context sensitive) code completion.
Add AST tree for scripts.
Formater and indentation and KeystrokeHandler
Multiview editor for Town files (as in 2008-10-10 release).
I added GSF modules and made them friendly for my modules.
IndentationEngine does not work.
Some classes are available in NB65 only: DefaultLanguageConfig, KeystrokeHandler.
org.xml.sax.SAXParseException: CDATA plus url= in <file>
at org.netbeans.core.startup.layers.ParsingLayerCacheManager.endElement(ParsingLayerCacheManager.java:333)
org.xml.sax.SAXParseException: Content is not allowed in prolog.
I will make some break. I tried som other technologies.
Desperade experiments and searches went to success. NetBeans Lexer works
using ANTLR lexer by syntax coloring. Antlr lexer knows different languages
but NetBeans lexer must get Locale as a parameter or it has to set language
itself by file name or lang keyword in the first commented line. Otherwise
it gets Locale.getDefault() locale.
Now I will continue working on Parser and using AST generated by ANTLR.
TODO message about uploading.
I expose soures as a zip-file only because I am not able to upload sources
to ¨mercurial work repository by SSH. See according to time.