Skip to content

lu-m-dev/halving-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Halving Game

  • Simple number game involving two players
  • Game starts with a number (positive integer)
  • Two players take turns to either subtract 1 or divide by 2
  • Whoever reduces the number to zero wins

Game Demo

game demo

Tech Specs

  • Minimal implementation
  • Player 1 moves first and is the human player
  • Player 2 is the AI agent using minimax algorithm
  • HTML/CSS for UI, JavaScript for game logic

User Interface

  • Current number n
  • Two buttons Subtract 1 and Divide by 2 to collect human player input

Minimax Algorithm

  • Simulates the game until game end and picks the best outcome (recursion)
  • Assumes both players play optimally
  • On the agent's turn, it picks the action that maximizes outcome for agent
  • On the opponent's turn, it picks the action that minimizes outcome for agent

Credit

Stanford CS 221

About

Minimalistic implementation and deployment of halving game with minimax agent

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages