colbyga / pychess

Automatically exported from code.google.com/p/pychess
GNU General Public License v3.0
0 stars 0 forks source link

Add "Premove" support for internet games #271

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to introduce a possibility of premove. I used to use
Winboard on Windows and it was very nice when I was playing 1 0 games.

Thanks

Original issue reported on code.google.com by Peaudepa...@gmail.com on 12 Dec 2007 at 11:02

GoogleCodeExporter commented 9 years ago
Premove is http://en.wikipedia.org/wiki/Premoving when you "does" the move 
before
it's your turn, so PyChess can reply with the move as quickly as possible, 
right?

Yup. Would be good to have.
However for 1 0 games, it is even more important to have the timelock stuff.

Original comment by lobais on 13 Dec 2007 at 6:18

GoogleCodeExporter commented 9 years ago
List of possible ways to implement premove:
    *  Automatic Premove: Refers to the capability of entering a move and having the
interface automatically play it for you.
    * Manual Premove: Refers to lifting a piece up and hovering it over a square,
dropping it as soon as you see or hear a move made.
    * Simple Premove: See Automatic Premove.
    * Semi Premove: Refers to making moves on your turn over and over until one
successfully makes it through, hopefully with a lowered loss of time.  Mainly 
used
with the older interfaces such as SLICS and CClient.
    * LR Premove: Refers to the interface LightningRulez's version of premove.  If a
capture is premoved and the piece moves away, LR will automatically nullify the
premove and allow you to make a different move. (also known as a Ghost premove)
          o Anti-ghost: Option in LightningRulez to turn LR Premove off when the user
hits a certain time level such as having only 5 seconds left in order to ensure 
that
you don't waste time with correcting Ghosts.  It can also be used to switch to 
True
premove.
    * True premove: Any premove that is made will always be made.  There is no
Ghosting that occurs.  Best known by its inclusion in some of the earlier 
versions of
the Thief interface.
    * Predrop: The capability to make a premoved drop of a piece in the House
variants (crazyhouse & bughouse).

Original comment by lobais on 14 Mar 2008 at 10:13

GoogleCodeExporter commented 9 years ago
Another way would be first to make the expected opponent move and then your 
own. Only
if the opponent then makes the expected move, will your move be completed.

Original comment by lobais on 14 Mar 2008 at 10:17

GoogleCodeExporter commented 9 years ago
Do not forget it is quite essential to display premove on board. Not that 
important
if only one premove is allowed (i. e. any other premove replaces the first 
one), but
definitely needed if more premoves allowed.
Like you can do several moves and depending on what opponent plays an app will 
try to
play your moves in order you did it and the first which can be done (is legal) 
will
be played.
The other important sub-feature is "deleting" premove.

Original comment by pe3...@gmail.com on 10 Jan 2009 at 12:50

GoogleCodeExporter commented 9 years ago
I like very well how Playchess manage this. I like the the ability to premove 
several
pieces. It is useful for example if you have 0.5 seconds remaining and an 
inevitable
check, check, check, mate. (for example mating with queen and rook)

Original comment by juanef...@gmail.com on 3 Aug 2009 at 6:07

GoogleCodeExporter commented 9 years ago
Revision 1521 adds some basic pre-move support named "Manual Premove" in 
comment 2.

Original comment by mattgatto on 12 Sep 2009 at 3:08

GoogleCodeExporter commented 9 years ago
There is a regression in trunk.
If you watch an engine versus engine game, the can drag around the pieces.

Original comment by lobais on 23 Nov 2009 at 8:12

GoogleCodeExporter commented 9 years ago
Also, all cords are currently highlighted on hover. Even if they don't contain a
movable piece.

Original comment by lobais on 23 Nov 2009 at 10:20

GoogleCodeExporter commented 9 years ago
Both of those should be fixed in revision 1551

Original comment by mattgatto on 29 Nov 2009 at 11:27

