Commit Graph

40399 Commits

Author SHA1 Message Date
Lucas CHOLLET
351fc0cce2 ChessEngine: Use reduced Board objects in MCTSTree
Monte-Carlo methods are known to intensively create nodes and in our
case each leaf of the tree stores a board. However, for this use case,
we don't need a full board object that also contains game information.

This patch adds a `clone_cleared()` method that return a clone without
game information and uses it when constructing the tree.
It allows the ChessEngine much more possibility before getting out of
memory.
2022-08-22 21:20:41 +02:00
Lucas CHOLLET
5f13a87ce7 ChessEngine: Limit MCTSTree expansion
This method temperate the habit of Monte-Carlo based algorithms to
repeatedly create new nodes.

It was first implemented in `Efficient Selectivity and Backup Operators
in Monte-Carlo Tree Search` by Rémi Coulom.
2022-08-22 21:20:41 +02:00
Andreas Kling
4c081e0479 Kernel/x86: Protect the CR3->PD map with a spinlock
This can be accessed from multiple CPUs at the same time, so relying on
the interrupt flag is clearly insufficient.
2022-08-22 17:56:03 +02:00
Andreas Kling
6cd3695761 Kernel: Stop taking MM lock while using regular quickmaps
You're still required to disable interrupts though, as the mappings are
per-CPU. This exposed the fact that our CR3 lookup map is insufficiently
protected (but we'll address that in a separate commit.)
2022-08-22 17:56:03 +02:00
Andreas Kling
c8375c51ff Kernel: Stop taking MM lock while using PD/PT quickmaps
This is no longer required as these quickmaps are now per-CPU. :^)
2022-08-22 17:56:03 +02:00
Andreas Kling
a838fdfd88 Kernel: Make the page table quickmaps per-CPU
While the "regular" quickmap (used to temporarily map a physical page
at a known address for quick access) has been per-CPU for a while,
we also have the PD (page directory) and PT (page table) quickmaps
used by the memory management code to edit page tables. These have been
global, which meant that SMP systems had to keep fighting over them.

This patch makes *all* quickmaps per-CPU. We reserve virtual addresses
for up to 64 CPUs worth of quickmaps for now.

Note that all quickmaps are still protected by the MM lock, and we'll
have to fix that too, before seeing any real throughput improvements.
2022-08-22 17:56:03 +02:00
Andreas Kling
930dedfbd8 Kernel: Make sys$utime() and sys$utimensat() not take the big lock 2022-08-22 17:56:03 +02:00
Andreas Kling
280694bb46 Kernel: Update atime/ctime/mtime timestamps atomically
Instead of having three separate APIs (one for each timestamp),
there's now only Inode::update_timestamps() and it takes 3x optional
timestamps. The non-empty timestamps are updated while holding the inode
mutex, and the outside world no longer has to look at intermediate
timestamp states.
2022-08-22 17:56:03 +02:00
Andreas Kling
35b2e9c663 Kernel: Make sys$mknod() not take the big lock 2022-08-22 17:56:03 +02:00
Timothy Flynn
d86b25c460 Meta: Move downloading of emoji-test.txt to unicode_data.cmake
The current emoji_txt.cmake does not handle download errors (which were
a common source of issues in the build problems channel) or Unicode
versioning. These are both handled by unicode_data.cmake. Move the
download to unicode_data.cmake so that we can more easily handle next
month's Unicode 15 release.
2022-08-22 16:00:29 +01:00
Sam Atkins
cde4552710 GamesSettings: Add a preview for the current card-game settings :^) 2022-08-22 12:50:41 +02:00
Sam Atkins
deeef8c412 GamesSettings: Add a setting for the card-back image
And also add a couple of images so there's more than one option. :^)

