ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

@HG: auto moveing and lift,put,drag
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Daniel Shawul



Joined: 14 Mar 2006
Posts: 2187
Location: Ethiopia

PostPost subject: Re: @HG: auto moveing and lift,put,drag    Posted: Sun May 27, 2012 11:06 pm Reply to topic Reply with quote

I implemented it now and all I can say is that it works really well. It is very easy to implement on both sides (gui & engine) and works really well. Clicking on to-squares, intermediate squares etc to make the legal root move that has that square as its destination is fun. For multi-leg captures of checkers that branch at the 3rd branch clicking on the from and destination resolves the branch. Something I forgot to mention is that this method also offers nice solution for poping up "promotion menu". It can decide to do that when it sees its moves are all promotions and tell the gui to offer the user a menu with its options. Again no decisions required from the GUI.
I was hung up on a bug for an hour or so because of a non reentrant behaviour of the referee engine thread. It was calling itself when it gets a move for the user (eg click e2e4 -> move e2e4), so I needed to call it from the GUI thread to update its moves. Console output to show the behavior I explained before. Only one command required "click" from gui to referee. It makes the move when it determines it is final, sends "illegal move" when an unreachable combo is clicked, and highlights when there are multiple options like in case of click h3.
Code:

            a b c d e f g h
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
          8 r n b q k b n r * * * * * * * * * * * * * * * * 8
          7 p p p p p p p p * * * * * * * * * * * * * * * * 7
          6 . . . . . . . . * * * * * * * * * * * * * * * * 6
          5 . . . . . . . . * * * * * * * * * * * * * * * * 5
          4 . . . . . . . . * * * * * * * * * * * * * * * * 4
          3 . . . . . . . . * * * * * * * * * * * * * * * * 3
          2 P P P P P P P P * * * * * * * * * * * * * * * * 2
          1 R N B Q K B N R * * * * * * * * * * * * * * * * 1
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
            * * * * * * * * * * * * * * * * * * * * * * * *
            a b c d e f g h

                [Material: 4900 4900 ]
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

click e4
move e2e4
click h3
highlight 8/8/8/8/8/7Y/7Y/6Y1
click h2
move h2h3
click e5
Illegal move

One additional modification is when the user changes his mind about which move he want to make. Say he clicked e2 to move to e4 (e3 & e4 will be highlighted), then he decided to make d2d4, clicking on d2 would produce an illegal move first, then when he clicks again on d2 the highlight for d2 will be produced. These two can be merged by automatically switching from moving e2 to moving d2 (i.e forgetting about previously clicked squares) when the user makes an impossible combo.
SO this removes the need for sending "illegal move". That also gave me a problem because I stopped the game when the user makes an illegal move. The human can never make an illegal move because it is the GUI's duty to make sure that don't happen. So we have now only a "move" or "highlight" as responses from the referee. The clicks will go on until the human finally makes a legal move.
Edit I guess we still need "illegal move" when the user clicks on an empty square (no squares to highlight and no legal move). But anyway it can still be used as a shortcut to make faster move selection...
_________________
https://sites.google.com/site/dshawul/
https://github.com/dshawul
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Subject Author Date/Time
@HG: auto moveing and lift,put,drag Daniel Shawul Sun May 27, 2012 3:28 pm
      Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun May 27, 2012 11:06 pm
      Re: @HG: auto moveing and lift,put,drag H.G.Muller Tue May 29, 2012 8:27 am
            Re: @HG: auto moveing and lift,put,drag Daniel Shawul Tue May 29, 2012 2:46 pm
                  Re: @HG: auto moveing and lift,put,drag H.G.Muller Tue May 29, 2012 3:36 pm
                        Re: @HG: auto moveing and lift,put,drag Daniel Shawul Tue May 29, 2012 4:23 pm
                              Re: @HG: auto moveing and lift,put,drag H.G.Muller Wed May 30, 2012 7:29 am
                                    Re: @HG: auto moveing and lift,put,drag Daniel Shawul Wed May 30, 2012 9:12 pm
                                          Re: @HG: auto moveing and lift,put,drag H.G.Muller Fri Jun 01, 2012 3:51 pm
                                                Re: @HG: auto moveing and lift,put,drag Daniel Shawul Fri Jun 01, 2012 5:07 pm
                                                      Re: @HG: auto moveing and lift,put,drag Daniel Shawul Fri Jun 01, 2012 9:10 pm
                                                      Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun Jun 03, 2012 1:27 pm
                                                            Re: @HG: auto moveing and lift,put,drag H.G.Muller Sun Jun 03, 2012 2:29 pm
                                                                  Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun Jun 03, 2012 2:46 pm
                                                                        Re: @HG: auto moveing and lift,put,drag H.G.Muller Sun Jun 03, 2012 6:13 pm
                                                                              Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun Jun 03, 2012 7:44 pm
                                                                                    Re: @HG: auto moveing and lift,put,drag H.G.Muller Mon Jun 04, 2012 4:05 am
                                                                                          Re: @HG: auto moveing and lift,put,drag Daniel Shawul Mon Jun 04, 2012 11:27 am
                                                                                          Re: @HG: auto moveing and lift,put,drag H.G.Muller Mon Jun 04, 2012 4:06 pm
                                                                                          Re: @HG: auto moveing and lift,put,drag Daniel Shawul Tue Jun 05, 2012 12:51 am
      Re: @HG: auto moveing and lift,put,drag Engin Üstün Sun Jun 03, 2012 3:49 pm
            Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun Jun 03, 2012 4:34 pm
                  Re: @HG: auto moveing and lift,put,drag Engin Üstün Sun Jun 03, 2012 5:26 pm
                        Re: @HG: auto moveing and lift,put,drag Daniel Shawul Sun Jun 03, 2012 9:46 pm
                              Re: @HG: auto moveing and lift,put,drag H.G.Muller Mon Jun 04, 2012 3:49 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads