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
A python script to solve Wordle puzzles

Wordle solver A python script to solve Wordle puzzles.

Felix Weinberger 1 Feb 12, 2022
Pygame Raycaster made by me.

Pygame Raycaster made by me.

Sable 0 Jan 10, 2022
Flappy Bird clone in Python using Pyglet

python_Flappy-Bird This is the Game Flappy Bird which was originally developt by Dong Nguyen under .Gears recreated in Python. Requirements (used to d

Konstantin Opora 1 Dec 10, 2021
offline bot for game on chrome

Бот офлайн игры браузера CHROME В автоматическом режиме запускает браузер Chrome под ОС windows, так же автоматически определяет разрешения экрана, на

Andrej Marinchenko 19 Dec 17, 2022
A coven of tools to assist in PnP RPGs.

pupillae A coven of tools to assist PnP RPGs. Status: Pre-alpha. Testing. Adding necessary functions and features as discovered/required. Other-than-P

0 Dec 09, 2021
The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on the spaceship.

Astronomia: let the exploration begin The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on t

Aryan Nath 8 Nov 18, 2022
Code infrastructure and player algorithms for the Codenames board game.

Codenames Code infrastructure and player algorithms for the Codenames board game. This is the active fork of mkali-personal/codenames. Intro This is b

Asaf Kali 1 May 18, 2022
XPlaneROS is a ROS wrapper for the XPlane-11 flight simulator.

XPlaneROS XPlaneROS is a ROS wrapper for the XPlane-11 flight simulator. The wrapper provides functionality for extracting aircraft data from the simu

AirLab Stacks 26 Dec 04, 2022
AI based assitant for minecarft

Minecraft_AI_assistant AI-based assistant for Minecraft There are 4 steps to build 1-I'm using collecting_data.png as a structure to take shots with c

Murat Ali Avcu 13 Oct 16, 2022
Netskrafl - an Icelandic crossword game website

Netskrafl - an Icelandic crossword game website English summary This repository contains the implementation of an Icelandic crossword game in the genr

Miðeind ehf 30 May 09, 2022
Hex-brawl-v25 - Simple Brawl Stars v25.107 server emulator written in Python

Hex Brawl Simple Brawl Stars v25.107 server emulator written in Python. Requirem

Shark01 3 Nov 24, 2022
Fully functional BlackJack game with a graphical user interface.

BlackJack Welcome to BlackJack! This game is fully functional, with a casino sound package integrated using Pygame, dynamic game logic developed using

Shwetang Desai 2 Jan 10, 2022
Searches the word list in Wordle based on search pattern.

Wordle Searcher Searches the word list in Wordle based on search pattern. Warning: like all forms of cheating, it trivializes the game, and robs you o

Tyler Martin 1 Jan 29, 2022
使用python编写2048游戏及自动玩

使用python编写2048游戏及自动玩

tiger-wang 68 Dec 23, 2022
Lucky Balls is gambling game where user try to guess 6 numbers from 1 to 48 that computer has picked.

LUCKY BALLS Lucky Balls is gambling game where user try to guess 6 numbers from 1 to 48 that computer has picked. INSTRUCTIONS User input his bet, tha

rile037 2 Dec 28, 2021
Pygame for humans (pip install hooman) (25k+ downloads)

hooman ~ pygame for humans pip install hooman join discord: https://discord.gg/Q23ATve The package for clearer, shorter and cleaner PyGame codebases!

Abdur-Rahmaan Janhangeer 31 Nov 08, 2022
Input-based tic tac toe game made in only python.

Tic Tac Toe Tic Tac Toe is a game in which two players seek in alternate turns to complete a row, a column, or a diagonal with either three O's or thr

Ayza 5 Jun 26, 2022
Code d'un jeu en python par Graveen (avec mes modifications)

ATTENTION Vous ne devez pas copier coller le code sans le comprendre, apprennez déjà, le python et pygame, et seulement ensuite, vous pourrrez l'utili

TheBigWolfy 7 Nov 02, 2022
WIP python/pygame 2D zombie shooter

2d-shooter project A single/multiplayer co-op survival small space zombie shooter. If you'd like to contribute, feel free to join the discord! INSTALL

36 Dec 08, 2022
Implementation of the Spider-Man Game

Projeto FPRO FPRO/LEIC, 2021/22 Francisco Campos (up202108735) 1LEIC08 Objetivo Criar um clone do clássico Spider-Man em Pygame... Repositório de códi

1 Dec 24, 2021