GoogleCodeExporter commented 9 years ago
The fix works great.

I think premove should be enabled in human vs. engine games as well. This 
improves
consistency and the pieces are already unlocked while the computer thinks.

Original comment by lobais on 29 Nov 2009 at 11:24

GoogleCodeExporter commented 9 years ago
It should be enabled whenever there is at least one local human player. If it's 
not, that's a bug.

Original comment by mattgatto on 30 Nov 2009 at 2:22

GoogleCodeExporter commented 9 years ago
I'm sorry you are right. I forgot what I had written in Comment #2.
In that case, I believe this request is fixed for now.

Original comment by lobais on 30 Nov 2009 at 7:30

GoogleCodeExporter commented 9 years ago
So, I'm sorry, I'm confused.  Is pre-move supported with ICS?

-john

Original comment by zollo.j...@gmail.com on 15 Feb 2010 at 5:16

GoogleCodeExporter commented 9 years ago
John, yes, it should work both on FICS and in local games too since the code is 
in BoardControl and is 
independent of what type of game it is.

Original comment by mattgatto on 15 Feb 2010 at 1:51

GoogleCodeExporter commented 9 years ago
Hey Matt, wait a minute.  Are we talking about "pre-drag" or "pre-move".  What 
I mean
is I can currently drag a piece, wait for the computer to move, then drop the 
piece
after the computer has moved.  I still cannot move a piece and drop it before my
opponent has moved.  So, it seems like PyChess supports the pre-drag or "manual"
pre-move, but does it support a true pre-move like XBoard?

Thanks Matt.

Sincerely,
John

Original comment by zollo.j...@gmail.com on 18 Feb 2010 at 4:59

GoogleCodeExporter commented 9 years ago
John: well, yes, technically it is not true full pre-move support, but would be 
better called "pre-
drag/select" support. It still is, arguably, a type of pre-move support though. 
I coded it (r1521) as the 
solution to issue 300, not this issue.

It still works fine as a temporary solution to this issue, and avoids having to 
solve all the UI difficulties 
involved in this issue (like negating a pre-move, making multiple pre-moves 
based on what move your 
opponent ends up making, etc.) while still being nearly as effective in blitz 
games, and lightning games 
to a lesser extent.

Original comment by mattgatto on 18 Feb 2010 at 5:20

GoogleCodeExporter commented 9 years ago
True, Matt.  Pre-drag is better than nothing.  I don't use true pre-move that 
often
anyway.  Thanks for informing me about this issue.  Thanks!

Keep up the good work!

Maybe we'll get to this one day!

Sincerely,
John

Original comment by zollo.j...@gmail.com on 18 Feb 2010 at 5:34

GoogleCodeExporter commented 9 years ago
I do not think any bltitz (3-0) player will take pychess seriously until and 
unless
it has premove. Considering that blitz is the most popular game in FICS, it is
unlikely that pychess would be getting more acceptance.

Original comment by pallabb...@gmail.com on 16 Apr 2010 at 9:06

GoogleCodeExporter commented 9 years ago
It's started by Donald Malmer.

Original comment by gbtami on 22 Apr 2013 at 5:58

GoogleCodeExporter commented 9 years ago
It's Dan not Donald :)

I've finished the majority of the work of basic premove functionality and 
merged to the latest version of the trunk in rev f94fabdfa1d1 of my clone: 
https://code.google.com/r/dmalmer-pychess/source/detail?r=f94fabdfa1d1b1b04a6f43
12b23100193509c5fa.

---

However, there is a MAJOR bug that will prevent this from being pulled to the 
trunk- if you premove a pawn to a promotion, the entire game freezes or crashes.

This is a strange one... for one, there are as many as 5 different errors that 
pychess spits out when it either crashes or it simply freezes up and requires a 
force quit. I’ve attached these in a text file as well as a log file from one 
of the games. Sometimes the promotion dialog will pop up and you’ll have time 
to select a piece, sometimes now. I might’ve narrow it down to happening 
around:

