liveBook · Manning

Bogart

As explained in Learn AI-Assisted Python Programming, Second Edition

Bogart is a dice-based computer game in which players accumulate chips and may win them based on their rolls.

Bogart is a two-player dice game implemented without physical dice or chips. The pot starts empty, one player is chosen randomly, and players alternate turns until someone wins. A turn adds chips to the pot, rolls progressively more dice, and forces a choice between stopping safely or risking everything. section 10.4.1

A player’s turn follows this pattern:

  • Add one chip and roll one die. Rolling a 1 ends the turn without awarding chips. section 10.4.1
  • If no 1 appears, stop and collect the pot or continue by adding two chips and rolling two dice. section 10.4.1
  • Continue sequentially through three, four, and five dice; any 1 ends the turn without a payout. section 10.4.1
  • Organize the implementation with a top-level play function, separate turn logic, chip awarding, and game-ending decisions. section 10.4.2

A safer strategy

A player who has accumulated enough chips to win can stop instead of risking another roll. A human-versus-computer version can give the computer rules for stopping when its current chips are valuable or sufficient to win. section 10.5

Figure 10.5 Player turn in Bogart
figure

The player-turn flowchart helps trace the choices, rolls, failed turns, payouts, and stopping points before translating them into functions. section 10.4.1

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains complete rules and top-down implementation responsibilities, while leaving computer-player strategy as an exercise.
Examples
Uses a two-player chip-pot game, a player-turn flowchart, and a proposed human-versus-computer variation.
What it assumes
Assumes basic familiarity with program decomposition and random calls, while teaching the game rules and their implementation structure.
What you can do after
Build it from scratch by dividing the game into functions for turns, payouts, switching players, and winning conditions.
How it connects
Connects dice games with top-down design, functions, random number generation, game loops, and human-computer interaction.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.