25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2024-06_memory-text-ui.md 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Title: "Memory" text UI
  2. Date: 2024-06-14 00:00
  3. Category: News
  4. Slug: memory-text-ui
  5. Lang: en
  6. # "Memory" text UI
  7. In May I implemented text UI for "Memory" game in Python. And converted it to C++
  8. by the instrument under development.
  9. Game logic cycle implementation lead to the creation of a controller that manages
  10. context. Creating the controller in Python was straightforward. C++ version took
  11. some time, because the controller needs [std::any][any], which is part of C++17.
  12. The instrument under development is limited to C++11 in order to support OpenWrt.
  13. Here's how much code I wrote (in lines):
  14. * (Python) Portable logic code: 360
  15. * (Python) Portable testing code: 565
  16. * (Python) Unportable code of controller, input/output, etc.: 350
  17. * (C++) Ported logic code: 360
  18. * (C++) Ported testing code: 586
  19. * (C++) Unportable code of controller, input/output, etc.: 565
  20. Here's the same data in per cent:
  21. | Language | Total lines of code | Portable/ported | Unportable |
  22. | --- | --- | --- | --- |
  23. | Python | 1275 (**100%**) | 925 (**72%**) | 350 (**28%**) |
  24. | C++ | 1511 (**100%**) | 946 (**62%**) | 565 (**38%**) |
  25. Thus, the development of C++ version of "Memory" game was 62% lines
  26. of code cheaper than if it would be without the instrument. Nice figures.
  27. Here's how "Memory" text UI looks like now:
  28. <iframe width="560" height="315" src="https://www.youtube.com/embed/tChSjw5W8KQ?si=WO5MYLCBhgstVshl" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
  29. # June plans
  30. I'll make a graphical UI for Python version of "Memory" game.
  31. [any]: https://en.cppreference.com/w/cpp/utility/any