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
Setup minecraft server (Tuinity) to your directory

hapeshiva server-setup Setup minecraft server (Tuinity) for you. Support for optimization Create optimized yml Customazible server port and view dista

3 May 11, 2022
Cricket game using PYQT

Cricket-game-using-PYQT This is a Fantasy cricket Desktop application build in p

Sanket Mane 1 Jan 03, 2022
3 Oct 22, 2021
A python script that uses pygame to display fractals.

Pygame-Fractals A python script that uses pygame to display interactive fractals. There are 3 fractals on the script. They can be displayed on the col

michel 2 Feb 09, 2022
This is a simple game of rock-paper-scissors developed in Python

This is a simple game of rock-paper-scissors developed in Python. It allows two players to play with one another on different command lines through networking.

NAMAN JAIN 3 Oct 21, 2022
A Game of Life implementation in Python

Game of Life in Python (Golipy) Golipy is a simulator of John H. Conway's Game of Life, developed in Python based on the Pygame library. This is a toy

Alber 2 Dec 10, 2021
This is a good project to train your logic game with python language

JO-KEN-PÔ!!! | Description | basic. I make this game only to train. This is a good project to train your logic game with python language. This game is

Elianderson Silva 1 Jan 24, 2022
TicTacToc - Simple TicTacToc game played by minimax algorithm

TicTacToc simple TicTacToc game played by minimax algorithm. This app is based o

5 Apr 05, 2022
🐍 Conway's Game of Life cellular automaton implemented in PyGame

Conway's Game of Life My PyGame implementation of Conway's Game of Life. This implementation involves treating all edges of the grid as stitched toget

Mateusz Żebrak 1 May 29, 2022
Flappy Bird Game using Pygame in Python

Flappy Bird Game using Pygame in Python Demo Pages Hello dear, hope you are very well! I created Flappy Bird Game using Pygame ( Pygame is a cross-pla

Datt Panchal 3 Feb 05, 2022
Typing Game : from nob to good

Fast and Curious A game to learn/improve keyboard typing skills. The main idea is to improve your typing skills and at the same time learn fun facts (

Raffaele Fiorillo 7 Jun 13, 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
SuperChess is a GUI application for playing chess.

About SuperChess is a GUI application for playing chess. It is written in Python 3.10 programming language, uses PySide6 GUI library, python-chess lib

Boštjan Mejak 1 Oct 16, 2022
This is a basic virtual quiz game using opencv-python

Basic Virtual-Quiz-Game This is a basic structure of a virtual quiz game using opencv-python. As the camera window opens up we can see the questions a

2 Dec 11, 2021
Space Invaders x Asteroid Game

Retro Journey 1: Space Invaders A simple implementation of a retro style video game where users compete against asteroids and the goal is to destroy a

Sandesh Lamsal 2 Aug 05, 2022
Replicating Minecraft World Generation in Python

Minecraft World Generation in Python This is an attempt to replicate Minecraft world generation in Python. This is part of an article published on Med

Bilal Himite 159 Dec 19, 2022
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
2DMC is an abrrieviation for 2 Dimensional Minecraft.

2DMC 2DMC is an abrrieviation for 2 Dimensional Minecraft. This idea is originally created and implemented by Griffpatch on Scratch. This is a persona

DaNub 5 Nov 06, 2022
Pyvidplayer - An extremely easy to use module that plays videos on Pygame

pyvidplayer An extremely easy to use module that plays videos on Pygame Example

17 Dec 05, 2022
An environment to run atari-like games in VGDL.

vgdl An environment to run atari-like games in VGDL. Requirements python = 3.6 Installation pip install -r requirements.txt Usage # Create an enviro

Sergio Arnaud Gomez 1 Dec 24, 2021