‹ Back to SmartGame / 返回首页

Game Guides & Learning Resource

游戏攻略与学习指南

SmartGame features four classic logic puzzles, each rooted in mathematics, computer science, or game theory. This guide covers the history, rules, thinking skills developed, and strategic hints for each game. All puzzles are free to play at www.idaypop.com.

本页面介绍每款游戏的来历、规则、所训练的思维能力,以及上手提示。四款游戏均可在首页免费游玩。

💧 Water Jug — 测水量

State-Space Search • Number Theory • Bezout's Identity

History & Background

The water jug puzzle has circulated for centuries and became widely known to modern audiences through the 1995 action film Die Hard with a Vengeance, in which the protagonists must measure exactly 4 gallons using 5-gallon and 3-gallon jugs to defuse a bomb within minutes.

Despite its casual appearance, this puzzle rests on solid number theory. Bezout's Identity guarantees that for two integers a and b, every integer of the form ax + by is a multiple of gcd(a, b). Since gcd(5, 3) = 1 — which divides any integer, including 4 — measuring exactly 4 liters is mathematically guaranteed to be achievable. Had both jugs held an even number of liters, only even totals would be reachable, and measuring an odd amount would be impossible no matter how many steps you took.

This principle extends to all water jug puzzles: a target volume T is achievable with jugs of capacity a and b if and only if T is a multiple of gcd(a, b) and T ≤ max(a, b).