(My yak silhouette isn't very good, so please replace that, artists!)
2022-08-22 12:50:41 +02:00
Sam Atkins
435e53fcfe LibCards: Remove card-back-image scaling
This was giving wonky results with images that do not fill the entire
card - and it's also unnecessary, since the Buggie image we have been
using, and the two I will be adding, are all small enough to not need
scaling anyway. :^)
2022-08-22 12:50:41 +02:00
Sam Atkins
40b1428194 LibCards: Make the card back image configurable
`CardPainter::set_background_image_path()` immediately repaints the card
back and inverted card back bitmaps if they exist, so users just need
to `update()` that part of the screen. This is handled automatically by
`CardGame`, but other users will have to do this manually.
2022-08-22 12:50:41 +02:00
Sam Atkins
7f46d31849 LibCards: Centralise card bitmap creation
Instead of each card being responsible for painting its own bitmaps, we
now have a CardPainter which is responsible for this. It paints a given
card the first time it is requested, and then re-uses that bitmap when
requested in the future. This saves memory for duplicate cards (such as
in Spider where several sets of the same suit are used) or unused ones
(for example, the inverted cards which are only used by Hearts). It
also means we don't throw away bitmaps and then re-create identical
ones when starting a new game.

We get some nice memory savings from this:

|           | Before   | After    | Before (Virtual) | After (Virtual) |
|:----------|---------:|---------:|-----------------:|----------------:|
| Hearts    | 12.2 MiB |  9.3 MiB |         25.1 MiB |        22.2 MiB |
| Spider    | 12.1 MiB | 10.1 MiB |         29.2 MiB |        22.9 MiB |
| Solitaire | 16.4 MiB |  9.0 MiB |         25.0 MiB |        21.9 MiB |

All these measurements taken from x86_64 build, from a fresh launch of
each game after the animation has finished, but without making any
moves. The Hearts value will go up once inverted cards start being
requested.
2022-08-22 12:50:41 +02:00
Sam Atkins
aac2488d5c LibCards+Games: Replace card "value" int with a Rank enum
Because `card->value() == 11` is a lot less clear than `card->rank() ==
Cards::Rank::Queen`, and also safer.

Put this, along with the `Suit` enum, in the `Cards` namespace directly
instead of inside `Cards::Card`. Slightly less typing that way.
2022-08-22 12:50:41 +02:00
Sam Atkins
163a74e3e2 Spider: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
c709dc154f Hearts: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
f9f25271b3 Solitaire: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
c5b7ad6004 LibCards: Add a CardGame base class
For now, the only feature of this is that it sets the background colour
from the `Games::Cards::BackgroundColor` config value. Later, other
card game configuration and shared behaviour can go here, to save
duplicating it in each game.
2022-08-22 12:50:41 +02:00
Sam Atkins
a01c4c50d1 GamesSettings: Introduce a new GamesSettings application :^)
This currently has exactly one setting: The background colour for card
games. My thinking is, it's better to not have a Settings application
for each individual game we include in the system, since most will only
have a small number of settings, all Settings windows have tabs anyway,
and I don't want to flood the Settings app list unnecessarily.

