Greedy and random baselines
How much does a smarter search actually add?
Two trivial players: one plays any legal move, the other the move that looks best right now. Every real algorithm has to beat them.
The random player chooses a legal move uniformly. It has no idea what is good, which makes it a floor.
The greedy player looks exactly one move ahead. It tries each legal move, scores the resulting position with the evaluation function and plays the highest. It never considers the reply, so it walks into a trap that is obvious two moves later.
They earn their place twice: as opponents of different strengths, and as a measuring stick. If minimax at depth four cannot beat greedy, the evaluation is the problem, not the search.
Loading the demo…
Connect Four against the greedy player. It only ever scores its own next move, so try setting up a threat it has to answer two moves from now.
- 01List the legal moves.
- 02Random: pick one of them at random and stop.
- 03Greedy: play each move on a copy of the position and score the result.
- 04Greedy: play the move with the highest score, breaking ties at random.
function random_move(position):
return random_choice(moves(position))
function greedy_move(position):
me = turn(position)
return argmax over m in moves(position) of evaluate(play(position, m), me)Random takes one step; greedy scores each of the b legal moves once. Both answer instantly.
- Instant, even on large boards.
- A fair test of the evaluation function.
- Opponents a beginner can beat.
- Greedy cannot see the opponent’s reply.
- Random is no challenge at all.
- Neither plans.
- 01OthelloGreedy plays the move that scores best right now; random plays anything legal.
- 02Connect FourGreedy picks the column whose resulting position scores best; random drops anywhere.