水杯量水问题是一道流传数百年的经典逻辑谜题,在 1995 年好莱坞电影《虎胆龙威3》中被大众熟知。背后的数学原理是贝祖定理(Bezout's Identity):gcd(5,3)=1,因此 5 升和 3 升的杯子可以量出任意整数升的水(不超过 5 升),包括目标 4 升。若两个杯子都是偶数升,则只能量出偶数升。
Rules
  • You have one 5-liter jug and one 3-liter jug, both without measurement markings
  • Three allowed operations: fill a jug completely from the tap; empty a jug completely; pour from one jug into the other until the source empties or the target is full
  • Goal: end up with exactly 4 liters in one of the jugs
Skills Developed

This puzzle is a textbook example of state-space search in computer science. Each pair (A liters in the 5L jug, B liters in the 3L jug) is a distinct state; each of the three operations is a directed edge in the state graph. There are at most 6 × 4 = 24 possible states, and Breadth-First Search (BFS) over this graph will always find the minimum-step solution.

Playing and solving this puzzle trains several important cognitive skills:

  • Reverse thinking: working backward from the goal state to discover which prior state leads to it
  • Exhaustive enumeration: systematically listing reachable states without double-counting
  • Shortest-path intuition: understanding that "fewer steps" maps to BFS depth in a graph
  • Problem modeling: the engineering habit of representing a physical problem as an abstract graph for algorithmic solution
Hint

Draw a table of all possible (5L-jug, 3L-jug) water-level pairs and trace where each of the three operations leads from every state. Starting at (0, 0), follow the chain of reachable states — somewhere in the network is a direct path to either (4, 0) or (?, 4) containing 4 liters. The shortest such path requires fewer than 10 steps.

试着把所有可能出现的水量组合 (A, B) 列出来,从初始状态 (0, 0) 出发,追踪每次操作后到达的新状态。你会发现某条路径恰好经过目标状态,步数不超过 10 步。

🚣 River Crossing — 动物过河

Constraint Satisfaction • Multi-Step Planning • 1,200-Year-Old Puzzle

History & Background

River crossing puzzles are among the oldest recorded logic puzzles in human history. The English scholar Alcuin of York (c. 735–804 AD) compiled the famous collection Propositiones ad Acuendos Juvenes ("Problems to Sharpen the Young"), which includes the wolf-goat-cabbage crossing problem. That puzzle tradition is now over 1,200 years old and has been studied and reproduced continuously through the Middle Ages and the modern era.

Variations of this puzzle appear in folklore and mathematics education across dozens of cultures, with different cargo (missionaries and cannibals, jealous husbands, etc.) but the same underlying structure: safely ferry a group of agents across a river under constraints that forbid certain combinations from being left together unsupervised.

SmartGame's version extends the classic by using six animals in three parent-cub pairs, significantly increasing the complexity of the constraint set and requiring more systematic multi-step planning than the original two-constraint version.

渡河谜题是人类最古老的逻辑谜题之一。公元 8 世纪英国学者约克的阿尔昆(Alcuin of York)在其著作《磨砺青年心智的习题集》中收录了「农夫、狼、羊、白菜」的渡河版本,距今已有 1200 余年。SmartGame 将其扩展为六只动物——三对大小动物,增加了约束条件的复杂度。
Rules
  • Six animals — Big Lion, Small Lion, Big Tiger, Small Tiger, Big Leopard, Small Leopard — must all cross from the left bank to the right bank
  • The boat holds at most 2 animals and cannot cross empty
  • Animals that can row (marked ✓): Big Lion, Big Tiger, Big Leopard, Small Lion
  • A cub is in danger if left on the same bank as a non-parent adult without its own parent present
  • The boat needs at least one rower to depart
Skills Developed

This puzzle is a classic instance of a Constraint Satisfaction Problem (CSP) — a category extensively studied in artificial intelligence and used in scheduling, resource allocation, and planning systems. The state space consists of all legal distributions of animals across left bank, boat, and right bank, and the solution is a sequence of transitions through this space that respects all constraints at every step.

Key cognitive skills trained:

  • Constraint enumeration: identifying which of the many possible bank configurations violate a safety rule
  • Bidirectional planning: accounting for the fact that the boat must return (costing steps) each time it crosses
  • Simultaneous constraint satisfaction: keeping all three parent-cub relationships safe at once, not just one
  • Systematic exploration: avoiding repeated states and dead ends through orderly search
Hint

Begin by listing out all the "dangerous" bank configurations — situations where a cub would be eaten. Then, rather than trying random crossings, think about which animals must go first to avoid creating a dangerous state on either bank. Remember that the return trip consumes a step, so take two animals across whenever possible. Focus on moving one family across completely before dealing with the next.

先弄清哪些两岸组合是「危险的」(某只小动物会被吃掉),再想怎样让每次渡河后两岸都保持安全。注意船的每次返回都会消耗一步,所以要尽量利用每次渡河带两只动物的机会。

🐕 Mad Dog Village — 疯狗村

Common Knowledge • Epistemic Logic • Higher-Order Reasoning

History & Background

Mad Dog Village is a game-theoretic adaptation of the famous Muddy Children Puzzle, a classic problem in epistemic logic (the logic of knowledge and belief). The puzzle structure was studied extensively in philosophy, mathematics, and game theory throughout the 1970s and 1980s.

A landmark formalization came in 1992 when Harvard economist David Geanakoplos published the paper "Common Knowledge" in the Journal of Economic Perspectives, systematically connecting these epistemic puzzles to game theory and behavioral economics. The paper demonstrated how common knowledge — a concept subtly distinct from merely "everyone knows" — is the decisive ingredient that enables rational coordination.

In computer science and artificial intelligence, common knowledge is a foundational concept in the design of multi-agent systems. Distributed protocols, consensus algorithms (such as those underlying blockchain networks), and secure communication systems all must reason about what agents know about each other's knowledge — precisely the kind of higher-order reasoning that this puzzle trains.

疯狗村源自认识论逻辑中著名的「泥巴孩子谜题」(Muddy Children Puzzle)。1992 年哈佛经济学家 David Geanakoplos 在论文《Common Knowledge》中对此类问题进行了系统性总结,成为博弈论和行为经济学的基础理论。在 AI 领域,公共知识是多智能体系统设计的核心概念之一。
Rules
  • Ten cottages; each has one person and one dog. At least one dog is rabid
  • Each person can see all nine neighbors' dogs (normal or rabid), but cannot see their own dog
  • The village chief gives everyone an 8-second window each day
  • If you believe your dog is rabid, shoot it during those 8 seconds
  • All villagers are perfectly rational, and this rationality is itself common knowledge among all villagers
Core Concept: What Is Common Knowledge?

There is a subtle but critical difference between "everyone knows X" and "X is common knowledge."

"Everyone knows X" means: each individual person knows X. That is just one level of knowledge.

Common knowledge of X means an infinite chain of mutual awareness:

  • Everyone knows X
  • Everyone knows that everyone knows X
  • Everyone knows that everyone knows that everyone knows X
  • … and so on, for every finite depth

Before the chief's announcement, every villager privately knows how many rabid dogs there are (by observation) — but this is not common knowledge among the village. The chief's public declaration each day creates the missing common knowledge that unlocks rational deduction for every villager simultaneously.

所有人「知道」某件事,和这件事成为「公共知识」是不同的概念。公共知识要求:每个人都知道;每个人都知道每个人都知道;以此类推无穷层级。村长每天的宣告将信息提升为公共知识,这是理性推理的启动条件。
Skills Developed

This puzzle trains higher-order reasoning — reasoning not just about facts, but about what other rational agents know, and what those agents think you know. This kind of nested reasoning is central to:

  • Game theory: predicting rational opponents' moves in strategic interactions
  • Cryptographic protocols: designing communication systems where agents prove knowledge without revealing it
  • Multi-agent AI: building autonomous systems that coordinate without centralized instruction
  • Mathematical induction: the puzzle solution is itself a proof by induction — solve the base case (N=1 rabid dog), then generalize to N
Hint

Work through the simplest case first: suppose there is exactly 1 rabid dog in the village. The owner of that dog sees zero rabid dogs among the neighbors. What does that tell them? What do they do on day 1?

Now suppose there are exactly 2 rabid dogs. Each owner of a rabid dog sees exactly 1 rabid dog among their neighbors. On day 1, they wait to see if the other rabid-dog owner shoots (as they would if there were only 1). When day 1 passes without a shot, what new information has been revealed? What happens on day 2?

Extend this logic to the general case. Once you see the pattern, you will know exactly when rational villagers act.

从最简单的情形出发:假设全村只有 1 只疯狗,第 1 天会发生什么?再假设有 2 只,前 1 天没有枪声意味着什么?找到这个规律,就找到了解题的钥匙。

🥚 Egg Drop — 摔鸡蛋

Dynamic Programming • Minimax Optimization • Information Theory

History & Background

The Egg Drop Problem is one of the most celebrated dynamic programming puzzles in computer science education and technical hiring. Google, Microsoft, Amazon, and other major technology companies have used variants of this problem in software engineering interviews for over two decades.

The formal problem — given k eggs and a building with n floors, find the critical floor (the highest safe drop height) using the fewest worst-case trials — was introduced in algorithm textbooks in the late 1990s and gained widespread public awareness through the coding-interview culture of the internet era.

Beyond its interview fame, the egg drop problem has deep connections to information theory. Each drop is a binary experiment (egg breaks or survives) that yields one bit of information about the unknown critical floor. The optimal strategy minimizes the worst-case number of experiments needed to identify that floor — which is precisely the same question as finding the minimum-length binary code for an unknown value, a central problem in data compression and search theory.

摔鸡蛋问题(Egg Drop Problem)是计算机科学面试和算法课程中最著名的动态规划题目之一,被谷歌、微软、亚马逊等公司广泛用于技术面试。其变形版本与信息论中的最优编码问题有深层联系:每次投蛋都是一次二元实验,最优策略即最少次数地定位临界层。
Rules
  • A 50-floor building; you start with 2 eggs
  • There exists a "critical floor": dropping an egg from this floor or above breaks the egg; below it, the egg survives
  • A broken egg is permanently gone; an unbroken egg can be reused as many times as needed
  • Goal: identify the critical floor (or confirm floor 50 is safe) using the fewest drops in the worst case
Why Binary Search Fails Here

A naive approach is binary search: try floor 25 first, then 13 or 38, and so on. With unlimited eggs, binary search needs at most log₂50 ≈ 6 drops — optimal.

But this strategy collapses with only 2 eggs. If the first egg breaks at floor 25, you have only 1 egg left. With a single egg, you cannot risk another high-floor drop — you must scan linearly from floor 1 upward, one floor at a time, until the egg either breaks or you reach floor 24. That could require 24 more drops — far worse than 6.

With 2 eggs, the challenge is to find a strategy that balances the two worst cases: (a) the first egg breaking early, leaving a large range to scan linearly; and (b) the first egg never breaking, meaning you tried many high floors before success.

二分查找假设每次失败都有后路,但本题只有 2 个蛋。一旦第一个蛋在高层碎了,第二个蛋只能从低层逐层扫描,最坏情况会非常差。最优策略需要平衡「第一个蛋碎」和「第一个蛋不碎」两种最坏情形。
Skills Developed

The egg drop problem elegantly teaches several core concepts from computer science and operations research:

  • Dynamic programming: the optimal number of drops for (k eggs, n floors) can be built from the solutions to smaller subproblems — this is the hallmark DP pattern of optimal substructure
  • Minimax reasoning: the goal is to minimize the worst-case outcome, not the average case — a mindset essential in risk management, adversarial games, and robust system design
  • Resource-constrained search: how the presence of a finite, consumable resource (eggs) fundamentally changes the optimal strategy compared to the unconstrained version
  • Information-theoretic thinking: each experiment (drop) reveals information; the strategy question becomes "how do I extract information maximally efficiently from each trial?"
Hint

Suppose your first drop is from floor F. There are two outcomes:

  • Egg breaks: the critical floor is somewhere in floors 1 to F-1. You now have only 1 egg left and must scan linearly — that's at most F-1 more drops.
  • Egg survives: the critical floor is somewhere above F. You still have 2 eggs and a smaller building to search.

The total worst-case drops is 1 (for this drop) plus the maximum of the two sub-scenarios. You want to choose F such that this total is as small as possible — and then apply the same logic recursively for the "egg survives" case.

Alternatively, think about it this way: if you are allowed at most T total drops, how many floors can you definitely cover with 2 eggs? Work out T=1, T=2, T=3, … and look for the pattern.

思考:在某一层投下第一个蛋,有两种结果——碎了或没碎。两种情况下剩余的子问题有多大?希望这两个子问题的最坏情况次数尽量「平衡」。找到这个平衡点,就找到了最优策略的核心。

© 2025 SmartGame · www.idaypop.com