As for having a single setting for all the card games: it's nice when
things match. :^)
2022-08-22 12:50:41 +02:00
Sam Atkins
0737d217cb Base: Add a 32x32 version of the Games icon 2022-08-22 12:50:41 +02:00
Roberto Bampi
1c52ca9693 PixelPaint: Push layer creation onto the undo stack
Before this change, creating a layer, painting something on it and
undoing would delete the layer as well as the paint on it.
2022-08-22 12:49:11 +02:00
Jannis Weis
8fa34b43ce HexEditor: Fix utf16 validation
Previously the utf8_view was validated for the utf16 valude instead
of the utf16_view.
2022-08-22 12:48:47 +02:00
Jannis Weis
32205495e6 LibGUI: Clear selected index of Breadcrumbbar if segment is removed
If the segment corresponding to the selected index is removed the index
is no longer valid.
2022-08-22 12:48:11 +02:00
Jannis Weis
3911758277 FileManager: Disable open_child_directory_action if no child exists 2022-08-22 12:48:11 +02:00
Jannis Weis
8b395ffcc5 FileManager: Respond to all selection changes in the Breadcrumbbar
Use Breadcrumbbars on_segment_change instead of on_segment_click.
This allows us to remove the manual handler invokation in the
open_child_directory_action
2022-08-22 12:48:11 +02:00
Jannis Weis
a00fa793b3 LibGUI: Add on_segment_change handler to Breadcrumbbar
This allows programs to respond to any selection changes of the
Breadcrumbbar, not just ones made by clicking one of the buttons.
2022-08-22 12:48:11 +02:00
Anthony Iacono
f86b671de2 Kernel: Use Process::credentials() and remove user ID/group ID helpers
Move away from using the group ID/user ID helpers in the process to
allow for us to take advantage of the immutable credentials instead.
2022-08-22 12:46:32 +02:00
Skye Sprung
8026d8926c Documentation: Change spelling error in CLionConfiguration.md
Change "want exclude" to "want to exclude"
2022-08-22 08:48:29 +01:00
Xexxa
0335829e71 Base: Add more emoji
> #️⃣ - U+23 U+FE0F U+20E3 Keycap Number Sign
*️⃣ - U+2A U+FE0F U+20E3 Keycap Asterisk
0️⃣ - U+30 U+FE0F U+20E3 Keycap Digit Zero
1️⃣ - U+31 U+FE0F U+20E3 Keycap Digit One
2️⃣ - U+32 U+FE0F U+20E3 Keycap Digit Two
3️⃣ - U+33 U+FE0F U+20E3 Keycap Digit Three
4️⃣ - U+34 U+FE0F U+20E3 Keycap Digit Four
5️⃣ - U+35 U+FE0F U+20E3 Keycap Digit Five
6️⃣ - U+36 U+FE0F U+20E3 Keycap Digit Six
7️⃣ - U+37 U+FE0F U+20E3 Keycap Digit Seven
8️⃣ - U+38 U+FE0F U+20E3 Keycap Digit Eight
9️⃣ - U+39 U+FE0F U+20E3 Keycap Digit Nine
🇨🇲 - U+1F1E8 U+1F1F2 CM Cameroon
🇳🇵 - U+1F1F3 U+1F1F5 NP Nepal
🇲🇲 - U+1F1F2 U+1F1F2 MM Myanmar (Burma)
🇧🇧 - U+1F1E7 U+1F1E7 BB Barbados
🇬🇼 - U+1F1EC U+1F1FC GW Guinea-Bissau
🇹🇬 - U+1F1F9 U+1F1EC TG Togo
🇸🇴 - U+1F1F8 U+1F1F4 SO Somalia
🇦🇼 - U+1F1E6 U+1F1FC AW Aruba
💈 - U+1F488 Barber Pole
📯 - U+1F4EF Postal Horn
🥫 - U+1F96B Canned Food
🪓 - U+1FA93 Axe
🧀 - U+1F9C0 Cheese Wedge
 - U+2614 Umbrella with Rain Drops
🧨 - U+1F9E8 Firecracker
⛸️ - U+26F8 U+FE0F Ice Skate
🪧 - U+1FAA7 Placard
🇯🇪 - U+1F1EF U+1F1EA JE Jersey
🪨 - U+1FAA8 Rock
📮 - U+1F4EE Postbox
🇻🇨 - U+1F1FB U+1F1E8 VC St. Vincent & Grenadines
2022-08-22 08:43:06 +01:00
Ryan Liptak
221d9089e9 Meta: Generate emoji.txt at build time from Unicode's emoji-test.txt
Instead of manually updating emoji.txt whenever new emoji are added,
we use Unicode's emoji-test.txt to generate emoji.txt on each build,
including only the emojis that Serenity supports at that time.

