

If the Spy attacks any other piece, or is attacked by any piece (including the Marshal), the Spy is defeated. Each player also has one Spy, which succeeds only if it attacks the Marshal, or the Flag. It immediately eliminates any other piece striking it, without itself being destroyed. The most numerous special piece is the Bomb (each player has six note that the Bombs cannot move) which only Miners can defuse. Piecesįor most pieces, rank alone determines the outcome, but there are special pieces. Such pre-play distinguishes the fundamental strategy of particular players, and influences the outcome of the game. Players arrange their 40 pieces in a 4x10 configuration at either end of the board. The average game has 381 moves, The number of legal positions is 10 115, The number of possible games is 10 535. In the event that a player has no movable pieces, the opponent is the winner. They are shown as lakes on the battlefield and serve as choke points to make frontal assaults less direct. Two zones in the middle of the board, each 2x2, cannot be entered by either player's pieces at any time. A piece may not move onto a square already occupied unless it attacks.

If the engaging pieces are of equal rank, both are removed. Each player moves one piece per turn, when the player wants to attack they move their piece onto a square occupied by an opposing piece, both players reveal their piece's rank the weaker piece (there are exceptions see below) is removed from the board. The ranks are printed on one side only and placed so that the players cannot identify the opponent's pieces. Typically, one player uses red pieces, and the other uses blue pieces. I'd be happy to hear about your feedback though.The object of the game is to capture the opponent's flag or cause a surrender. I'm not even sure if such a project is still (potentially) useful in this age of LLMs. This is really a prototype, so don't expect to do anything serious or useful with it. The Python AST is eventually serialized to Python code, using the standard library `ast` module.Īs the transformer deals with a lot of repetitive code, I was wondering if more high level tree rewriting techniques (à la Stratego/XT or similar tools) could be used, but couldn't find any useful resources in the Python world.This translator uses Python pattern matching (instead of the more common visitor pattern). Then a translator, which is the only interesting part of the project, transforms it into a Python AST.The JSON is transformed into an AST (Abstract Syntax Tree).The front-end is actually a PHP parser written in PHP that outputs JSON.
#Stratego game images code
The idea is that if you have (legacy) PHP code you need to rewrite in Python, it can automate at least a first pass, then work on the result to make a proper Python program. Had to switch to other projects and never had the time to make a proper release, so I have done one yesterday. I started a PHP -> Python compiler (or transpiler) last year (week-end project). Introduction to Programming with Python (from Microsoft Virtual Academy).

