Commit graph

79 commits

Author SHA1 Message Date
ItsDrike aa446e9c43
Enforce LF through gitattributes 2024-12-07 12:55:00 +01:00
ItsDrike 4426d83438
Add editorconfig file 2024-12-07 12:53:46 +01:00
ItsDrike 9be91f0942
Remove left over unneccessary clean-up logic 2024-12-07 12:49:28 +01:00
ItsDrike 3ab8cfb7dc
Clean up GameState constructor 2024-12-07 12:34:11 +01:00
ItsDrike fdc3405366
Limit runtime for win scenario calculations
Depth limit alone often does a poor job at ensuring the simulation
doesn't take too long, as the amount of branches may differ depending on
the game and in some cases, the function can take way too long.

This solution introduces another stop condition, based on the runtime
of the evaluation, ensuring we don't block the game for too long.

Note that the original depth limiting, while fairly effective is a hacky
solution, instead, it may be a good idea to change the simulation logic
from DFS to BFS based search.
2024-12-07 12:26:47 +01:00
ItsDrike 1eb72163b5
Fix win simulation unnecessarily drawing same card 2024-12-07 12:02:55 +01:00
ItsDrike 0bee5ddc12
bug: ignore correct column for moving multiple cards 2024-12-06 18:38:25 +01:00
ItsDrike b2cad5ac14
bug: Don't reverse throwaway pile on flipping 2024-12-06 18:37:44 +01:00
ItsDrike 2b44a39ee8
slight code clean up 2024-12-06 17:09:19 +01:00
ItsDrike 18891308bc
bug: fix manual cross-column movement logic
The original implementation didn't use references for the QList
instances, which meant they were getting copied, so the changes made
didn't mutate the actual values held by the class.
2024-12-06 17:08:34 +01:00
ItsDrike 5240949353
Significantly optimize the winnability simulation
The original approach for calculating winnability first checked for
inter-column movements, which isn't ideal, instead, the new logic now
first attempts to make foundation pile movements. Additionally, this
converts the function to return an option value, which will be null if
the winnability check fails to determine the result within given maximum
depth. This is a necessary check, as the original logic took really long
to finish, especially if ran at the beginning of the game, where it
could keep going for hundreds of moves.
2024-12-06 17:04:15 +01:00
ItsDrike 2ec6206e26
Improve hash state computing
The new logic avoids possible collisions that could previously occur.
2024-12-06 17:01:24 +01:00
ItsDrike 5da97d7c0e
Add a destructor 2024-12-06 16:59:54 +01:00
ItsDrike 135d16daae
Add winnability check 2024-12-06 05:08:58 +01:00
ItsDrike eec98ba110
Return bool (success status) from drawNextCard 2024-12-06 04:54:34 +01:00
ItsDrike 206ff25a1a
Make parent the first arg in PlayingCard constructor 2024-12-06 04:33:29 +01:00
ItsDrike 03e74a6c67
Const correctness for valid move checks 2024-12-06 03:49:25 +01:00
ItsDrike 4692ce356b
Return QVariantList objects instead of QList
QML doesn't have a proper type-safe generic list type, returning QList
instances does technically work, however, qmlls (LSP) complains about
using this as it isn't a proper QML type. Instead, return QVarianList
objects, that are meant for QML.
2024-12-06 03:40:23 +01:00
ItsDrike 84a8aa57d6
Don't use deprecated SIGNAL & SLOT macros 2024-12-06 03:39:34 +01:00
ItsDrike ad690429a4
Format qml files 2024-12-05 03:24:09 +01:00
ItsDrike 36a010d5aa
Add clang-format config & format files 2024-12-05 03:06:34 +01:00
ItsDrike ddb17f8bba
Move main.cpp to src/ dir 2024-12-05 02:43:42 +01:00
ItsDrike 70bb8b36bd
Move qrc files to qml/ dir 2024-12-05 02:41:24 +01:00
ItsDrike a9a9c6fd9e
Enable strict compile flags 2024-12-05 02:34:42 +01:00
ItsDrike 3facc3333c
Don't shadow variable 2024-12-05 02:34:28 +01:00
ItsDrike 30e935b7ce
Remove left-over (fixed) bug comment 2024-12-05 02:24:55 +01:00
ItsDrike c710d0d1b3
Move source code to src/ dir 2024-12-05 01:59:15 +01:00
ItsDrike 8388a45d74
Track qml files in qrc 2024-12-05 01:47:24 +01:00
ItsDrike a49140512f
Make a more generic generate_qrc script 2024-12-05 01:28:46 +01:00
ItsDrike becb9e629d
Define CMAKE_CXX_STANDARD 2024-12-05 01:28:01 +01:00
ItsDrike 4c0437c90c
Clean up gitignore 2024-12-05 01:27:43 +01:00
ItsDrike 529753b078
Fix qmlls & clang LSP issues
This makes cmake export the qmlls.ini settings for qmlls (lang server),
which makes it aware of the C++ components used in the project. By
default, qmlls wasn't able to find these as they lived in a separate
build dir which it didn't know about.

Additionally, this also enables exporting compile commands to provide
better support for other editors that rely on these. Note that the
compile_commands.json will still only be exported into the build dir
though, so to make use of this, you'll probably want to symlink this
from the build dir.
2024-12-05 01:27:27 +01:00
ItsDrike cb75fde6d7
Move all qml files to qml/ dir 2024-12-05 01:22:18 +01:00
ItsDrike 26561ec350
Improve board design slightly 2024-12-04 20:34:29 +01:00
ItsDrike 72c4e64782
Add proper board cleanup logic
There totally weren't any memory leaks before
2024-12-04 20:34:03 +01:00
ItsDrike 7d4d139a97
Remove unnecessary spacer item 2024-12-04 19:26:32 +01:00
ItsDrike bbf1cd2eaa
Move FoundationPiles to it's own file 2024-12-04 19:26:16 +01:00
ItsDrike 44318ac5ac
Move DrawPile to it's own file 2024-12-04 19:22:20 +01:00
ItsDrike 981d724ee4
Move ThrowawayPile to it's own file 2024-12-04 19:20:06 +01:00
ItsDrike 5dd95b1a65
Separate Tableau to it's own file 2024-12-04 19:19:39 +01:00
ItsDrike 0364ae6b9e
Render a blank card if draw pile is empty 2024-12-04 19:15:27 +01:00
ItsDrike 12676e36b7
Remove unnecessary Solitare pkg QML import 2024-12-04 19:15:10 +01:00
ItsDrike 048054be13
Render a blank slot for empty column 2024-12-04 19:08:02 +01:00
ItsDrike a381288413
Manually connect the foundationChanged signal to slot
For some reason, the automatic signal-slot connection based on naming
doesn't work, call connect manually from the constructor instead.
2024-12-04 19:07:14 +01:00
ItsDrike 492f8cfec4
Add a quick function to set up a winning deck 2024-12-04 19:06:50 +01:00
ItsDrike aa611b81ed
Don't pre-draw cards 2024-12-04 18:04:19 +01:00
ItsDrike 548d36a358
clean up ensureColumnRevealed method 2024-12-04 18:03:06 +01:00
ItsDrike 5696e244f2
bug: fix col auto-move for multiple cards 2024-12-04 18:02:02 +01:00
ItsDrike 9b4c43d603
bug: QList has a copy constructor, use references 2024-12-04 18:00:45 +01:00
ItsDrike 986c2ce2be
Add support for making moves from QML 2024-12-04 00:05:29 +01:00