For the Exapunk minigame, ПАСЬЯНС

Related tags

Game Developmentgame
Overview

Exapunks Automation

This repository solves Exapunk's Solitaire minigame, ПАСЬЯНС. This repository is useable, but only with specific display conditions (more on that below under Usage)

How it works

main.py contains the Board class, which is responsible for reading your screen and creating a Game object from it. The Game object is a programatic version of the game board that contains an array of Rank objects. Ranks are containers for each column in the game, but instead of containing an array of Card objects, they contain a list of Stack objects, which only know their front card, back card, and their length. When Board generates Game, it combines all pre-existing stacks that are able to merge (that is to say: Stacks in the same Rank that can be combined, are combined). Game.solve checks the front stack in each rank against all other front stacks, seeing if the back card and front card are compatible. If they are, that particular move is added to the state space to further investigate.

The solver is breadth-first and it finds all possible solutions for the particular puzzle. Game.move_stack is a collections.deque that stores each possible set of moves. Every Game.iteration, a list of consecutive moves is popped off of the move stack and checked for child moves. If a child move is found, it's appended to the end of a copy of the move list, then the new move list is appended to the back of the move stack. If there are no moves left, we check if the board we're looking at is a winning board. If it is, append that particular move list to Game.winning_moves. Win or not, the move stack shrinks until it's empty and we know we've searched all possible states.

Example of solution

Usage & Installation

This code wasn't really made with other people using it mind. That said, if your monitor resolution is 1920x1080 and Exapunks is full screen, this should work for you. You'll just need to fork this repository and run main.py. There are some things you can change to tailor this for yourself.

This project uses Pillow and pyautogui

python -m pip install Pillow
python -m pip install pyautogui

Under main.py's main function, there is a function call for board.play_games(n) or board.play_quick_games(n). A quick game doesn't look at moves that involve moving cards to the hand and it generally solves the board on the order of ~2 seconds. There is no guarentee that the game will be possible without the hand (maybe ~50% to 60% are completable without it?), but it's very fast and it'll redeal the board until it completes n games. A normal game looks at the hand as a last resort and it's success rate is 100%, but it takes maybe ~20 seconds to solve and it'll keep playing until it reaches n games completed.

