Skip to content

Instantly share code, notes, and snippets.

@BlueNexus
BlueNexus / python2pseudo.py
Last active April 21, 2024 23:25
Python to Pseudocode converter
import os.path
import re
'''
INSTRUCTIONS
1. Create a file with the following code
2. Put the file you want to convert into the same folder as it, and rename it to "py_file.py"
3. Add a "#F" comment to any lines in the code which have a function call that doesn't assign anything (so no =),
as the program cannot handle these convincingly
4. Run the converter file
import re
python_file = '../PyROV/game.py'
workfile = None
basic_conversion_rules = {"=": "TO", "if": "IF", "==": "EQUALS", "while": "WHILE", "until": "UNTIL", "import": "IMPORT", "class": "DEFINE CLASS", "def": "DEFINE FUNCTION", "else": "ELSE", "elif": "ELSEIF", "except": "EXCEPT", "try": "TRY", "pass": "PASS"}
prefix_conversion_rules = {"=": "SET ", "#F": "CALL "}
advanced_conversion_rules = {"print": "OUTPUT", "return": "RETURN", "input": "INPUT"}
def f2list(to_list):
# Trust Fund Buddy - Bad
# Demonstrates a logical error
print( \
"""
Trust Fund Buddy
Totals your monthly spending so that your trust fund doesn't run out
(and you're forced to get a real job).
@BlueNexus
BlueNexus / thing.dm
Last active December 29, 2016 11:37
/* Stack type objects!
* Contains:
* Stacks
* Recipe datum
* Recipe list datum
*/
/*
* Stacks
*/
//#define RADDBG
var/repository/radiation/radiation_repository = new()
var/list/to_process = list()
/repository/radiation
var/list/sources = list() //All the radiation sources we know about
var/list/irradiated_turfs = list()
var/list/irradiated_mobs = list()
var/radiation_level = rand(15, 35)
for(var/area/A in all_areas)
if(!(A.z in using_map.station_levels))
continue
if(A.flags & RAD_SHIELDED)
continue
for(var/turf/T in A)
radiation_repository.irradiated_turfs[T] = radiation_level
for(var/turf/spot in to_process)
var/turf/origin = get_turf(epicentre)
var/turf/dest = spot
var/working = power
while(origin != dest)
origin = get_step_towards(origin, dest)
if(!to_process[origin])
to_process[origin] = working
working -= origin.rad_resistance
else
#define DECAY_RATE 0.1
#define RADDBG
var/repository/radiation/radiation_repository = new()
var/list/to_process = list()
/repository/radiation
var/list/sources = list()
var/list/irradiated = list()
#define DECAY_RATE 0.1
#define RADDBG
var/repository/radiation/radiation_repository = new()
var/list/to_process = list()
/repository/radiation
var/list/sources = list()
var/list/irradiated = list()
#define DECAY_RATE 0.1
#define RADDBG
var/repository/radiation/radiation_repository = new()
var/list/to_process = list()
/repository/radiation
var/list/sources = list()
var/list/irradiated = list()