Skip to content

Commit 81dc2c3

Browse files
committed
Reorg show both white/black and inverted links, naive start on Elucidation#17
1 parent f6bf070 commit 81dc2c3

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

chessbot.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,31 @@
5656
message_template = """[◕ _ ◕]^*
5757
5858
I attempted to generate a [chessboard layout]({unaligned_fen_img_link}) from the posted image,
59-
with a certainty of **{certainty:.4f}%**. *{pithy_message}*
59+
with a certainty of **{certainty:.3f}%**. *{pithy_message}*
6060
61-
* Link to [Lichess Analysis]({lichess_analysis})[^( Inverted)]({inverted_lichess_analysis}) - {to_play_full} to play
62-
* FEN: `{fen}`
61+
White to play : [Analysis]({lichess_analysis_w}) | [Editor]({lichess_editor_w})
62+
63+
* `{fen_w}`
64+
65+
Black to play : [Analysis]({lichess_analysis_b}) | [Editor]({lichess_editor_b})
66+
67+
* `{fen_b}`
68+
69+
> ▼ Links for when pieces are inverted on the board:
70+
>
71+
> *White to play : [Analysis]({inverted_lichess_analysis_w}) | [Editor]({inverted_lichess_editor_w})*
72+
>
73+
> ^(`{inverted_fen_w}`)
74+
>
75+
> *Black to play : [Analysis]({inverted_lichess_analysis_b}) | [Editor]({inverted_lichess_editor_b})*
76+
>
77+
> ^(`{inverted_fen_b}`)
6378
6479
---
6580
6681
^(Yes I am a machine learning bot | )
6782
[^(`How I work`)](http://github.com/Elucidation/tensorflow_chessbot 'Must go deeper')
68-
^( | Reply with a corrected FEN or )[^(Editor)]({lichess_editor})
69-
^(/)[^( Inverted)]({inverted_lichess_editor})^( to add to my next training dataset)
83+
^( | Reply with a corrected FEN to add to my next training dataset)
7084
7185
"""
7286

@@ -90,21 +104,31 @@ def generateMessage(fen, certainty, side):
90104
# Things that don't rely on black/white to play
91105
# FEN image link is aligned with screenshot, not side to play
92106
vals['unaligned_fen_img_link'] = 'http://www.fen-to-image.com/image/30/%s.png' % fen
93-
vals['certainty'] = certainty*100 # to percentage
107+
vals['certainty'] = certainty*100.0 # to percentage
94108
vals['pithy_message'] = getPithyMessage(certainty)
95109

96-
vals['to_play_full'] = 'White'
97110
if side == 'b':
98111
# Flip FEN if black to play, assumes image is flipped
99-
vals['to_play_full'] = 'Black'
100112
fen = invert(fen)
101113

114+
inverted_fen = invert(fen)
115+
102116
# Fill out template and return
103-
vals['fen'] = fen
104-
vals['lichess_analysis'] = 'http://www.lichess.org/analysis/%s_%s' % (fen, side)
105-
vals['lichess_editor'] = 'http://www.lichess.org/editor/%s_%s' % (fen, side)
106-
vals['inverted_lichess_analysis'] = 'http://www.lichess.org/analysis/%s_%s' % (invert(fen), side)
107-
vals['inverted_lichess_editor'] = 'http://www.lichess.org/editor/%s_%s' % (invert(fen), side)
117+
vals['fen_w'] = "%s w - -" % fen
118+
vals['fen_b'] = "%s b - -" % fen
119+
vals['inverted_fen_w'] = "%s w - -" % inverted_fen
120+
vals['inverted_fen_b'] = "%s b - -" % inverted_fen
121+
122+
vals['lichess_analysis_w'] = 'http://www.lichess.org/analysis/%s_w' % (fen)
123+
vals['lichess_analysis_b'] = 'http://www.lichess.org/analysis/%s_b' % (fen)
124+
vals['lichess_editor_w'] = 'http://www.lichess.org/editor/%s_w' % (fen)
125+
vals['lichess_editor_b'] = 'http://www.lichess.org/editor/%s_b' % (fen)
126+
127+
vals['inverted_lichess_analysis_w'] = 'http://www.lichess.org/analysis/%s_w' % (inverted_fen)
128+
vals['inverted_lichess_analysis_b'] = 'http://www.lichess.org/analysis/%s_b' % (inverted_fen)
129+
vals['inverted_lichess_editor_w'] = 'http://www.lichess.org/editor/%s_w' % (inverted_fen)
130+
vals['inverted_lichess_editor_b'] = 'http://www.lichess.org/editor/%s_b' % (inverted_fen)
131+
108132
return message_template.format(**vals)
109133

110134
# Add a little message based on certainty of response

0 commit comments

Comments
 (0)