If your screen dimensions aren't 1920x1080, it's technically possible to modify this code to work for you, but it'll be a pain. Your game will still need to be fullscreen. You'll need to recreate all of the images in res/ and edit the constants in the Board class. Here are some steps to help you out:

  1. Recreate the images in res/. These images are special - their names matter (so keep red 10s as 0R, for example) and they're square and equidistant. Recreate these images and make sure you don't get any pixels from the face cards in their images (I noticed the texture for the Ace & Queen get near the suit icon, so make sure those aren't in them). Remember - it needs to be the same square relative to the card for all these images.
  2. Measure the distance between the squares both horizontally and vertically, along with the distance between the top row of squares and the top of your screen, and the left column and the left of your screen. Also, you'll need the size of the square. These are the Board.square_size, Board.vertical_spacing_with_square, Board.horizontal_spacing_with_square, Board.left_offset, and Board.top_offset.
  3. Measure a card's height and width for Board.card_width and Board.card_height
  4. Get coordinates for the newgame button for newgame_x and newgame_y
  5. Calculate hand_x and hand_y. hand_x is the middle of the hand horizontally and hand_y is maybe 10% of the height from the top (it's not terribly sensitive).

I can't guarentee this will work for you, but there are no magic numbers and it should work.

Owner
Will C
I graduated from the University of Nevada, Reno with a degree Mechanical Engineering. I've been teaching myself how to program since I was 10 years old.
Will C
Vitrix is an open-source FPS video game coded in python

Vitrix is an open-source FPS video game coded in python Table of contents Usage Game Server Installing Requirements Hardware Requirements Software Req

Vitrix 1 Feb 13, 2022
2D ping pong game

pingpong 2D Ping Pong game How to play: player 1 w To move up s To move Down player 2 up To move up down To move Down To change the game settings, you

menachem 0 Mar 27, 2022
A Pygame application which generates mazes using randomized DFS (Depth-First-Search)

Maze-Generator-with-Randomized-DFS A Pygame application which generates mazes using randomized DFS (Depth-First-Search)-(Iterative implementation). Ra

Aysha sana 2 Feb 08, 2022
Rock Paper Scissors Game with PyQt5

Rock-Paper-Scissors-Game rock paper scissors is a old game that all of us played it but this time let's play with computer Description This is Rock Pa

MohammadAli.HBA 4 Nov 11, 2021
An algorithm to reach a correlated equilibrium in multiplayer games.

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games. View Demo · Report Bug · Request Fea

Omar Boufous 2 Feb 01, 2022
Rock Paper Scissors Games with Python

This is a classic Rock, Paper, Scissors game with some ASCII aesthetics. After the welcome message, the game asks you to choose between the three choices. Then it let the computer choose its choice.

p.katekomol 1 Jan 24, 2022
View your VALORANT performance in different areas of every map in the game!

Valorant-Zone-Stats Inspired by Leetify's awesome Map Zones Tool for CS:GO A simple desktop program to view your VALORANT performance in different are

Louis 76 Jan 01, 2023
Snake game made in python with the pygame library.

Pygame snake Snake game made in python with the pygame library. Requirements pip pygame Pygame Installation On the command line, type: pip install pyg

Ayza 3 Oct 02, 2022
A popular children's game developed in Python.

Pedra Papel e Tesoura Um dos jogos mais populares da infância... 🪨 📜 ✂️ 💻 Situação do projeto: Projeto finalizado ✔️ 🛠 Tecnologias: Python Tkinter

Arthur V.B.S. 2 Dec 05, 2022
MiTM proxy server for Darza's Dominion

Midnight A MiTM proxy server for Darza's Dominion, PC version. See this video for a demonstration of godmode: https://youtu.be/uoqvSxmnCJk How to use

2 Oct 24, 2022
🎅 Celebrating 2021 Christmas with the development of this game

ChristmasGame (DEVELOPING) 🎅 Celebrating Christmas with the development of this game You can also use this engine to create your game too, just empty

Érik Freitas 5 Jan 10, 2022
Pygame Raycaster made by me.

Pygame Raycaster made by me.

Sable 0 Jan 10, 2022
A fun discord bot for music, mini games, admin controls, economy, ai chatbot and levelling system

A fun discord bot for music, mini games, admin controls, economy, ai chatbot and levelling system. This bot was specially made for Dspark discord server.

2 Aug 30, 2022
Just a copied of flappy bird game made by Thuongton999

flappy-bird Just a copied of flappy bird game made by Thuongton999 Installation and Usage Using terminal (on Window) Make sure you installed Python an

ThuongTon 9 Aug 08, 2021
This is game 2048 created with moudle of python tkinter and OOP.

Game 2048 This is game 2048 created with moudle of python tkinter and OOP. This game build on classes. For start this game run: If you have python ver

0 Nov 02, 2021
PyCharge is an open-source computational electrodynamics Python simulator

PyCharge PyCharge is an open-source computational electrodynamics Python simulator that can calculate the electromagnetic fields and potentials genera

Matthew Filipovich 28 Jan 03, 2023
A Tetris Game for programming education

Tetris Game プログラミング学習を目的とした、ブロックを操作してスコアを競うゲームです。 FAQはこちら。 tutorialはこちら。 実行環境準備 Mac環境 Finder→Application→Utility→Terminalから、ターミナルを起動して以下コマンドを実行する。 # i

11 Dec 01, 2022
A small Python Library to process Game Boy Camera images

GameBEye GameBEye is a Python Library to process Game Boy Camera images. Source code 📁 : https://github.com/mtouzot/GameBEye Issues 🆘 : https://gith

Martin TOUZOT 4 Nov 25, 2022
Utility.py - a utility that offerres cool cli tools and games.

Utilty.py Utility.py is a utility that offerres cool cli tools and games. Currently the offerd games/items are: get the number, countdown, random name

bee-micizi 1 Dec 08, 2021
Tic-Tac-Toe - Tic-Tac-Toe game build With Python

Tic Tac Toe This game is very popular amongst all of us and even fun to build as

PyLaboratory 0 Feb 06, 2022