Meta tags:
Headings (most frequently used words):
january, 2013, lists, python, tutorial, thursday, part, pythonbyexample, monday, 14, friday, 11, 10, wednesday, tuesday, saturday, december, 22, 2012, customizing, blog, archive, about, me, training, text, movies, versi, betelgeuse, mines, ii,
Text of the page (most frequently used words):
the (64), stars (36), self (32), and (29), this (23), list (23), share (21), lists (20), tutorial (19), #python (18), def (16), you (15), with (14), use (12), game (11), player (11), using (10), return (9), can (9), star (9), that (9), unknown (8), some (8), need (8), have (8), brightness (8), which (8), for (8), are (8), when (8), january (7), 2013 (7), pinterest (7), facebook (7), blogthis (7), email (7), posted (7), method (7), tutorials (7), tiles (7), guide (6), http (6), examples (6), methods (6), val (6), from (6), print (6), but (6), index (6), add (6), also (6), new (5), mines (5), over (5), used (5), class (5), special (5), one (5), your (5), more (5), make (5), each (5), good (5), example (5), function (5), group (5), betelgeuse (4), text (4), comment (4), uses (4), games (4), lightbird (4), net (4), larks (4), __getitem__ (4), pieces (4), easy (4), may (4), default (4), will (4), most (4), comments (4), tictactoe (4), here (4), few (4), other (4), turns (4), enemy (4), simple (3), about (3), chapter (3), part (3), versi (3), training (3), movies (3), posts (3), next (3), many (3), helpful (3), now (3), __setitem__ (3), __init__ (3), get (3), full (3), change (3), not (3), want (3), just (3), iterate (3), only (3), very (3), code (3), __iter__ (3), object (3), custom (3), container (3), starlst (3), series (3), handling (3), into (3), all (3), chapters (3), time (3), store (3), turn (3), board (3), item (3), two (3), random (3), letter (3), added (3), first (3), neat (3), lark (3), creates (3), december (2), 2012 (2), glad (2), announce (2), addition (2), post (2), has (2), usage (2), built (2), along (2), like (2), pop (2), append (2), insert (2), mutablesequence (2), collections (2), little (2), bits (2), functionality (2), following (2), aldebaran (2), enter (2), deneb (2), access (2), items (2), needed (2), later (2), attributes (2), wrapper (2), value (2), bright_stars (2), names (2), iter (2), once (2), sure (2), what (2), choice (2), cover (2), detail (2), org (2), html (2), there (2), main (2), still (2), out (2), pseudo (2), look (2), thursday (2), left (2), going (2), really (2), rockpaperscissors (2), both (2), players (2), second (2), flashcards (2), script (2), copy (2), randomized (2), removed (2), illustrates (2), returns (2), same (2), words (2), indexes (2), hidden (2), word (2), different (2), revealing (2), clone (2), play (2), even (2), interface (2), empty (2), space (2), times (2), fleets (2), convenient (2), capture (2), ray (2), then (2), nextgroup (2), instructions (2), javascript (2), pythonbyexample (2), theme, powered, blogger, view, complete, profile, blog, archive, subscribe, atom, home, customized, explanations, able, cetera, sort, reverse, extend, count, str, __str__, del, __delitem__, len, __len__, manner, them, wanted, set, inherit, override, float, int, split, input, real, program, often, accompany, letting, naturally, did, could, alone, point, these, experiment, worry, rest, course, might, wrap, name, making, around, tuples, than, enough, cases, way, visual, measured, lower, convenience, test, fomalhaut, kind, structure, always, safe, start, customizing, goal, utility, functions, sorting, give, effbot, zone, htm, docs, datastructures, already, excellent, should, work, important, data, structures, subsequent, tips, programs, saturday, covering, page, listing, located, unlike, previous, goes, much, greater, hope, readers, who, programming, plan, expanded, version, near, future, working, kinks, format, through, perhaps, dramatically, people, books, guides, pick, choose, best, expressive, continues, where, off, introduction, written, winning, lines, contain, locations, type, collection, case, because, winlines, entire, check, winline, completed, sequence, keep, track, scores, integers, initially, corresponding, thing, getting, modifying, master, cards, temporary, card, after, shown, another, useful, property, they, shuffle, slightly, modified, utils, shuffled, exhaused, removes, last, provide, any, valid, argument, letters, ways, displaying, checked, against, operator, picked, remove, generating, probably, learn, reading, tuesday, minesweeper, url, classic, quite, fun, though, primitive, contains, nice, floodfill, algorithm, mark, neighbouring, twist, border, revealed, neighbours, stay, their, tongue, wednesday, uploaded, conquest, strategy, things, base, allow, comparison, between, various, objects, belong, provides, how, implement, having, arbitrary, number, moves, per, sometimes, skip, let, army, build, send, multiple, system, consistent, allows, configure, was, reversi, highlights, rather, approach, cast, starting, location, line, horizontal, vertical, diagonal, end, itertools, groupby, blanks, finally, groups, groupby_iterator, none, key, makes, create, piece, logic, successful, needs, success, returned, captured, tricky, think, nicely, handled, available, takes, until, move, ends, either, happen, blank, friday, cobbled, together, file, simlated, video, interactive, interpreter, session, tmovies, monday,
Text of the page (random words):
pythonbyexample pythonbyexample monday january 14 2013 python training text movies i have cobbled together a script that creates training text movies that use a instructions text file and some javascript the javascript creates a simlated video of an interactive interpreter session along with comments and instructions http lightbird net larks tmovies html posted by unknown at 12 54 pm 8 comments email this blogthis share to x share to facebook share to pinterest friday january 11 2013 versi tutorial a new tutorial was added to lark s python guide versi tutorial a clone of the reversi game some of the highlights a rather neat approach is used to capture enemy pieces a ray is cast from the starting location ray creates the list of all pieces in line horizontal vertical or diagonal to the end of board then i use the itertools groupby function to group tiles into player s enemy s and blanks finally a custom nextgroup function is used two times to get two next groups the nextgroup groupby_iterator default none returns a convenient wrapper object with key and group attributes or a default value if there is no next group this makes it very easy to create the piece capture logic to be successful first group needs to be enemy tiles and the second player s on success first group returned to be captured turns handling is a little tricky in this game and i think nicely handled here a player may have no turns available then the enemy takes turns until the player can make a move the game only ends when either player can make no turn which may happen when some blank tiles are still left on the board the full list of tutorials is here lark s guide posted by unknown at 2 19 pm 1 comment email this blogthis share to x share to facebook share to pinterest thursday january 10 2013 betelgeuse tutorial i ve just uploaded a new tutorial this time it s a simple space conquest strategy game betelgeuse tutorial one of the things this tutorial illustrates is the use of a base class to allow comparison between various objects that belong to players it also provides an example of how to implement a game with each player having arbitrary number of moves per turn sometimes you have to skip a few turns to let your space army build up other times you may want to send multiple fleets from different stars or even from the same star system stars and fleets have a neat consistent interface which allows convenient handling of both as with most other games in the guide you can configure it to have ai vs ai play ai vs player or player vs player posted by unknown at 2 28 pm 1 comment email this blogthis share to x share to facebook share to pinterest wednesday january 9 2013 mines tutorial i ve just added the mines clone of minesweeper game tutorial mines the main url with all tutorials is here lark s tongue guide to python it s a neat classic game and is quite fun to play even though the interface is primitive the game contains a nice example of floodfill algorithm which is used to mark empty tiles tiles with no neighbouring mines with a twist tiles that border empty tiles also have to be revealed but their neighbours stay hidden posted by unknown at 2 01 pm 1 comment email this blogthis share to x share to facebook share to pinterest tuesday january 8 2013 python lists part ii this post continues where i left off in my introduction to python lists this time i m going to look at some examples of use of lists in the games i ve written for my series of tutorials tictactoe uses lists to store winning lines which in turn contain lists of board locations a list is a good type of a collection to use in this case because when i use winlines i iterate over the entire list and check if a winline is completed by the player that s what lists are really good for going over each item in a sequence tictactoe tutorial rockpaperscissors uses a list to keep track of player scores it s a list of two integers initially both are 0 corresponding to players 1 and 2 that s a good example of the second thing lists are really good at getting and modifying items by index rockpaperscissors tutorial flashcards script uses lists to store a master copy of cards and a temporary randomized copy which has the card removed from it after it s shown this illustrates another useful property of lists they can be randomized using the built in random shuffle function i m using the slightly modified utils shuffled function in my example lists can also be exhaused using the pop method which returns a list item and removes it from the list at the same time last item by default but you can also provide any other valid index as an argument flashcards tutorial in the words game i m using a list to store indexes of hidden letters for each word this list is used in a few different ways when displaying a word each letter s index is checked against the list using in operator when revealing a random letter it is picked using random choice function when revealing a letter it s index is removed using remove method when generating the list indexes are added using the append method which is probably the first list method you learn when reading about lists in a python tutorial words tutorial posted by unknown at 1 12 am no comments email this blogthis share to x share to facebook share to pinterest thursday january 3 2013 i m glad to announce the addition of a new chapter covering the tictactoe game to my series of python tutorials tictactoe tutorial the main page with a listing of all tutorials is located here http lightbird net larks unlike the previous chapters this one goes into much greater detail and i hope will be helpful to readers who are new to python and programming i plan to make an expanded version of a few other chapters in the near future i m still working out the kinks out of the format of pseudo code i use in this chapter once i go through a few chapters i m sure it will change perhaps dramatically i ll need to look at more examples of pseudo code people use in books and guides and pick choose the best most expressive bits and pieces posted by unknown at 12 37 am no comments email this blogthis share to x share to facebook share to pinterest saturday december 22 2012 python lists part i a list is one of the most important data structures in python in this and subsequent posts i will go over the methods tips and examples of using lists in your programs i will be using python 3 3 but most of the examples should work with python 2 7 there are already some excellent tutorials that cover usage of lists http docs python org 3 3 tutorial datastructures html more on lists and http effbot org zone python list htm in this series of posts my goal is to cover some helpful utility functions for list handling go into more detail on list sorting and give some examples of list use in my game tutorials http lightbird net larks customizing lists lists are a kind of a default go to container structure in python if you re not sure what to use it s always a safe choice to start with and to change later as needed it s very easy to make a list like container to add custom functionality if you only need to iterate over the list you need to add the special __iter__ method star brightness starlst deneb 1 25 aldebaran 0 85 betelgeuse 0 42 fomalhaut 1 16 class stars object def __init__ self stars self stars stars def __iter__ self return iter self stars stars stars starlst for star in stars print star you can also use the in test print starlst 0 in stars once you have your custom container it s easy to add convenience methods class stars object def __init__ self stars self stars stars def __iter__ self return iter self stars def names self return s 0 for s in self stars def brightness self return s 1 for s in self stars def bright_stars self return s 0 for s in self stars if s 1 1 print stars names print stars bright_stars the way visual brightness is measured is that the lower the value of course you might also want to make a star class to wrap each star with name and brightness attributes but this is a good example of making a wrapper around a list of tuples which may be more than enough in many cases now if i need to access items by index i ll just need to add one more special method __getitem__ naturally if i did not need to iterate but only needed access by index i could add this special method alone my point is that it s very easy to add these special methods as you experiment with your code as you go and worry about the rest later def __getitem__ self i return self stars i letting me do print stars 0 deneb 1 25 often you ll want to accompany your __getitem__ with a __setitem__ def __setitem__ self i val self stars i val now i can change the star s brightness ok not the real star s but the one in my program i brightness input enter star and brightness split i int i stars i 1 float brightness print stars i if i enter 1 0 9 i get the following aldebaran 0 9 in this manner i can get little bits and pieces of the full list s functionality as i need them if i wanted to have a full set of list s methods i need to inherit from collections mutablesequence and override the following special methods class stars collections mutablesequence def __init__ self stars self stars stars def __len__ self return len self stars def __getitem__ self i return self stars i def __delitem__ self i del self stars i def __setitem__ self i val self stars i val def __str__ self return str self stars def insert self i val self stars insert i val now you ll be able to use methods like append count extend pop reverse sort et cetera my guide to python has many examples of usage of lists built in and customized used in many simple games along with helpful explanations http lightbird net larks in my next post i ll go over some of the uses of lists in my guide s games posted by unknown at 8 00 pm 1 comment email this blogthis share to x share to facebook share to pinterest home subscribe to posts atom blog archive 2013 6 january 6 python training text movies versi tutorial betelgeuse tutorial mines tutorial python lists part ii i m glad to announce the addition of a new chapter 2012 1 december 1 about me unknown view my complete profile simple theme powered by blogger
|