X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f996b,8f5a1c02a21987e6 X-Google-Attributes: gidf996b,public X-Google-ArrivalTime: 2001-05-09 00:22:53 PST Message-ID: <3af8f04b@e-post.inode.at> From: Albert Brandl Subject: Re: ascii art game! was: (Re: my first post feedback me please) Newsgroups: alt.ascii-art References: <3evlOmz89lHXglLQy71DSQ1s0qdC@4ax.com> User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16 (i686)) NNTP-Posting-Host: albert.lindeverlag.at Date: 9 May 2001 09:22:51 +0100 X-Trace: e-post.inode.at 989392971 albert.lindeverlag.at (9 May 2001 09:22:51 +0100) Lines: 85 Path: newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newscore.univie.ac.at!newsfeed01.univie.ac.at!e-post.inode.at!not-for-mail Xref: newsfeed.google.com alt.ascii-art:5702 > Somebody please program an ascii art game where you have to shift > lines or correct wrong tabs or non-ascii characters heheh and even > more tasks to think of.... > that would be FUN! ascii art out of the group could be used (after > asking the artists) and there could be a micro ascii art quiz ;) like > ...what does this micro ascii art show and then a multiple choice ;) > heheh it's quite easy to program such a thing. below is python code which permutes a simple ascii picture and asks the user to find out the original picture. it's not hard to modify the program such that it permutes a text file containing some ascii-art - if you are interested, please mail me. have fun! albert ps: python can be obtained from www.python.org. its easy to install (interpreters exist for various platforms) and a very good language for this kind of stuff. ---snip--- #! /usr/bin/env python import random import string def permute(l): """ returns a permutation of the list l which is different from l""" l1 = l[:] while l1 == l: length = len(l1) for idx in range(length): rnd = random.randrange(0, length) temp = l1[0] l1[0] = l1[rnd] l1[rnd] = temp return l1 def showRiddle(pic, riddle): """ presents the permuted strings and asks the user to find the original permutation""" while riddle != pic: for idx in range(len(riddle)): print idx, riddle[idx] combination=string.split(raw_input( "Enter is the right combination (e.g. 3 2 1 0 4): ")) new_riddle = [""] * len(riddle) for idx in range(len(combination)): new_riddle[idx] = riddle[string.atoi(combination[idx])] riddle = new_riddle print print "Congratulations! You have found the right combination:" print for item in riddle: print item def main(): """main function - initializes picture and permutation, calls showRiddle to present the riddle""" pic = ["+---+", "|b b|", "| u |", "| o |", "+---+"] riddle = permute(pic) showRiddle(pic, riddle) if __name__ == "__main__": main()