By using emoji-test.txt, we can also include all forms of each emoji
(fully-qualified, minimally-qualified, and unqualified) which can be
helpful when double-checking how certain forms are handled.
2022-08-22 08:42:54 +01:00
Ryan Liptak
8f4317e207 Base: Move Serenity-specific emoji from emoji.txt to emoji-serenity.txt 2022-08-22 08:42:54 +01:00
Andreas Kling
bf25b0a0b5 PixelPaint: Show more specific Undo/Redo action text
The Undo/Redo actions now tell you what kind of action will be
undone/redone. This is achieved by adding an "action text" field to the
ImageUndoCommand and having everyone who calls did_complete_action()
provide this text.
2022-08-21 20:33:03 +02:00
Andreas Kling
101eb53de5 PixelPaint: Add Tool::tool_name() as a single-point-of-truth
Let the tools know what their names are.
2022-08-21 20:33:01 +02:00
Andreas Kling
c45f99f735 PixelPaint: Make Filter::filter_name() const 2022-08-21 20:19:59 +02:00
Andreas Kling
17687435ca WindowServer: Redraw menu items after client updates them somehow
This fixes an issue where the undo/redo actions in TextEditor only
updated once you hovered over them.
2022-08-21 20:04:33 +02:00
Andreas Kling
42435ce5e4 Kernel: Make sys$recvfrom() with MSG_DONTWAIT not so racy
Instead of temporary changing the open file description's "blocking"
flag while doing a non-waiting recvfrom, we instead plumb the currently
wanted blocking behavior all the way through to the underlying socket.
2022-08-21 16:45:42 +02:00
Andreas Kling
8997c6a4d1 Kernel: Make Socket::connect() take credentials as input 2022-08-21 16:35:03 +02:00
Andreas Kling
51318d51a4 Kernel: Make Socket::bind() take credentials as input 2022-08-21 16:33:09 +02:00
Andreas Kling
8d0bd3f225 Kernel: Make LocalSocket do chown/chmod through VFS
This ensures that all the permissions checks are made against the
provided credentials. Previously we were just calling through directly
to the inode setters, which did no security checks!
2022-08-21 16:22:34 +02:00
Andreas Kling
dbe182f1c6 Kernel: Make Inode::resolve_as_link() take credentials as input 2022-08-21 16:17:13 +02:00
Andreas Kling
006f753647 Kernel: Make File::{chown,chmod} take credentials as input
...instead of getting them from Process::current(). :^)
2022-08-21 16:15:29 +02:00
Andreas Kling
c3351d4b9f Kernel: Make VirtualFileSystem functions take credentials as input
Instead of getting credentials from Process::current(), we now require
that they be provided as input to the various VFS functions.

This ensures that an atomic set of credentials is used throughout an
entire VFS operation.
2022-08-21 16:02:24 +02:00
James Bellamy
9744dedb50 Kernel: Use credentials object in Socket set_origin/acceptor 2022-08-21 14:55:01 +02:00
James Bellamy
2686640baf Kernel: Use credentials object in LocalSocket constructor 2022-08-21 14:55:01 +02:00
James Bellamy
386642ffcf Kernel: Use credentials object in VirtualFileSystem
Use credentials object in mknod, create, mkdir, and symlink
2022-08-21 14:55:01 +02:00
James Bellamy
8ef5dbed21 Kernel: Use credentials object in Coredump:try_create_target_file 2022-08-21 14:55:01 +02:00
MacDue
78813313f9 PixelPaint: Fix tool preview positions after moving a layer
Previously the tool previews did not account for the position of
the layer, so would be drawn in the wrong location if the layer was
not at 0,0.
2022-08-21 14:13:08 +02:00
MacDue
973771f8f4 PixelPaint: Make outline ellipse the same size as other ellipses
The non-AA outline ellipse was drawn outside the bounding rectangle
unlike all other ellipses. This commit now scales it to match the
size of the other ellipse drawing modes (AA, filled, etc).
2022-08-21 14:13:08 +02:00