<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hey Chris,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>That's awesome!  I have been refactoring some of the backend of kuku, but have not touched the main event loop yet - hence the current version in the main branch of the git repo is out of date of the xo that is on the wiki.  There is a branch called trial-2 in the git repo which contains code that should be very similar to the posted xo file.  You should be able to see it in the cloned repo by doing 'git checkout -b my-trial-2 origin/trial-2'.  (Also see <A href="http://wiki.laptop.org/go/Kuku/Git_Usage">http://wiki.laptop.org/go/Kuku/Git_Usage</A>)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The only changes I have done to the main kuku.py file have to do with import statements and pulling out some class definitions due to my module refactoring.  The best way to create a patch would be to do the following with git (sorry if you know this git stuff already).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>git clone (kuku repo url)</DIV><DIV>git checkout -b kuku_patch_branch</DIV><DIV>(port your patch to kuku.py)</DIV><DIV>git add kuku.py</DIV><DIV>git commit</DIV><DIV>git format-patch master..kuku_patch_branch</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>That should create a file called 0001_my-commit-message.patch.  You can send the patch to the list and I'll apply it and check it in.  If you have set your git config variables with your name and email, it will commit it as you when I apply the patch.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Right now there are no tests for the kuku.py, but there are some for the other modules (like Tile and Grid).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This is really exciting and I'm stoked that you did this.  Note that there is a lot of refactoring work that needs to be done including</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>* update wrapper code to use the Lincoln Quirk's git repository</DIV><DIV>* refactor widgets._ScreenWidget using pygame.Sprite</DIV><DIV>* unit tests for question.py in test_question.py</DIV><DIV>* refactor Scenario out of kuku and unittest</DIV><DIV>** The Scenario should take control of the pygame loop and hand control back</DIV><DIV>*** this would handle animations in the middle of the game to support a storyboard</DIV><DIV>** rewrite game_over, game_win, game_start, reset_board, etc. in terms of Scenarios</DIV><DIV>*** add more unit-tests before do this</DIV><DIV>* factor State out of kuku and unittest</DIV><DIV>** state should be expanded to allow multiplayer mode</DIV><DIV>* factor Actor and Player out of kuku and unittest</DIV><DIV>* fator QuestionAnswer out of kuku, rename and unittest</DIV><DIV>* move initialization out of kuku.py</DIV><DIV>* refactor tile and grid with pygame.Sprite classes</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I'll be on IRC later today (Sunday) around 5 or 6ish sitting in #olpc-content as jblucks if you want to chat about the patch etc.  Please feel free to keep refactoring away - the next major step will be to add collaboration to kuku which should start with refactoring the State class out of kuku.py.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>And please put your name up on the wiki page as a contributor! </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Cheers,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Julius</DIV><DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>---------------------------------------------------------------------------------------</DIV><DIV>Please Reply to My Permanent Address: <A href="mailto:julius@younglucks.com">julius@younglucks.com</A></DIV><DIV><A href="http://www.openwetware.org/wiki/User:Julius_B._Lucks">http://www.openwetware.org/wiki/User:Julius_B._Lucks</A></DIV><DIV>----------------------------------------------------------------------------------------</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN></SPAN></SPAN></SPAN> </DIV><BR><DIV><DIV>On Aug 19, 2007, at 4:20 AM, Christopher Schmidt wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">KuKu currently lags significantly when using the arrow keys. With a</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">little bit of profiling and refactoring, I was able to decrease the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">level of CPU time used by KuKu by a factor of 2 on my mac. Essentially,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">only changed pieces of display are updated, rather than the whole grid</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">being updated every loop through the event loop, which was making the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">gameplay quite difficult.<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">In my experience, this turned the lag time from practicaly unplayable to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">practically unnoticable.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I attempted to put together a patch with git, but when I git-cloned the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">repo, it didn't come anywhere near to matching the code that is in the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">current .xo from the wiki: Which one is more up to date/should I be</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">using? (I can port my patch over -- it's primarily to the main event</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">loop of the game only.)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">How should I create a patch? Are there tests I should be running?<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I created <A href="https://dev.laptop.org/ticket/2900">https://dev.laptop.org/ticket/2900</A> to upload the patch, and</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">will put it there if anyone can help me figure out what I need to do to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">create it.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://crschmidt.net/olpc/KukuAnakula.xo">http://crschmidt.net/olpc/KukuAnakula.xo</A> is the current version of the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">code I've written.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://crschmidt.net/olpc/Kuku-original.profile.txt">http://crschmidt.net/olpc/Kuku-original.profile.txt</A> is the profiling</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">data before the rewrite.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://crschmidt.net/olpc/Kuku-refactor.profile.txt">http://crschmidt.net/olpc/Kuku-refactor.profile.txt</A> is the profiling</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">data after.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">This data is generated by hotshot, grepped for 'kuku' (insensitive).</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Function call counts drop from 8614 in the original to 744 in the refactor,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">for a 5 second game where I move the chicken to each of the squares.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Note that this was simply a small 'attack the largest numbers first'</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">approach -- it's possible that a more concentrated effort would be able</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">to determine more places where optimization is possible. Specifically, I</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">avoided optimizing the case where images are loaded, though I think my</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">changes to limit grid.draw() will also have the result of limiting the</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">image redraws I saw being a problem at one point.<SPAN class="Apple-converted-space">   </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Looking forward to helping if my changes are acceptable.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Regards,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Christopher Schmidt</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">MetaCarta</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Games mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Games@lists.laptop.org">Games@lists.laptop.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.laptop.org/listinfo/games">http://lists.laptop.org/listinfo/games</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>