예제 #1
0
파일: bbs.py 프로젝트: berak/tron-gae
 def get(self):
     s = header();
     s += validate_form(1)
     s += """
     <table>
     <form action=/bbs/new onSubmit='return valid()' method=post>
     <tr><td align=left>
     <input type=text size=120 name=title title='title'>
     <input type=text name=author title='author'>
     <input type=submit value='start a new thread'>
     </td></tr>
     </form>
     </table>
     <p>
     <table>
     <th width=15%>from</th><th>topic</th><th width=15%>date</th>
     """
     for b in tron_db.BulletinThread.all():
         s += "<tr><td width=15%>" + b.author + ": </td><td><a href=/bbs/thread?id=" + str(b.key().id())+">" + b.title + "</a></td><td width=15%>" + str(b.date) + "</td></tr>\n"
     s += """
     </form>
     </table>
     """
     s += footer()
     self.response.out.write( s )
예제 #2
0
파일: bbs.py 프로젝트: berak/tron-gae
 def get(self):
     id = self.request.get("id")
     b = tron_db.BulletinThread.get_by_id(int(id))
     s = header();
     s += validate_form(1)
     s += "<table><th width=15%>"+b.author+":</th><th>"+b.title+"</th><th width=15%>"+str(b.date)+"</th>\n"
     for t in tron_db.BulletinEntry.all().filter('ref =',int(id)):
         s += "<tr><td width=15%>" + t.author + ": </td><td>" + t.text + "</td><td width=15%>" + str(t.date) + "</td></tr>\n"
     s += """
     </table>
     <p>
     <table>
     <tr><td>
     <form action=/bbs/add onSubmit='return valid()' method=post>
     <textarea name=text rows=2 cols=100></textarea></td><td>
     <input type=hidden name=ref value="""+str(id)+""">
     <input type=text name=author title='author'>
     <input type=submit value='add an entry'>
     </form>
     </td>
     </tr>
     </table>
     """
     s += footer()
     self.response.out.write( s )
예제 #3
0
파일: code.py 프로젝트: berak/tron-gae
    def get(self):
        res = header("submit a bot to the competition")
        res += validate_form(1)
        res += """
        <br>
        <table width=90%><tr><td>
        <form name='upload' action='/up/load' method=post enctype='multipart/form-data' onsubmit='return valid();'>
        <!--form name='upload' action='/up/load' method=post enctype='multipart/form-data'-->
        <textarea name='text' rows='30' cols='60' title='your code goes here'>def turn(board,r,c): """+'\n    '+"""return "N"</textarea>
        <br>
        <input name='name' title='botname'> &nbsp; &nbsp; &nbsp; &nbsp;
        <input type='submit' value='  upload  your   bot  '>
        </td><td valign=top>
        <br>
        First of all: it's <a href='http://python.org'>Python</a> only, sorry for that<p>
        A single function 'turn(board,r,c)' is called in each step,<br>
        you are given the board(as a row-column grid[][]), and the position of your bot.<br>
        you return the direction of your next move, one of ["N","E","S","W"] <p>
        you'll die, if you<ul><li> hit a wall('#')<li>walk onto your own tail, or into another player('1','2','3',etc)</ul>
        note, that since your code is running in a separate namespace,<br>
        you'll have to address non-const global vars as 'global'<p>
        some snippets:
        <pre>
        // roundabout
        t = 0
        DIRS=["N","E","S","W"]       
        def turn(board,r,c):
            global t
            t += 1
            t %= 4
            return DIRS[t]
            

        STEPS={'N':[-1,0],'S':[1,0],'E':[0,-1],'W':[0,1]};       
        def walk(r,c,dir): 
           return r+STEPS[dir][0], c+STEPS[dir][1]
           
        def passable(board,r,c): 
            if r<0 or c<0 or (r >= len(board)) or (c >= len(board[0])) or board[r][c] != ' ':
                return False
           
        </pre>
        </td></tr></table><br>
        """
        res += footer()
        self.response.out.write(res)		
예제 #4
0
파일: maps.py 프로젝트: berak/tron-gae
 def get(self):          
     s  = header( "maps" )
     s += validate_form(1)
     s += """
     <form action=/maps/up method=post enctype='multipart/form-data' onSubmit="return valid()">
     <table>
     <tr>
     <td width=20%>
     Map Author <br>
     <input type=text name='author' title='author'> <br><br>
     Map Name <br>
     <input type=text name='name' title='name'> <br><br><br><br><br>
     <input type=submit value='upload another map'>
     </td>
     <td halign=top>
     <textarea name='text' rows=10 cols=60 title='paste your map here'></textarea>
     </td>
     <td> 
     only the following chars are allowed:
     <pre>
     wall char  : '#' 
     free space : ' ' 
     players    : ['1','2','3','4'] 
     </pre>
     maps can have up to 500 walkable fields(the max size of the history for a player).<br>
     please come up with something symmetric, that gives equal chances for each player.<br>
     </td>
     </table >
     </form>
     <table border=0 width=90%>
     """
     for m in tron_db.Map.all():
         s += m.html()
     s += "</table>"
     s += footer()
     self.response.out.write( s )