{"id":363,"date":"2026-02-19T10:37:15","date_gmt":"2026-02-19T10:37:15","guid":{"rendered":"https:\/\/ffritze.de\/?p=363"},"modified":"2026-05-05T19:51:06","modified_gmt":"2026-05-05T19:51:06","slug":"reversi-als-beispiel-fuer-den-minimax-algorithmus-in-swift-playgrounds","status":"publish","type":"post","link":"https:\/\/ffritze.de\/en\/reversi-als-beispiel-fuer-den-minimax-algorithmus-in-swift-playgrounds\/","title":{"rendered":"Reversi as an example of the Minimax algorithm (in Swift Playground)"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Reversi, also known as Othello, is a strategic board game for two players played on an 8\u00d78 board. The goal of the game is to have more stones of your color on the board than the opponent.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Rules of the game<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Game board:<\/strong><br>The game is played on an 8\u00d78 board.<\/li>\n\n\n\n<li><strong>Game pieces:<\/strong><br>Each player has stones in one color: orange or yellow.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-b0c51ef4 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-container-core-column-is-layout-188acd66 wp-block-column-is-layout-flow\" style=\"padding-right:0;padding-left:0;flex-basis:70%\">\n<ul class=\"wp-block-list\">\n<li><strong>Starting grid:<\/strong><br>At the beginning of the game, there are four stones in the middle of the board: two orange and two yellow stones in diagonal arrangement.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image alignleft size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"298\" height=\"300\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/Reversi-start-298x300.png\" alt=\"\" class=\"wp-image-369\" style=\"box-shadow:var(--wp--preset--shadow--natural);aspect-ratio:0.9935500189705324;object-fit:cover\" srcset=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/Reversi-start-298x300.png 298w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/Reversi-start-150x150.png 150w, https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/Reversi-start.png 306w\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Rules:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The players take turns putting a stone on an empty field. A move is only valid if it \"catches\" at least one opponent's stone between the newly set stone and its own stone.<\/li>\n\n\n\n<li>All enemy stones that lie between the new stone and a separate stone are turned over and change color.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>End of game:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The game ends when the board is full or no player can make a valid move.<\/li>\n\n\n\n<li>The player with the most stones of his color wins.<br><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Minimax algorithm<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Minimax algorithm is a decision algorithm that is often used in games like Reversi to find the best move for a player. Here is a brief explanation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Goal:<\/strong><br>The Minimax algorithm aims to achieve the maximum gain for the player, while minimizing the maximum loss for the opponent.<\/li>\n\n\n\n<li><strong>Baumstruktur:<\/strong><br>Der Algorithmus erstellt einen Spielbaum, der alle m\u00f6glichen Z\u00fcge und deren Ergebnisse darstellt. Jeder Knoten im Baum repr\u00e4sentiert einen Spielzustand.<\/li>\n\n\n\n<li><strong>Minimization and maximization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The algorithm evaluates the possible moves by considering the best moves for the current player (maximizer) and the worst moves for the opponent (minimizer).<\/li>\n\n\n\n<li>The maximizer chooses the move with the highest value, while the minimizer chooses the move with the lowest value.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Depth and Heuristics:<\/strong>\n<ul class=\"wp-block-list\">\n<li>To optimize the calculation, a maximum depth for the search is often set. Instead of following every possible move to the end, a heuristic is used to evaluate the value of a game state.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Result<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Reversi is an exciting game that requires strategic thinking. The Minimax algorithm is a powerful tool to make decisions in this game and can help to greatly improve the game strength of AI opponents.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Have fun playing and programming!<\/p>\n\n\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-container-core-buttons-is-layout-396e47c8 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-text-align-left wp-element-button\" href=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/GraphApp.swiftpm.zip\" style=\"padding-top:0;padding-right:var(--wp--preset--spacing--30);padding-bottom:0;padding-left:var(--wp--preset--spacing--30)\" target=\"_blank\" rel=\"noreferrer noopener\">\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-c0d5ccf6 wp-block-group-is-layout-flex\">\n                    <figure class=\"wp-block-image size-full\">\n                        <img loading=\"lazy\" decoding=\"async\" width=\"89\" height=\"88\" src=\"https:\/\/ffritze.de\/wp-content\/uploads\/2026\/02\/swift_48.png\" alt=\"\" class=\"wp-image-543\">\n                    <\/figure>\n\n                    <div class=\"wp-block-group is-vertical is-content-justification-center is-layout-flex wp-container-core-group-is-layout-81423f52 wp-block-group-is-layout-flex\">\n                        <p class=\"has-medium-font-size\">Download<\/p>\n\n                        <p class=\"has-small-font-size\">for Swift Playground <\/p>\n                    <\/div>\n                <\/div>\n<\/a><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Reversi, also known as Othello, is a strategic board game for two players played on an 8\u00d78 board. The goal of the game is to have more stones of your color on the board than the opponent.<\/p>","protected":false},"author":2,"featured_media":365,"comment_status":"open","ping_status":"open","sticky":false,"template":"seite-thoughts-beitrag","format":"standard","meta":{"footnotes":""},"categories":[19,7,46],"tags":[10,32,33,11],"class_list":["post-363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithms","category-programs","category-swift-playground","tag-game","tag-minimax","tag-reversi","tag-spiel"],"_links":{"self":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts\/363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/comments?post=363"}],"version-history":[{"count":0,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/posts\/363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/media\/365"}],"wp:attachment":[{"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/media?parent=363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/categories?post=363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ffritze.de\/en\/wp-json\/wp\/v2\/tags?post=363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}