Let's Make Robots!

MyRobotLab Plays Chess with Patrick?

Hi,

This is a blog post for PM and anyone else interested.  I have been doing many updates to mrl, and have begun working on some tutorial videos.  Patrick Mccabe and I spoke a couple times regarding hooking up his great chess robot to mrl for a game engine.  

Well, he beat me to it and found one to interface with Apple Script - but I still thought it would be fun to try.  It did not take me more than 30 mins to find, download, and wrap a chess game engine and gui with mrl.

Once the chessgame is a Service it can be loaded through the gui and integrated with other services.  In the video I show how to start it up and have it send a command string to the serial port and gui/logger.

The mrl GUI can be put into an applet so it can be played over the inter tubes too..

GroG

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Yarrg! - of course the button you need is below the screen ... isn't that how it always is ?!?!

Alright - I put the button you need at the top... I'll get to the other parts later.

Just replace the myrobotlab.jar (quick update) from here http://code.google.com/p/myrobotlab/downloads/list

 

I think I will have to try plugging my computer directly into the bot becuase I think those bad moves the engine is recieving is because of my series 2 xbees failing for some reason. I have never found their 2-way com to be reliable any way. Might have to buy some series 1 if that turns out to be the problem. How hard would it be to run this on windows? I know I said Mac, but I have a windows netbook that would work well. Dont waste your time if it takes a while. 

I do not know what caused this error.

log file sent to your email.

Last login: Thu May 12 19:35:07 on console

Patrick-Mccabes-iMac:~ patrickmccabe$ cd myrobotlab-0002

Patrick-Mccabes-iMac:myrobotlab-0002 patrickmccabe$ sh b.sh

Exception in thread "Thread-43" java.lang.ArrayIndexOutOfBoundsException: 6

at org.myrobotlab.chess.Board.attack(Unknown Source)

at org.myrobotlab.chess.Board.inCheck(Unknown Source)

at org.myrobotlab.chess.Board.makeMove(Unknown Source)

at org.myrobotlab.control.ChessGameGUI$Thinker.run(Unknown Source)

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 6

at org.myrobotlab.chess.Board.gen(Unknown Source)

at org.myrobotlab.control.ChessGameGUI.youGotToMoveItMoveIt(Unknown Source)

at org.myrobotlab.control.ChessGameGUI.vetoableChange(Unknown Source)

at java.beans.VetoableChangeSupport.fireVetoableChange(VetoableChangeSupport.java:335)

at java.beans.VetoableChangeSupport.fireVetoableChange(VetoableChangeSupport.java:252)

at javax.swing.JComponent.fireVetoableChange(JComponent.java:4483)

at org.op.chess.ChessBoard.selected(ChessBoard.java:210)

at org.op.chess.Square$SquareMouseListener.mouseClicked(Square.java:68)

at java.awt.Component.processMouseEvent(Component.java:6377)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)

at java.awt.Component.processEvent(Component.java:6139)

at java.awt.Container.processEvent(Container.java:2085)

at java.awt.Component.dispatchEventImpl(Component.java:4736)

at java.awt.Container.dispatchEventImpl(Container.java:2143)

at java.awt.Component.dispatchEvent(Component.java:4566)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4291)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)

at java.awt.Container.dispatchEventImpl(Container.java:2129)

at java.awt.Window.dispatchEventImpl(Window.java:2478)

at java.awt.Component.dispatchEvent(Component.java:4566)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680)

at java.awt.EventQueue.access$000(EventQueue.java:86)

at java.awt.EventQueue$1.run(EventQueue.java:639)

at java.awt.EventQueue$1.run(EventQueue.java:637)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)

at java.awt.EventQueue$2.run(EventQueue.java:653)

at java.awt.EventQueue$2.run(EventQueue.java:651)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:650)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

 

Found it 

 

228995 [Thread-45] INFO org.myrobotlab.control.ServiceGUI  - a2-a1q <-----------------------------------
228995 [gui_outbox] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
228995 [Thread-45] INFO org.myrobotlab.control.ServiceGUI  - a2-a1q  from 48  to 56
228995 [gui_outbox] DEBUG org.myrobotlab.framework.Outbox  - /log#null notifyList is empty
228995 [gui_outbox] DEBUG org.myrobotlab.framework.Outbox  - outbox run WAITING gui_outbox 

It ends with the piece which is putting your king in check - in this case the queen..
Part of the quirky format so far is the pre-pending of names at the beginning for non pawn moves like 
kb1-b3
Currently the code which attempt to filter some of this stuff is here
How would you like to change it?
  private String cleanMove(String t)
  {
    LOG.info(t);
 
    // remove piece descriptor
    if (t.length() == 6)
    {
      t = t.substring(1);
    }

    // remove -
    if (t.contains("-"))
    {
      t = (t.substring(0,2+ t.substring(3));
    }

    t = t.toLowerCase()
        
    return t;
  }
    

So you are saying the problem is that normally the piece descriptor is in the front, except when in check then it is in the back?

 

And I'm stickin to it.....

Previous knight move looks like this "Nd4-b3"

perhaps this is "correct chess notation" ??   I wouldn't know, I lose at go fish with my daughter....

Hmmm.. a quick peek @ the oracle - http://en.wikipedia.org/wiki/Algebraic_chess_notation  - looks like "Long Algebraic Notation"  cept .. I don't see any references to piece descriptor at the end...

Check is suppose to be +  and checkmate #

Oh well, it may not have the correct notation... but it kicked my butt... 

 

So if the last character is a  k, q, n, or whatever then the code needs to splice it off the rear, else splice it off the front I guess is what needs to be done.

In regards to promotion

it appears that the simple 4 characters e.g. a2a3  does not cut it?  

Do you want more info into the protocol?  do you need a piece name in your Arduino code? Maybe it should not be "cleaned"? At least promotion needs the additional letter - (although why wouldn't you always get a queen?)

Let me know....

It appears that check works so far. I doubt it would be promoting to anything but a queen. I think the last nut to crack is castling. I might need the piece descriptor so I know when it is castling unless you have an idea. I still do not quite know what the castling notation looks like, but it did not blow up your code when it happened.