PromotionDialog.py, ln 38, in runAndHide(): res = self.dialog.run()
or
BoardView.py, ln 527, in runAnimation(): self.redraw_canvas(rect(paintBox))

But I’m honestly not sure and hopefully am not sending out a red herring. 
I’m pretty lost in finding a solution, so any help would be greatly 
appreciate. This is a big enough bug that the code shouldn’t be added to the 
trunk yet.

Also, premove en passants work, so I think it is an issue with the dialog box, 
not the move flag.

---

Either way, here’s how it’s working currently:

-Set premove by clicking or dragging during opponent’s turn
-Only allow premoves to be set based on valid moves after the opponent moves 
(isAPotentiallyLegalNextMove method was already created, so not much work here)
-Right-click anywhere on board to reset
-Left-click either premove cord to reset
-Able to drag other pieces while premove is set
-Setting a different premove will overwrite the previous
-If premove is invalid after opponents move, premove is reset
-Premove cords are highlighted blue, adjusted for light and dark squares
-Piece animations:
    Premove piece sits in square it will move to
    When the move is made, leave piece in that square (don’t re-animate move from original square)

And while I was in there I added documentation around the different states in 
BoardControl.py changed the LockedState name to LockedNormalState for 
consistency.

---

gbtami, in rev a2e6dc64d1ac, you added a hack to _genPossibleBoards() in 
BoardView.py to always return []. Why did you do this? I removed the return and 
everything appears to be working fine, but is there something I missed?

And just as an FYI- to test using premoves, added a sleep(7) to PyChess.py 
before it makes a make on line 163. This gives a long pause between moves for 
you to set and cancel premoves.

---

Future/to be done:
-Add preferences option to enable/disable premoves
-If premoving to capture a piece, don’t make the move if the piece is no 
longer there
    -called ‘ghosts’ and is explained in this issue
    -make this an option in the preferences as well
-Add a keyboard command to reset premoves
-Add premove ability for dropping a piece in crazyhorse (doesn’t work 
currently, but low priority)

Original comment by dmalmer on 4 May 2013 at 8:12

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry Daniel!
Great work! I will try to look into the promotion dialog bug.
The "return" in _genPossibleBoards() was my attempt to speed up pychess here 
and there a bit before. I was thinking it's useless. My mistake.

Original comment by gbtami on 4 May 2013 at 5:24

GoogleCodeExporter commented 9 years ago
Committed your work in Revision: 4b5ee1f70796.
Added some promotion handling code too.

Original comment by gbtami on 5 May 2013 at 12:37

GoogleCodeExporter commented 9 years ago
This is great! It seems to work very well in the cases I've tested.

Some things we should do before the final release however:

* The visual indication is very similar to that of selection. Do people have 
any suggestions? One way to go would be to make it look like a real move, but 
with lower opacity? That way it keeps the sort of 'shadowy effect'

* The concept might be confusing for less experienced users. If this is going 
to be enabled by default, it might be nice to have some sort of "you've made a 
premove [Hide forever]" hint come up somewhere. Actually, thinking about it, 
the same thing might be nice for the first castling and en passant the users 
sees.

Keep up the good work! The next release is going to be awesome!

Original comment by lobais on 8 May 2013 at 1:43

GoogleCodeExporter commented 9 years ago
Does the premove conditionning by the opponent move be add to pychess finally? 
(do the premove only if the opponent do the move selected)

And the multiple time premove? (for example to do a queen with pawn a6-a7-a8 en 
zeitnot)

Original comment by yoanntar on 26 Jul 2013 at 7:42

GoogleCodeExporter commented 9 years ago
Hello,

I send a new message to remember you when you will have some time to check for 
the true multiple pre-move who is a very very useful tool in Blitz as said 
mattgatto in comment #16.

Thanks you for your great job, this software is better and better.

Original comment by yoanntar on 20 Oct 2014 at 9:26