MCTS (among other things) for 2048

Overview

2048

Created by Chad Palmer for CPSC 474, Fall 2021

Overview:

This is an application which can play 2048 and simulate games of 2048 with a variety of different computational intelligences, the highest performing of which is MCTS. With MCTS with 1000 iterations (./Driver -simulate m 1000 -display), the agent achieves scores comparable to a skilled human player (usually wins, occasionally achieves the 4096 tile). Flat Monte Carlo also works very well. The entire program runs a bit slower than I would like; that the 2048 game tree is very deep and moves require matrix operations slowed down execution time such that running the same number of games as MCTS for Kalah was infeasible. (A potential speedup could be implementing the game as bitboards and introducing a move lookup table to prevent unnecessary overcalculation, but that is a project for another day.) All code is my own; mcts.py is adapted to single-player, stochastic play from my work on the Kalah project.

Usage:

./Driver -readme View this page ./Driver -play Play the game yourself ./Driver -simulate [agent] [agent args] Simulate games with a given computational intelligence Available agents: r - random g - greedy (highest score after next turn) b - bottom left (choose first legal move in following order: left, down, right, up) f [number of games] - flat monte carlo (arg indicates how many random rollouts performed, evenly split between legal moves) m [number of iterations] - MCTS (arg indicates how many tree iterations performed) Optional additional args: -size [size] - Change size of game board (available to -play as well) -games [number of games] - Change number of games simulated (defaults to 1) -display - View games as they are played (can slow down execution) ./Driver -compete [agent1] [agent1 args] [agent2] [agent2 args] Compete two computational intelligences against each other (win condition is a higher score) Optional additional args from -simulate also available (except display)

Sample commands:

./Driver -readme ./Driver -play ./Driver -play -size 3 ./Driver -simulate r -display ./Driver -simulate r -games 1000 ./Driver -simulate f 100 -display ./Driver -simulate m 1000 -display ./Driver -compete r r -games 1000 ./Driver -compete b g -games 1000 ./Driver -compete g m 100

...

Thank you for a great semester!

  • Chad
Owner
Chad Palmer
Yale 2022, majoring in computer science and mathematics. Incoming SWE at Optiver.
Chad Palmer
Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature.

Insect Sweeper Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature. Mines are replaced with random insects that a player

Piotr Data 1 Nov 05, 2021
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

11 Oct 11, 2022
Simple implementation of the classic Snake Game in under 100 lines of code

Snake_Game Simple python implementation of the classic Snake Game in under 100 lines of code. Printscreen of the game: Imported Libraries: random; pyg

Raffaele Fiorillo 2 Jun 13, 2022
Jogo da velha escrito em python para 1 ou 2 jogadores

O Jogo da Velha Esse jogo da velha foi desenvolvido por mim em python, como um desafio de programar um jogo da velha em menos de 24 horas, no qual o c

Gabriel Castelo Branco 5 Jun 18, 2021
Tic-Tac-Toe Game in python3 Tkinter

Tic Tac Toe Tic-Tac-Toe Game in python3 Tkinter About: Tic Tac Toe or Noughts and Crosses as called in British is a pencil and paper game for two play

Sai Swarup Yakkala 5 Nov 06, 2022
python script to convert .OBJ files into Minecraft, rendering them in game with a core shader.

samples: random notes about the tool general output format: (animation not supported yet but planned) vertex id Minecraft's gl_VertexID isn't per mode

199 Jan 02, 2023
A Pygame game made in 48 hours

Flappuccino Flappuccino is a game created in 48 hours for the PyGame Community New Years Jam using Python with Pygame. Screenshots Background Informat

PolyMars 242 Jan 02, 2023
The original Tetris tile-matching game as adopted by IBM PC.

🕹️ Tetris Game The original Tetris tile-matching game as adopted by IBM PC. Game developed purely on python using the Dear PyGui Framework. 📖 Instru

14 Nov 12, 2022
Creates a landscape with more accurate river generation in Minecraft version 1.12 using python.

MinecraftLandRiverGen View the following youtube video to set up a world that can interact with the python programs

23 Dec 25, 2022
This is simple minesweeper-like Telegram game

This is simple minesweeper-like Telegram game. You need to open all "free" squares and put flags on squares with bombs on them. If you open a cell with a bomb, the game is over.

Aleksandr 32 Dec 31, 2022
Flappy bird using Pygames

flappy-bird Esse é um jogo que eu fiz utilizando a biblioteca de jogos do Python

Leandro Henrique 2 Jan 05, 2022
A terminal-based number guessing game written in python

A terminal-based number guessing game written in python

Akshay Vs 15 Sep 22, 2022
Graphical impimetaion of Conway's Game of Life in Python using pyglet

Conway's Game of Life in Python Konstantin Opora Conway's Game of Life: graphical implementation in python using pyglet. developed in Python 3.10.0 Re

Konstantin Opora 1 Nov 30, 2021
Magic: The Gathering Arena draft tool that utilizes 17Lands data

MTGA_Draft_17Lands Magic: The Gathering Arena draft tool that utilizes 17Lands data. Steps for Windows Step 1: Download and unzip the MTGA_Draft_17Lan

41 Dec 31, 2022
source codes for my(small indie game developer) games

My repository for most of my finished && unfinished games Table of Contents Getting Started Prerequisites Installation Usage License Contact Prerequis

Gustavs Jākobsons 1 Jan 30, 2022
Game-of-life - A simple python program to simulate and visualise the Conway's Game of life

Conway's game of life A simple python program to simulate and visualise the Conw

Dhravya Shah 3 Feb 20, 2022
:tada: 2048 in your terminal

term2048 term2048 is a terminal-based version of 2048. Install pip install term2048 To upgrade a previous installation, use: pip install -U term2048

Baptiste Fontaine 798 Nov 21, 2022
Lutris helps you install and play video games from all eras and from most gaming systems.

Lutris Lutris helps you install and play video games from all eras and from most gaming systems. By leveraging and combining existing emulators, engin

Pop!_OS 2 Nov 15, 2021
j-chess implementation in python

j-chess-client-python This repository aims to be a starting point for implementing a chess ai for the j-chess-server in python. To start, you can copy

Jonas 1 Dec 25, 2021
🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs

Projet jeu Azul 🕹️ Jeu Azul en Python avec 4 IAs 🤖 implémentées, jouable de 1 à 4 joueurs Par : Berachem MARKRIA et Tristan MARTINEZ Projet réalisé

Berachem Markria 2 Jun 07, 2022