Coder Social home page Coder Social logo

miskibin / 2048 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 64 KB

Implementation of 2048 game. This is web application with python backend and (js)jquery and bootstrap frontend.

Python 63.48% CSS 8.24% JavaScript 11.21% HTML 17.07%
2048-ai 2048-game alpha-beta-pruning fastapi jquery-ajax python web-application

2048's Introduction

2048 Game

This project implements the popular game 2048. The game is built using a combination of Python for the backend and HTML, CSS, and JavaScript for the frontend.

Contributors

I am absolutelly open to contributions:

potentaial tasks:

  • refactor frontend so it will be scallable to portable devices
  • Add new engine to game. It could be DQNagent, or some classic engine.

Features

  • The game is played on a grid with dimensions defined by the shape argument.
  • The game starts with two tiles, each with a value of either 2 or 4.
  • The player can move the tiles in four directions: up, down, left, and right.
  • When two tiles with the same value collide while moving, they merge into a new tile with the sum of their values.
  • After each move, a new tile with a value of either 2 or 4 appears on the board.
  • The goal of the game is to reach a tile with a value of 2048.

Installation

  1. Clone the repository:
git clone https://github.com/michalskibinski109/2048.git
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Run the application:
python main.py

The application will be accessible at http://localhost:8000.

Files

  • board.py: Contains the implementation of the game board and its operations.
  • game.py: Implements the game logic and provides methods to play the game.
  • engine.py: Implements the engine to find the best move using the minimax algorithm.
  • main.py: Sets up the API endpoints and runs the FastAPI server.
  • templates/index.html: HTML template for the frontend of the game.
  • static/main.js: JavaScript code for handling user interactions and making API requests.
  • static/style.css: CSS styling for the frontend.

API Endpoints

  • GET /: Renders the game interface.
  • GET /board: Returns the current state of the game board and score as JSON.
  • GET /ai_move: Performs an AI move and returns the updated game board and score as JSON.
  • POST /move/{direction}: Moves the tiles in the specified direction and returns the updated game board and score as JSON.
  • POST /reset: Resets the game board to its initial state and returns the updated game board and score as JSON.

Frontend Screenshots

frontend

documentation modal

For more details and examples, please refer to the code and comments in the individual files.

License

This project is licensed under the MIT License.

2048's People

Contributors

miskibin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.