Python write fortress machine