Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand on DemoReplayStrategy #24 #56

Closed
wants to merge 6 commits into from
Closed

Conversation

dianzrong
Copy link
Collaborator

@dianzrong dianzrong commented May 1, 2023

Summary (#24):
This pull request summarized the OCR text of the current and previous screenshots. Then, the summaries are compared, to see if the screen has changed. The change is then noted in the prompt.

Assumptions:
The screen can summarized by 1 word. This may not be true for more complex screens such as those with multiple windows open simultaneously.

External Libraries:

  • Gensim
  • NLTK

Next Steps:

  • testing
  • creating a helper function to compare screenshots (including summarizing screenshots) to have cleaner and more readable code

@abrichr
Copy link
Member

abrichr commented May 2, 2023

Thank you @dianzrong ! Can you please add instructions as per #33 (comment), e.g.

git remote add dianzrong https://github.com/dianzrong/puterbot.git
git fetch dianzrong
# what goes here to run your code? please create a branch update your PR to merge from that branch, e.g.:
git checkout feat/<your-feature-name>
pip install -r requirements.txt  # please add gensim here
python -m ...  # please fill this in

If I run:

git checkout dianzrong/main  # we don't want this because we end up in detached head state, please create a branch like I specified above
pip install -r requirements.txt
python -m puterbot.replay DemoReplayStrategy

I get:

2023-05-01 21:44:29.413 | INFO     | __main__:replay:19 - strategy_name='DemoReplayStrategy'
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/replay.py", line 43, in <module>
    fire.Fire(replay)
  File "/Users/abrichr/MLDSAI/src/puterbot/.venv/lib/python3.10/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/abrichr/MLDSAI/src/puterbot/.venv/lib/python3.10/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/Users/abrichr/MLDSAI/src/puterbot/.venv/lib/python3.10/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/replay.py", line 21, in replay
    strategy_class_by_name = get_strategy_class_by_name()
  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/utils.py", line 375, in get_strategy_class_by_name
    from puterbot.strategies import BaseReplayStrategy
  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/strategies/__init__.py", line 3, in <module>
    from puterbot.strategies.demo import DemoReplayStrategy
  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/strategies/demo.py", line 22, in <module>
    from gensim.summarization.summarizer import summarize
ModuleNotFoundError: No module named 'gensim'

@abrichr abrichr mentioned this pull request May 2, 2023
@abrichr
Copy link
Member

abrichr commented May 2, 2023

@dianzrong thank you for the great work! Please grab some time on my calendar at your earliest convenience on Weds/Thurs this week: https://www.getclockwise.com/c/richard-abrich/quick-meeting

@abrichr
Copy link
Member

abrichr commented May 2, 2023

@dianzrong if I run pip install gensim I get:

  File "/Users/abrichr/MLDSAI/src/puterbot/puterbot/strategies/demo.py", line 22, in <module>
    from gensim.summarization.summarizer import summarize
ModuleNotFoundError: No module named 'gensim.summarization'

What version of gensim did you install?

@abrichr
Copy link
Member

abrichr commented May 2, 2023

@dianzrong can you please comment on your approach? i.e. why did you choose to implement this:

            last_summarized_ascii = summarize(self.get_ascii_text(last_screenshot), word_count=1,
                                              split=False)
            last_summarized_ocr = summarize(self.get_ocr_text(last_screenshot), word_count=1,
                                            split=False)

Can you please show some examples of pairs of raw and summarized ascii/ocr? Thank you! 🙏

@dianzrong
Copy link
Collaborator Author

@abrichr Thank you for your comments. I used gensim==3.8.2 as gensim.summarization was removed in later versions. However, I just noticed this relies on out of date Python functions so I will implement the summarization a different way.

@dianzrong
Copy link
Collaborator Author

dianzrong commented May 2, 2023

@abrichr After implementing it differently, I have the following output. The ASCII doesn't read text very well so my implementation of it doesn't seem very useful.

ASCII:

)s7<{!I?r\ls>i**)xIs<vr?[v%I**{{c\*!}IiiIl<ls??%i{}c<>><ii)vivi<>><xviiiii<>><xi)iii><)<<i<iiiv)<)<)<)%%vvv>v>\v<\<\\<>\
vlscrllr%vxvxccrlclx%xv{?xrccc%%%v*Ixlxcc%%%vssxlcv%vvvicc%c%cxvvvi{l%xxcxv%vv*l%xxx%i%vixvxxxc%i%vlcs{****?*{cllc%sx%xv
{!*{}{I[{lIr?!!?!}I?}**{{*********{r{{*{s****r{{*sxcccccxxcxxxcccccxxcccccccccxxccccccccccccccxccccxc*cr*l}n*!a{oa?j?*I{
{e[!!*e][1!st1I!]*r{{[![]{[t?!s!e?1]so1?!1[I*o?!1![[{!?![[[11?s{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ss{{ssrrsrrsrlrss{ss{s{{{{
/""///""/"i</\{cv%rlcxl%)""i)%cx</""\\\\\)\)""\)\""\|)|))\)\\/|\)\))/|))))"/))))"/""/////////)<<)/ir{{s{sssssx"/////////
<<<<<<<<<<{c\)?]!}[[[[]]i><riI!?l\<<%%%v%%%%<<v%%><%v%vvv%%%%<)%%%%x<)%%%%)\v%%%><>>\<<<<<<<\%{r%\r[eeaaettttI><<<<<<<<<
BBBBBBBBBBDDBBDDDDDDDDDDBBBDBDDH$K@KK@@@@@DKHKDBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBDDBBBDDDDDDDDDDBBBBBBBBBBB
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ0DWBWWBBBBBRNNBRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR0QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ0000QQ0QQ000000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xi)iii><)<<i<iiiv)<)<)<)%%vvv>v>\v<\<\\<>\ vlscrllr%vxvxccrlclx%xvs?%llccx%xv*Ixlxcc%%%vs{xlcv%vvvicc%c%cxvvvi{l%xxcxv%vv*l%xxx%i%vixvxxxc%i%vlcs{****?

OCR:

File
Edit
Window
View
Code
Run
PyCharm
Help
Cxparu un
Seaicliesu
nsu-eca
oruu, Un
Quick Iveeli
DcKI (aliyu
sullly - ccus
suy_spac
theathletic.com/4481801/2023/05/02/conn-smythe-draisaitl-marner/
Uni
Code stuff
Books
Fun
To Watch
Bell Virtual Repair
Future
Save
Olympics
The Athletic
NHL
Scores & Schedule
Playoff Bracket
Teams
Standings
Podcasts
Subscribe for s$2
Fantasy
Log In
By Dom Luszczyszyn 2h ago
The opening round is in the books and what a treat it was in terms of the
predictable chaos the NHL specializes in.
Six of eight favorites may have won, but the two that lost were the two most
expected to win: the best regular-season team of all time and the defending
Stanley Cup champions. Stunning.
That's left a relatively wide-open remaining field where it does truly feel like
any team could win. From those teams have come some incredible opening-
round performances and the goal here is to highlight who each team's MVP is
so far as we take stock into the Conn Smythe trophy race.
It's still early with three rounds to go, but after one round, here's who's
headlining “Conn Smythe Watch" for each team (and some other names to
consider too).
Data as of May 2
We use cookies and related technology to optimize your experience. Some cookies are essential to make our website work, while others, like analytics cookies, help
Manage Cookies
Accept & Continue
us track your interaction and improve your online experience. Please see our Cookie Policy. for more information.

Summarized OCR:

Scores & Schedule Playoff Bracket Teams Standings Podcasts Subscribe for $2 Fantasy Log In By Dom Luszczyszyn 2h ago The opening round is in the books and what a treat it was in terms of the predictable chaos the NHL specializes in.

@abrichr
Copy link
Member

abrichr commented May 2, 2023

Excellent work! Can you please refactor this into a SummaryReplayStrategyMixin, e.g. in strategies/summary with a get_summary method?

@abrichr
Copy link
Member

abrichr commented May 2, 2023

What is next here?

@dianzrong dianzrong closed this May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants