<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: khalid ali</title>
    <description>The latest articles on DEV Community by khalid ali (@khalid_ali_77fe2769690065).</description>
    <link>https://dev.to/khalid_ali_77fe2769690065</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4083271%2F581dcb70-0075-4fcc-9437-a2a2b2e8b328.jpg</url>
      <title>DEV Community: khalid ali</title>
      <link>https://dev.to/khalid_ali_77fe2769690065</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khalid_ali_77fe2769690065"/>
    <language>en</language>
    <item>
      <title>Baloot rules for developers: contracts, projects, doubling and qaid scoring</title>
      <dc:creator>khalid ali</dc:creator>
      <pubDate>Fri, 11 Sep 2026 07:45:34 +0000</pubDate>
      <link>https://dev.to/khalid_ali_77fe2769690065/baloot-rules-for-developers-contracts-projects-doubling-and-qaid-scoring-55ol</link>
      <guid>https://dev.to/khalid_ali_77fe2769690065/baloot-rules-for-developers-contracts-projects-doubling-and-qaid-scoring-55ol</guid>
      <description>&lt;p&gt;Baloot is Saudi Arabia's most popular card game, and most English-language explanations get the scoring wrong. This is a compact, implementation-oriented reference we used while building Arb3a Baloot (Unity client, Node.js server, RL-trained opponent).&lt;/p&gt;

&lt;h2&gt;
  
  
  Deck and seating
&lt;/h2&gt;

&lt;p&gt;32 cards (7 through Ace in four suits), four players in two fixed partnerships, eight cards each. The dealer rotates counter-clockwise. Bidding starts with the player to the dealer's right.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contracts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sun&lt;/strong&gt;: no trump. Card order per suit: A, 10, K, Q, J, 9, 8, 7. Point values: A 11, 10 10, K 4, Q 3, J 2, others 0. Round total is 130 plus 10 for the last trick.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hokm&lt;/strong&gt;: one trump suit. In the trump suit the order becomes J, 9, A, 10, K, Q, 8, 7 with J worth 20 and 9 worth 14. Other suits keep the Sun order. Round total is 162 including the last-trick bonus.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bidding
&lt;/h2&gt;

&lt;p&gt;Two rounds. In the first round, players may take the face-up card as trump (Hokm), call Sun, or pass. In the second round a player may name a different trump suit or Sun. If everyone passes twice, the hand is redealt. The side that buys must score more than half the points or it loses everything to the opponents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Projects (melds)
&lt;/h2&gt;

&lt;p&gt;Declared during the first trick, shown after the second. Sira (3 consecutive cards, one suit), Fifty (4), Hundred (5, or four of a kind), Four Hundred (four Aces, Sun only), Baloot (K and Q of trumps). Only the side with the strongest project scores its projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doubling
&lt;/h2&gt;

&lt;p&gt;Double, Triple, Quadruple and Qahwa multiply the round result. Qahwa ends the match on that hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoring (qaid)
&lt;/h2&gt;

&lt;p&gt;Points are converted with rounding: in Hokm divide by 10 and round (with special rules at .5), in Sun divide by 5 then round. A team wins the match at 152 or more, provided it is ahead. Kaboot (winning all eight tricks) is worth 44 in Sun and 25 in Hokm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Android: &lt;a href="https://play.google.com/store/apps/details?id=com.e_moh.balootgame" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.e_moh.balootgame&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;iOS: &lt;a href="https://apps.apple.com/app/id6759184291" rel="noopener noreferrer"&gt;https://apps.apple.com/app/id6759184291&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Full rules and glossary (Arabic): &lt;a href="https://baloot.kriyadh.com/rules" rel="noopener noreferrer"&gt;https://baloot.kriyadh.com/rules&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gamedev</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Training a reinforcement-learning agent to play Baloot (and shipping it to Android)</title>
      <dc:creator>khalid ali</dc:creator>
      <pubDate>Fri, 11 Sep 2026 02:04:49 +0000</pubDate>
      <link>https://dev.to/khalid_ali_77fe2769690065/training-a-reinforcement-learning-agent-to-play-baloot-and-shipping-it-to-android-2hk5</link>
      <guid>https://dev.to/khalid_ali_77fe2769690065/training-a-reinforcement-learning-agent-to-play-baloot-and-shipping-it-to-android-2hk5</guid>
      <description>&lt;p&gt;Baloot is a 32-card trick-taking game played in Saudi Arabia by four players in two teams: two contracts (Sun and Hokm), two bidding rounds, declarable melds called projects, doubling up to four times, and a scoring system (qaid) with rounding rules that catch even experienced players out. Building a bot that plays it well turned out to be a much bigger project than the card game itself. This is a write-up of the approach used in Arb3a Baloot (Unity client, Node.js server), which shipped on Android this week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the rule-based bot failed
&lt;/h2&gt;

&lt;p&gt;The first opponent was a hand-written heuristic: count trump strength, bid Hokm with jack and nine, lead high in Sun. It played legal Baloot but lost to humans, mostly because bidding depends on your partner's likely hand and the dealer position, not only on your own cards. Every hand-coded fix created a new exploitable habit.&lt;/p&gt;

&lt;h2&gt;
  
  
  State encoding
&lt;/h2&gt;

&lt;p&gt;The encoder produces a 571-dimensional vector per decision:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the 32-card hand as a bitmap&lt;/li&gt;
&lt;li&gt;trick history as ordered plays with seat indices&lt;/li&gt;
&lt;li&gt;suits each opponent is known to be void in (inferred from failed follows)&lt;/li&gt;
&lt;li&gt;confirmed projects&lt;/li&gt;
&lt;li&gt;bidding context: who bid, what, in which round, and the doubling level&lt;/li&gt;
&lt;li&gt;the running match score, because the right play at 140-60 is not the right play at 60-140&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Training loop
&lt;/h2&gt;

&lt;p&gt;PPO with self-play on a simulator that reuses the server's engine code, so the bot trains on exactly the rules it faces in production. Bidding and card play are two policy heads on a shared trunk. Rewards are shaped per round from the qaid delta rather than only at match end, which roughly halved wall-clock time to a competitive policy. A distillation stage compresses the best checkpoint into a small network that runs on-device for offline play.&lt;/p&gt;

&lt;h2&gt;
  
  
  Evaluation
&lt;/h2&gt;

&lt;p&gt;A candidate is promoted only when it beats the current champion over a fixed set of 960 dealt games with seats rotated, so both sides see the same cards. A search-based player (lookahead over sampled hidden hands) beats the champion network by a few points but is too slow to run for every seat on the server, so it stays a benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that bit us
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The model loader logged "model loaded" before verifying the file, so one deploy ran a random policy in production for days. It now prints the checksum and the evaluation win-rate at startup.&lt;/li&gt;
&lt;li&gt;Turn timers lived only in memory, so a server restart during a doubled hand stranded the table. Timer flags are now persisted with the game state.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Shipping
&lt;/h2&gt;

&lt;p&gt;The Android build is a Unity IL2CPP app bundle (arm64 + armeabi-v7a). The game is free with no ads.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Play: &lt;a href="https://play.google.com/store/apps/details?id=com.e_moh.balootgame" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=com.e_moh.balootgame&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;App Store: &lt;a href="https://apps.apple.com/app/id6759184291" rel="noopener noreferrer"&gt;https://apps.apple.com/app/id6759184291&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rules and terminology (Arabic): &lt;a href="https://baloot.kriyadh.com/rules" rel="noopener noreferrer"&gt;https://baloot.kriyadh.com/rules&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy to answer questions about the encoder or the training setup.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>machinelearning</category>
      <category>android</category>
    </item>
    <item>
      <title>Baloot Goes Digital: Building Saudi Arabia's Card Game with a Real RL-Trained AI</title>
      <dc:creator>khalid ali</dc:creator>
      <pubDate>Tue, 18 Aug 2026 12:33:07 +0000</pubDate>
      <link>https://dev.to/khalid_ali_77fe2769690065/baloot-goes-digital-building-saudi-arabias-card-game-with-a-real-rl-trained-ai-1gbi</link>
      <guid>https://dev.to/khalid_ali_77fe2769690065/baloot-goes-digital-building-saudi-arabias-card-game-with-a-real-rl-trained-ai-1gbi</guid>
      <description>&lt;p&gt;Baloot is Saudi Arabia's national card game — 32 cards, 4 players, 2 teams, and a bidding system (Sun / Hokm) that rewards reading your opponents.&lt;/p&gt;

&lt;p&gt;Most Baloot apps are either stuffed with ads or built around buying coins. &lt;strong&gt;Arb'a Baloot&lt;/strong&gt; takes the opposite approach: completely free, no ads, no in-app purchases.&lt;/p&gt;

&lt;h2&gt;
  
  
  The interesting part: a real AI
&lt;/h2&gt;

&lt;p&gt;Instead of hard-coded rules, the AI opponent was trained with &lt;strong&gt;reinforcement learning&lt;/strong&gt; over millions of self-play rounds — the same family of techniques behind AlphaGo. It bids Sun or Hokm like a strong human, counts cards, punishes mistakes, and works fully offline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Online multiplayer with private invite-code rooms&lt;/li&gt;
&lt;li&gt;Full rule set: projects (Sira, Fifty, Hundred, Four Hundred, Baloot) and doubling up to Qahwa&lt;/li&gt;
&lt;li&gt;Automatic score counting with correct rounding&lt;/li&gt;
&lt;li&gt;Weekly tournaments with a public leaderboard&lt;/li&gt;
&lt;li&gt;Rated 5.0 on the App Store · iPhone, iPad, Mac &amp;amp; Vision Pro&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Website: &lt;a href="https://baloot.kriyadh.com" rel="noopener noreferrer"&gt;https://baloot.kriyadh.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Full rules (Arabic): &lt;a href="https://baloot.kriyadh.com/rules" rel="noopener noreferrer"&gt;https://baloot.kriyadh.com/rules&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;App Store: &lt;a href="https://apps.apple.com/app/id6759184291" rel="noopener noreferrer"&gt;https://apps.apple.com/app/id6759184291&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source/README: &lt;a href="https://github.com/nrdx/arb3a-baloot" rel="noopener noreferrer"&gt;https://github.com/nrdx/arb3a-baloot&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gamedevaishowdev</category>
    </item>
  </channel>
</rss>
