This document summarizes an article that discusses the financial crisis and proposed bailout. It provides background on how the housing bubble and subsequent bust led to losses for banks. Mortgage-backed securities spread risk but also enabled excessive leverage. Potential losses total hundreds of billions of dollars. While actual losses so far are smaller, future losses could be larger if housing prices decline further. The bailout aims to prevent cascading bank failures but risks moral hazard by rewarding past poor decisions.
- The document summarizes an upcoming MogileFS Summit, including an overview of MogileFS, new features in version 2.0, and future plans. Key new features include code cleanup, a more robust replication process, and configurable replication policies. Future plans include improvements to the storage nodes, database partitioning, and parallel metadata files.
This column discusses modern Python modules that can help alleviate issues caused by the Global Interpreter Lock (GIL) and enable scaling of Python applications across multiple CPU cores or machines. It notes that while the GIL simplifies the CPython implementation, it prevents true multi-threading. The column explores using multiple processes instead of threads to achieve parallelism. It highlights the subprocess module for basic cross-platform process management and Parallel Python for a more complete distributed processing solution. However, it also mentions that Parallel Python is not the only option and there are alternative solutions.
El documento habla sobre el Sistema Universitario UNIMINUTO, el cual agrupa instituciones universitarias que comparten un modelo educativo innovador con el objetivo de ofrecer educación superior de calidad y fácil acceso. Busca formar profesionales competentes y líderes de transformación social para construir un país justo. También menciona algunas metas del sistema para el año 2012.
A Probabilistic Analysis of the Rocchio Algorithm with TFIDF for Text Categor...Hiroshi Ono
This document presents a probabilistic analysis of the Rocchio algorithm, a popular text categorization method, and compares it to a naive Bayes classifier. The analysis provides theoretical insight into Rocchio's heuristics, especially its TFIDF word weighting scheme. It suggests improvements that lead to a probabilistic variant of Rocchio called PrTFIDF. An empirical comparison on six text categorization tasks shows that PrTFIDF and the naive Bayes classifier perform better than the heuristic Rocchio classifier in terms of classification accuracy.
This document summarizes an article that discusses the financial crisis and proposed bailout. It provides background on how the housing bubble and subsequent bust led to losses for banks. Mortgage-backed securities spread risk but also enabled excessive leverage. Potential losses total hundreds of billions of dollars. While actual losses so far are smaller, future losses could be larger if housing prices decline further. The bailout aims to prevent cascading bank failures but risks moral hazard by rewarding past poor decisions.
- The document summarizes an upcoming MogileFS Summit, including an overview of MogileFS, new features in version 2.0, and future plans. Key new features include code cleanup, a more robust replication process, and configurable replication policies. Future plans include improvements to the storage nodes, database partitioning, and parallel metadata files.
This column discusses modern Python modules that can help alleviate issues caused by the Global Interpreter Lock (GIL) and enable scaling of Python applications across multiple CPU cores or machines. It notes that while the GIL simplifies the CPython implementation, it prevents true multi-threading. The column explores using multiple processes instead of threads to achieve parallelism. It highlights the subprocess module for basic cross-platform process management and Parallel Python for a more complete distributed processing solution. However, it also mentions that Parallel Python is not the only option and there are alternative solutions.
El documento habla sobre el Sistema Universitario UNIMINUTO, el cual agrupa instituciones universitarias que comparten un modelo educativo innovador con el objetivo de ofrecer educación superior de calidad y fácil acceso. Busca formar profesionales competentes y líderes de transformación social para construir un país justo. También menciona algunas metas del sistema para el año 2012.
A Probabilistic Analysis of the Rocchio Algorithm with TFIDF for Text Categor...Hiroshi Ono
This document presents a probabilistic analysis of the Rocchio algorithm, a popular text categorization method, and compares it to a naive Bayes classifier. The analysis provides theoretical insight into Rocchio's heuristics, especially its TFIDF word weighting scheme. It suggests improvements that lead to a probabilistic variant of Rocchio called PrTFIDF. An empirical comparison on six text categorization tasks shows that PrTFIDF and the naive Bayes classifier perform better than the heuristic Rocchio classifier in terms of classification accuracy.
This document discusses event driven architecture (EDA) and domain driven design. It begins with an introduction to the speaker and an overview of EDA basics. It then describes problems with traditional SOA implementations, where domain logic gets split across many systems. The document proposes that exposing domain events on a shared event bus allows isolating cross-cutting functions to separate systems while keeping domain logic together. It provides examples of how this approach improves scalability and decouples systems. Finally, it outlines potential business benefits of using EDA like enabling complex event processing, business process management, and business activity monitoring on top of the domain events.
The document discusses trends and challenges facing information technology, including building a civic semantic web and waiving rights over linked data. It also discusses whether semantic technologies could permit meaningful brand relationships. The document contains a chart showing government department spending in the UK, with the Department of Health spending £105.7 billion, followed by local and regional government spending £34.3 billion, and the NHS spending £90.7 billion.
genpaxospublic-090703114743-phpapp01.pdfHiroshi Ono
This document summarizes an Erlang meeting held on July 3, 2009 in Tokyo. It discusses the gen_paxos Erlang module, which implements the Paxos consensus algorithm. Paxos is needed to solve problems like split-brains where data could become inconsistent without coordination between nodes. The document explains the key aspects of Paxos like its phases, data model in gen_paxos, and how nodes communicate through message passing in Erlang. It also provides references to related works and papers about Paxos.
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
The document discusses Scala and functional programming concepts. It provides examples of building a chat application in 30 lines of code using Lift, defining case classes and actors for messages. It summarizes that Scala is a pragmatically oriented, statically typed language that runs on the JVM and has a unique blend of object-oriented and functional programming. Functional programming concepts like immutable data structures, functions as first-class values, and for-comprehensions are demonstrated with examples in Scala.
This document is the introduction to "The Little Book of Semaphores" by Allen B. Downey. It provides an overview of the book, which uses examples and puzzles to teach synchronization concepts and patterns. The book aims to give students more practice with these challenging concepts than a typical operating systems course allows. It also discusses the book's licensing as free and open source documentation.
This document provides style guidelines for Scala developers at Twitter. It outlines recommendations for imports, implicit usage, reflection, comments, whitespace, logging, project layout, variable naming conventions, and ends by thanking people for attending.
This document introduces developing a Scala DSL for Apache Camel. It discusses using Scala features like implicit conversions, passing functions as parameters, and by-name parameters to build a DSL. It provides examples of simple routes in the Scala DSL and compares them to Java. It also covers tooling for Scala in Maven and Eclipse and caveats like interacting with Java generics. The goal is to learn basic Scala concepts and syntax for building a Scala DSL, using Camel as an example.
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
The document discusses alternative concurrency paradigms to shared-state concurrency for the JVM, including software transactional memory which allows transactions over shared memory, message passing concurrency using the actor model where actors communicate asynchronously via message passing, and dataflow concurrency where variables can only be assigned once. It provides examples of how these paradigms can be used to implement solutions like transferring funds between bank accounts more elegantly than with shared-state concurrency and locks.
This document discusses using TCP/IP for high performance computing (HPC) applications. It finds that while TCP/IP can achieve bandwidth of 1 Gbps over short distances with low latency, the bandwidth degrades significantly over wide area networks with higher latency. It investigates tuning TCP parameters like socket buffer sizes to improve performance over high latency networks.
Martin Odersky outlines the growth and adoption of Scala over the past 6 years and discusses Scala's future direction over the next 5 years. Key points include:
- Scala has grown from its first classroom use in 2003 to filling a full day of talks at JavaOne in 2009 and developing a large user community.
- Scala 2.8 will include new collections, package objects, named/default parameters, and improved tool support.
- Over the next 5 years, Scala will focus on concurrency and parallelism features at all levels from primitives to tools.
- Other areas of focus include extended libraries, performance improvements, and standardized compiler plugin architecture.
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
This document discusses alternative concurrency paradigms for the Java Virtual Machine (JVM). It begins with an agenda and discusses how Moore's Law no longer solves concurrency problems as processors are becoming multi-core. It then discusses the problems with shared-state concurrency and how separating identity and value can help. The document introduces software transactional memory, message passing concurrency using actors, and dataflow concurrency as alternative paradigms. It uses examples of bank account transfers to demonstrate how these paradigms can be implemented and discusses their advantages over shared-state concurrency.
This document contains the schedule for a conference with sessions on various topics in natural language processing and computational linguistics. The conference will take place from September 14-16. Each day consists of morning and afternoon sessions split into parallel tracks (1a and 1b). Sessions cover areas like semantics, parsing, sentiment analysis, and more. Keynote speakers include Ricardo Baeza-Yates, Kevin Bretonnel Cohen, Mirella Lapata, Shalom Lappin, and Massimo Poesio. Presentations are 20 minutes each with coffee breaks in the mornings and poster sessions in the afternoons.
The article discusses the Guardian's Datastore project, which makes data of public interest freely available online for reuse. Some key points:
- The Datastore contains datasets on topics like MPs' expenses, carbon emissions, and public opinion polls. This data was previously hard to access but the web now allows easy access to billions of statistics.
- Making this data open and machine-readable supports the Guardian's tradition of fact-checking and transparency. It also encourages others to analyze and build upon the data in new ways.
- An early example involved crowdsourcing the review of 500,000 pages of MPs' expenses, revealing new insights. Other Guardian datasets like music recommendations and university rankings are now available for others
genpaxospublic-090703114743-phpapp01.pdfHiroshi Ono
This document summarizes a presentation on Paxos and gen_paxos. It introduces Paxos as a distributed consensus algorithm that is robust to network failures and allows data replication across multiple nodes. It then describes the gen_paxos Erlang implementation of Paxos, including its data model, state machine approach, and messaging between nodes. Key aspects of Paxos like the prepare and propose phases are explained through examples. The document also provides context on applications of Paxos and references for further reading.
This document discusses event driven architecture (EDA) and domain driven design. It begins with an introduction to the speaker and an overview of EDA basics. It then describes problems with traditional SOA implementations, where domain logic gets split across many systems. The document proposes that exposing domain events on a shared event bus allows isolating cross-cutting functions to separate systems while keeping domain logic together. It provides examples of how this approach improves scalability and decouples systems. Finally, it outlines potential business benefits of using EDA like enabling complex event processing, business process management, and business activity monitoring on top of the domain events.
The document discusses trends and challenges facing information technology, including building a civic semantic web and waiving rights over linked data. It also discusses whether semantic technologies could permit meaningful brand relationships. The document contains a chart showing government department spending in the UK, with the Department of Health spending £105.7 billion, followed by local and regional government spending £34.3 billion, and the NHS spending £90.7 billion.
genpaxospublic-090703114743-phpapp01.pdfHiroshi Ono
This document summarizes an Erlang meeting held on July 3, 2009 in Tokyo. It discusses the gen_paxos Erlang module, which implements the Paxos consensus algorithm. Paxos is needed to solve problems like split-brains where data could become inconsistent without coordination between nodes. The document explains the key aspects of Paxos like its phases, data model in gen_paxos, and how nodes communicate through message passing in Erlang. It also provides references to related works and papers about Paxos.
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
The document discusses Scala and functional programming concepts. It provides examples of building a chat application in 30 lines of code using Lift, defining case classes and actors for messages. It summarizes that Scala is a pragmatically oriented, statically typed language that runs on the JVM and has a unique blend of object-oriented and functional programming. Functional programming concepts like immutable data structures, functions as first-class values, and for-comprehensions are demonstrated with examples in Scala.
This document is the introduction to "The Little Book of Semaphores" by Allen B. Downey. It provides an overview of the book, which uses examples and puzzles to teach synchronization concepts and patterns. The book aims to give students more practice with these challenging concepts than a typical operating systems course allows. It also discusses the book's licensing as free and open source documentation.
This document provides style guidelines for Scala developers at Twitter. It outlines recommendations for imports, implicit usage, reflection, comments, whitespace, logging, project layout, variable naming conventions, and ends by thanking people for attending.
This document introduces developing a Scala DSL for Apache Camel. It discusses using Scala features like implicit conversions, passing functions as parameters, and by-name parameters to build a DSL. It provides examples of simple routes in the Scala DSL and compares them to Java. It also covers tooling for Scala in Maven and Eclipse and caveats like interacting with Java generics. The goal is to learn basic Scala concepts and syntax for building a Scala DSL, using Camel as an example.
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
The document discusses alternative concurrency paradigms to shared-state concurrency for the JVM, including software transactional memory which allows transactions over shared memory, message passing concurrency using the actor model where actors communicate asynchronously via message passing, and dataflow concurrency where variables can only be assigned once. It provides examples of how these paradigms can be used to implement solutions like transferring funds between bank accounts more elegantly than with shared-state concurrency and locks.
This document discusses using TCP/IP for high performance computing (HPC) applications. It finds that while TCP/IP can achieve bandwidth of 1 Gbps over short distances with low latency, the bandwidth degrades significantly over wide area networks with higher latency. It investigates tuning TCP parameters like socket buffer sizes to improve performance over high latency networks.
Martin Odersky outlines the growth and adoption of Scala over the past 6 years and discusses Scala's future direction over the next 5 years. Key points include:
- Scala has grown from its first classroom use in 2003 to filling a full day of talks at JavaOne in 2009 and developing a large user community.
- Scala 2.8 will include new collections, package objects, named/default parameters, and improved tool support.
- Over the next 5 years, Scala will focus on concurrency and parallelism features at all levels from primitives to tools.
- Other areas of focus include extended libraries, performance improvements, and standardized compiler plugin architecture.
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
This document discusses alternative concurrency paradigms for the Java Virtual Machine (JVM). It begins with an agenda and discusses how Moore's Law no longer solves concurrency problems as processors are becoming multi-core. It then discusses the problems with shared-state concurrency and how separating identity and value can help. The document introduces software transactional memory, message passing concurrency using actors, and dataflow concurrency as alternative paradigms. It uses examples of bank account transfers to demonstrate how these paradigms can be implemented and discusses their advantages over shared-state concurrency.
This document contains the schedule for a conference with sessions on various topics in natural language processing and computational linguistics. The conference will take place from September 14-16. Each day consists of morning and afternoon sessions split into parallel tracks (1a and 1b). Sessions cover areas like semantics, parsing, sentiment analysis, and more. Keynote speakers include Ricardo Baeza-Yates, Kevin Bretonnel Cohen, Mirella Lapata, Shalom Lappin, and Massimo Poesio. Presentations are 20 minutes each with coffee breaks in the mornings and poster sessions in the afternoons.
The article discusses the Guardian's Datastore project, which makes data of public interest freely available online for reuse. Some key points:
- The Datastore contains datasets on topics like MPs' expenses, carbon emissions, and public opinion polls. This data was previously hard to access but the web now allows easy access to billions of statistics.
- Making this data open and machine-readable supports the Guardian's tradition of fact-checking and transparency. It also encourages others to analyze and build upon the data in new ways.
- An early example involved crowdsourcing the review of 500,000 pages of MPs' expenses, revealing new insights. Other Guardian datasets like music recommendations and university rankings are now available for others
genpaxospublic-090703114743-phpapp01.pdfHiroshi Ono
This document summarizes a presentation on Paxos and gen_paxos. It introduces Paxos as a distributed consensus algorithm that is robust to network failures and allows data replication across multiple nodes. It then describes the gen_paxos Erlang implementation of Paxos, including its data model, state machine approach, and messaging between nodes. Key aspects of Paxos like the prepare and propose phases are explained through examples. The document also provides context on applications of Paxos and references for further reading.
1. ÿ ÿ ÿ 0o 0X0•0k
g, ‹ ^§0oR _À ÿ^R } € 0’[þ Œa0k 0 Pygame 0’O• 0c0f Python0nO• 0D 0h0 Python0nSï€ý
e¹
`' 0k0d0D0f ‰æ0Œ0f 0‚0‰ 0F0S0h0’vîv„ 0h0W 0J 0Š0~0Y0
0f
ÿ ÿ ÿ ‰•0Á0§0Ã0¯0j Pythone‡lÕ
g, ‹ ^§0’S×0Q0‹0k0B0_ 0Š0 k! 0ne‡lÕ 0` 0Q0o‰š0H0~0W0‡0F0 0B0~0Š}00K0D0S0h0ofø 0M0~0[
0“0n0g 0 }00K •èR 0oGoogleQH 0k0J ˜X0D0W
0D u 0~0Y0
0¤0ó0Ç0ó0È0h0³0á0ó0È ‘MR B
0L0j 0O0j 0‹0~0g0 A 1
0k 0d0Z
Pyt hon0o0¤0ó0Ç0ó0È0gQæt 0Ö0í0Ã0¯ 0dNãQe0W fø 0D0_Qæt 0’}š0Q0~0Y0 0‚
0
0’lz 0•0~0Y0 0] 0n0_0•0 0¤0ó0Ç0ó0È0o 0W0 VÞVÞ0W
10 0_0D0j 0‰0 B r ange( 10)
0’
]) 0U0j 0D0ˆ0F0kl 0’0d0Q0~0W0‡0F0 0Ï 0h0W0~0W0‡0F0 0Y0‹0h0 A 0ÿ^ 90L
0k
0ü0É0¿0Ö0’O• 0F0hi} 0Á0ó0g0Y0 NãQe0U0Œ0f 0 10
VÞVÞ0Š0~0Y0
0³0á0ó0È0o #0g0Y0 #Nå–MˆLg+0~0g
0³0á0ó0Èbq0D0k0j 0Š0~0Y0 Wi l ee‡
h
c [š ga Nö0L FA SE0k0j 0‹0~0g^ö0 VÞ
L
Y ep 0Y0k0o0S0Œ0’O• 0D0~0Y0 c [š ga Nö0’
Pyt hon0g0o0 Y ep 0kOU
0g0‚Qe0Œ0‰0Œ TR E
U0kVú[š 0Y0Œ0p0 q! –P0ë0ü0×0n[Œ b
0~0Y0 ep [W 0•0F0Le‡[W 0•0F0L0 •¢
0` 0` 0g0Y0
ep 0` 0•0F0L‘M 0` 0•0F0L0É0ó0hge0D0g
R
0Y0 O• 0De¹0o0 x = 1 0• 0_0D0k0 =0n w i l e ga Nöe‡ :
h
]æ •º0kY epT 0’0 Só•º0kNãQe0Y0‹0D0• # 0S0S0kQæt Q…[¹
0D0•0’fø 0M0~0Y0
•¢ep 0h0¯0é0¹
f ore‡ N uj ‘͉•0j 0‚0n0g0Y0L0 0] 0Œ0’fø 0O
0×0í0°0é0à0nR)p¹0o0 SX RÕO 0’šØ
} 0k0o0 0S0nOY
v}0g0orí 0Y0N0~0Y0n0g0
• 0kˆL0F0S0h0g0Y0 Fore‡ 0’O• 0F0S0h ‹ ^§0nN-0g‰š0H0f 0O0` 0U0D0
0g0 c [š VÞep 0 Y}0M 0` 0Q~p0Š•Ô0W
0j RÕ
O 0’0W 0O0Œ0~0Y0 fø 0M 0ok! 0n0h0J
0f e¹ ˆLg+
0Š0 C 0i 0h•U0D0 ˆLg+0kÿ 0o0D0Š0~0[
0j
0“0 0d0Q0f 0‚RÕ0M0~0Y0L0 kc 0W0De‡ lÕ
f or A i n B: 0oOU
0‚0d0Q0j 0D0 0g0Y0 0d0Q0f 0‚iË 0D
# 0S0S0kQæt 0’fø 0O 0~0[ 0“0L0
2. Pygame 0’O• 0c0f u; —b0’ˆhy: 0Y0‹
•i _S0j 0Ç 0£0ì0¯0È0ê0’O 0Š0 0] 0nN-0k 0 01.py 0 0h0D0F0Õ0¡0¤0ë0’O 0c0f 0 0Æ0-0¹ 0È0¨
0Ç 0£0¿0j 0i 0g•‹ 0M k! 0n0× 0í0°0é0à0’QeR›0W 0O 0U
0 0f 0` 0D0 QH ˆLNå 0n0³0á0ó 0È0oQe0Œ0j
˜- Y
0O 0‚0D
0f 0D0g0Y0
#- *- codi ng: s j i s - *-
i m or t pygam
p e
f r om pygam . l ocal s i m or t *
e p
def m i n( ) :
a
pygam . i ni t ( ) # pygam
e e
0nR g S
s cr een = pygam . di s pl ay. s et _m de( ( 640, 480) ) # u; —b0’O 0‹
e o
pygam . di s pl ay. set _capt i on( ' H l l o pygam ' ) # 0¿0¤0È0ë
e e e
pygam . di s pl ay. f l i p( ) # u; —b0’SÍf
e
w i l e 1:
h
f or event i n pygam . event . get ( ) : #0¤0Ù0ó0È0Á0§0Ã0¯
e
i f event . t ype == Q I T: # }BN†0Lb¼0U0Œ0_ÿ
U
r et ur n
i f ( event . t ype == K Y O N and
E DW
event . key == K ESC PE : # ESC
_ A ) 0Lb¼0U0Œ0_ÿ
r et ur n
i f __nam __ == ' __m i n__' : m i n( )
e a a
QeR›0L}B0•0c0_0‰[Ÿ ˆL0W 0• 0~0W
0f 0‡0F0 0³0ó0½0ü0ë0K0‰ python 01.py 0hQe0Œ0f [Ÿ ˆL0W 0O
0f
0` 0U0D0 u; —b0L0a 0ƒ0“ 0hQú0Œ0pb RŸ0g0Y0
; def main() 0k0d0D0f
C Š Šž0j 0i 0g0o0J 0j 0X 0n 0á0¤0ó•¢ep 0g0Y0L0 Python 0g0omain0L0j 0O 0‚0 N 0K0‰˜
0• 0f
0kQæ 0’0W 0O
t 0f 0Œ0~0Y0 0] 0n0_0• 0 NÊVÞ0n0ˆ 0F main•¢ep0oN ‰• 0h0‚Š 0H0~0Y0 0j 0‰0
0j
0j 0 fø 0O
0n0Kÿ 0h0D0F0h0
if __name__ == __main__ :
0gc [š 0U0Œ0_•¢ep 0’ 0 0S0n0¹0¯0ê0× 0È0’[Ÿ ˆL0W 0h0M
0_ 0k[Ÿ ˆL0Y0‹0ˆ 0F0k0Y0‹0K0‰0g
0Y0 0] 0n0_0• 0 ‰ ep 0Õ0¡0¤0ë0niË b 0k0j 0c0_ 0h0M 1 0d0` 0Q
0 0Æ0¹ 0È0’0W X4T 0k 0 N
0_0D
Š if e‡ 0g[Ÿ ˆL0W •¢ep 0’c [š 0Y0Œ0p 0 0] 0n0Õ0¡0¤0ë0` 0Q
0_0D 0gRÕ0K0Y0S0h0L0g0M0~0Y0
3. # - *- codi ng: s j i s - *-
i m or t pygam
p e
f r om pygam . l ocal s i m or t *
e p
def m i n( ) :
a
pygam . i ni t ( ) # pygam
e e
0nR g S
s cr een = pygam . di s pl ay. s et _m de( ( 320, 240) ) # u; —b0’O 0‹
e o
pygam . di s pl ay. set _capt i on( ' H l l o pygam ' ) # 0¿0¤0È0ë
e e e
pl ayer R ct = pygam . R ct ( 0, 0, 40, 10)
e e e
pl ayer R ct . cent er = ( 160, 200) #cÏu; 0µ0¤0º0hˆhy: OM 0’c [š
e •n
pygam . dr aw r ect ( s cr een, ( 0, 255, 128) , pl ayer R ct ) # VÛ‰Ò0’cÏu;
e . e
bal l R ct = pygam . R ct ( 0, 0, 10, 10)
e e e
bal l R ct . cent er = ( 160, 100) # cÏu; 0µ0¤0º0hˆhy: OM 0’c [š
e •n
pygam . dr aw el l i ps e( s cr een, ( 255, 128, 0) , bal l R ct ) # Q…c¥Q†0’cÏu;
e . e
w i l e 1:
h
pygam . di s pl ay. f l i p( ) # u; —b0’SÍf
e
f or event i n pygam . event . get ( ) : #0¤0Ù0ó0È0Á0§0Ã0¯
e
i f event . t ype == Q I T: # }BN†0Lb¼0U0Œ0_ÿ
U
r et ur n
i f ( event . t ype == K Y O N and
E DW
event . key == K ESC PE : # ESC
_ A ) 0Lb¼0U0Œ0_ÿ
r et ur n
i f __nam __ == ' __m i n__' : m i n( )
e a a
# end of f i l e
; pygame.draw 0h0¢0ó0Á0¨0¤0ê0¢0¹
SX Vó
} _b0oRect0„ ellipse 0nNÖ0k 0 line 0 circle 0j 0i 0L0B0Š0~0Y0 0D0Z0Œ 0‚0 N •è0’–d
0M 0¢0ó0Á0¨0¤0ê0¢0¹ ÿ 0®0¶0®0¶–dS» ÿ 0o 0U
0 0Œ0~0[ 0“ 0 0] 0n0_0• 0 Y' 0M Vó
0j _b0’cÏ0D0_
0h0M 0®0¶0®0¶0Ll 0k0j 0‹0K0‚0W
0 0Œ0~0[ 0“ 0 0] 0nX4 0o 0 2 R 0n 1 0n0µ 0¤0º0gO b 0W
T 0
0] 0n_Œ0k pygame.transform.scale2x() 0gP 0µ 0¤0º0k 0W 0~0Y0 0Y0‹0h0 0¢0ó0Á0¨0¤0ê0¢0¹0L
R¹0D0_r¶ aK0k0j 0Š0~0Yÿ 0_0` 0W scale2x0o0Ñ0ü 0Ä0g0o0j 0O —b0’ 2 P 0Y0‹0_0• 0 Vó
0 u; _bu(
0nu; —b0’O 0‹_ʼn•0L0B0Š0~0Yÿ 0
4. ÿ ÿ 0gO b 0W 0‚0n0’class0g•n 0M 0H 0 0á0ó0Æ0Ê0ó0¹0W
0_ cÛ 0f 0„0Y0O
e9• 0W0~0Y0
# - *- codi ng: s j i s - *-
i m or t pygam
p e
f r om pygam . l ocal s i m or t *
e p
cl as s Pl ayer :
def __i ni t __( sel f , s cr ) : #0¯0é0¹0nR g S
sel f . r ect = pygam . R ct ( 0, 0, 40, 10) # pl ayer0n0µ0¤0º
e e
s el f . col or = ( 0, 255, 128) # pl ayer n‚r
0
s el f . r ect . cent er = ( 160, 200) # pl ayer0n xy §j
^
s el f . s cr = s cr # u; —b0n•¢•#NØ0Q
def D aw m ge( s el f ) : # u; —b0k}u0’ˆhy:
r I a
pygam . dr aw r ect ( s el f . s cr , sel f . col or , s el f . r ect ) #VÛ‰Ò0’cÏu;
e .
def Set Pos ( sel f , x, y) : # •ê0-0ã0é0n x, y^§j 0’c [š 0Y0‹
sel f . r ect . t opl ef t = ( x, y)
cl as s B l l :
a
def __i ni t __( sel f , s cr ) : #0¯0é0¹0nR g S
s el f . r ect = pygam . R ct ( 0, 0, 10, 10) # bal l0n0µ0¤0º
e e
s el f . col or = ( 255, 128, 0) # bal l 0n‚r
s el f . r ect . cent er = ( 160, 100) # pl ayer0n xy §j
^
s el f . s cr = s cr # u; —b0n•¢•#NØ0Q
def D aw m ge( s el f ) : # u; —b0k}u0’ˆhy:
r I a
pygam . dr aw el l i ps e( s el f . s cr , sel f . col or , sel f . r ect ) # Q…c¥Q†0’cÏu;
e .
def Set Pos( s el f , x, y) :
sel f . r ect . t opl ef t = ( x, y)
5. def m i n( ) :
a
pygam . i ni t ( ) # pygam
e e
0nR g S
s cr een = pygam . di s pl ay. s et _m de( ( 320, 240) ) # u; —b0’O 0‹
e o
pygam . di s pl ay. s et _capt i on( ' C ass R pl acem nt ' ) # 0¿0¤0È0ë
e l e e
pl ayer = Pl ayer ( s cr een)
bal l = B l l ( s cr een)
a
w i l e 1:
h
pl ayer . D aw m ge( )
r I a
bal l . D aw m ge( )
r I a
pygam . di s pl ay. f l i p( ) # u; —b0’SÍf
e
f or event i n pygam . event . get ( ) : #0¤0Ù0ó0È0Á0§0Ã0¯
e
i f event . t ype == Q I T: # }BN†0Lb¼0U0Œ0_ÿ
U
r et ur n
i f ( event . t ype == K Y O N and
E DW
event . key == K ESC PE : # ESC
_ A ) 0Lb¼0U0Œ0_ÿ
r et ur n
i f __nam __ == ' __m i n__' : m i n( )
e a a
# end of f i l e
; 0¯0é0¹0k0d0D0f
class0o0ª0Ö0¸0§0¯0È T 0g0o0J 0j 0X 0n€ 0H 0g 0 Python 0g0‚0‚0a 0•0“[Ÿ ˆÅ 0U
c 0• e¹ 0Œ0f 0D
0~0Y0 0³0ó0¹ 0È0é0¯0¿0o def __init__(self): 0gˆL0D0~0Y0
Python0oY ep 0’O• 0F0n0k[£ Š 0LN ‰•0n0_0• 0 C++ 0n0ˆ 0F0k0] 0n0~0~fø 0O0S0h0o0g0M0~
0[ 0“ 0
cl as s X { cl as s X:
publ i c : da t a = 0;
i nt da t a ; de f f unc ( s e l f , a ) :
voi d f unc ( i nt a ) { da t a = a ; } s e l f . da t a = a
}
data 0h0_0` SX0kfø 0O0h0 e° 0_0k data Y ep 0’O 0c0f 0W0~0D0~0Y0 0] 0n0_0• 0 0á0ó0ÐY ep 0g
0B0‹0S0h0’f y: 0Y0‹0_0• 0 this 0Ý0¤0ó0¿0hT 0X Ts0g 0 self 0’O• 0D0~0Y0
a
N Š O‹ 0o 0 ]æ Só0i 0a 0‰0‚T 0X Ts 0h0j 0Š0~0Y0
e‡ a
6. # - *- codi ng: s j i s - *-
i m or t pygam
p e
f r om pygam . l ocal s i m or t *
e p
cl as s Pl ayer :
def __i ni t __( s el f , s cr ) : #0¯0é0¹0nR g S
sel f . r ect = pygam . R ct ( 0, 0, 40, 10) # pl ayer0n0µ0¤0º
e e
s el f . col or = ( 0, 255, 128) # pl ayer n‚r
0
s el f . r ect . cent er = ( 160, 200) # pl ayer0n xy §j
^
s el f . s cr = s cr # u; —b0n•¢•#NØ0Q
def D aw m ge( s el f ) : # u; —b0k}u0’ˆhy:
r I a
pygam . dr aw r ect ( s el f . s cr , sel f . col or , sel f . r ect ) #VÛ‰Ò0’cÏu;
e .
def Set Pos ( sel f , x, y) : # •ê0-0ã0é0n x, y^§j 0’c [š 0Y0‹
s el f . r ect . t opl ef t = ( x, y)
def MveK yi n( s el f ) : # 0-0üQeR›0gyûRÕ0U0[ 0‹
o e
keyi n = pygam . key. get _pr es s ed( )
e
m =0
x
i f keyi n[ K LEFT] : m = - 2
_ x
i f keyi n[ K R G T] : m = 2
_I H x
# u; —b0ng Q…0k0 •êR 0nyûRÕQH
0nVÛ‰Ò0L[Œ Qh0k
# T+0~0Œ0f 0D0‹0j 0‰0 yûRÕ0U0[ 0‹0
i f sel f . s cr . get _r ect ( ) . cont ai ns ( s el f . r ect . m ve( m , 0) ) :
o x
sel f . r ect . m ve_i p( m , 0)
o x
; 0-0üQeR›0nSÖ_—
pyga m . ke y. ge t _pr e s s e d( )0’T| 0v 0h0 0-0ü0Ü0ü 0É0n‘M 0’•Ô 0W
e R 0~0Y0 sþ W( ¼ 0U
b 0Œ0f 0D
0‹0-0ü0k0o 1
0LQe0c0f 0J 0Š0 if gxºŠ• 0W T 0n TRUE
0 0_X4 0k0j 0Š0~0Y0 0] 0n0_0• 0 0i 0n0-
0ü0Lb¼ 0U0Œ0f 0D0‹0K0’0Á0§0Ã0¯0Y0‹0S0h0L0g0M0~0Y0
7. cl ass B l l :
a
def __i ni t __( s el f , s cr ) : #0¯0é0¹0nR g S
s el f . r ect = pygam . R ct ( 0, 0, 10, 10) # bal l0n0µ0¤0º
e e
s el f . col or = ( 255, 128, 0) # bal l 0n‚r
s el f . r ect . cent er = ( 160, 100) # pl ayer0n xy §j
^
s el f . s cr = s cr # u; —b0n•¢•#NØ0Q
s el f . scr R ct = s cr . get _r ect ( ) # 0¹0¯0ê0ü0ó0nY' 0M
e 0U
s el f . vx = 2 # x¹T 0nyûRÕ• ^¦
e
s el f . vy = - 2 # y¹T 0nyûRÕ• ^¦
e
def D aw m ge( s el f ) : # u; —b0k}u0’ˆhy:
r I a
pygam . dr aw el l i ps e( s el f . s cr , s el f . col or , s el f . r ect ) # Q…c¥Q†0’cÏu;
e .
def Set Pos( s el f , x, y) :
s el f . r ect . t opl ef t = ( x, y)
def Mve( sel f ) :
o
m = s el f . r ect . m ve( s el f . vx, s el f . vy) #yûRÕQH r ect0’SÖ_—
r o 0n
i f s el f . scr R ct . r i ght < m . r i ght or sel f . s cr R ct . l ef t > m . l ef t :
e r e r
s el f . vx = - s el f . vx # xe¹T 0nyûRÕ0’SÍŽâ0U0[ 0‹
i f s el f . scr R ct . bot t om < m . bot t om or s el f . s cr R ct . t op > m . t op:
e r e r
s el f . vy = - s el f . vy # ye¹T 0nyûRÕ0’SÍŽâ0U0[ 0‹
s el f . r ect . m ve_i p( sel f . vx, s el f . vy)
o
; u; —bzï0n•º 0ŠR$[š 0nŠ¿0ye¹
• ^80g0B0Œ0p 0 u; PÏ0n]æ zï 0L0 u; —b0n]æ zï 0kw@
0D0_0‰0 0h0D0F0ˆ 0F gaNö0g0Á0§0Ã0¯
0j
0W0~0Y0L0 Pygame 0g0o_S0_ 0Š R$[š 0’SÖ0‹pº0n 0á0½0Ã0É0Lu( a 0U0Œ0f 0D0~0Y0
Rect rectA.contains(rectB) # rectA 0k rectB 0L[Œ Qh0kT+0~0Œ0f 0D0Œ0p True
Rect rectA.colliderect(rectB) # rectA 0k rectB 0L 1 0É0Ã0È0g0‚‘Í0j 0c0f 0D0Œ0p True
Rect rectA.collidepoint(x,y) # (x,y)0n^§j 0L rectA 0k‘Í0j 0c0f 0D0Œ0p True
NÖ0k 0‚0D0O
0d0K0B0Š0~0Y0L0 Y'OS0oN Š 0g0~0K0j 0H0~0Y0 0_0` 0W contains 0„ collide
0
0o 0 0i 0ne¹T 0L0 0h0D0F X10o 0O
`Å 0Œ0~0[ 0“0n0g 0 e¹T 0kO•[X0Y0‹_S 0ŠR$[š 0nX4T 0 0] 0Œ
u( 0k0í0¸ 0Ã0¯0’}D0€_ʼn•0L0B0Š0~0Y0
8. def m i n( ) :
a
pygam . i ni t ( ) # pygam nR g S
e e
0
s cr een = pygam . di spl ay. s et _m de( ( 320, 240) ) # u; —b0’O 0‹
e o
pygam . di s pl ay. s et _capt i on( ' C as s R pl acem nt ' ) # 0¿0¤0È0ë
e l e e
pl ayer = Pl ayer ( s cr een)
bal l = B l l ( s cr een)
a
cl ock = pygam . t i m . C ock( )
e e l
w i l e 1:
h
cl ock. t i ck( 60)
pl ayer . D aw m ge( )
r I a
bal l . D aw m ge( )
r I a
pygam . di s pl ay. f l i p( ) # u; —b0’SÍf
e
s cr een. f i l l ( ( 0, 0, 0) ) #Qhu; —b0’žÒ0gXW
0Š0d0v0Y
pl ayer . MveK yi n( )
o e
bal l . Mve( )
o
f or event i n pygam . event . get ( ) : #0¤0Ù0ó0È0Á0§0Ã0¯
e
i f event . t ype == Q I T: # }BN†0Lb¼0U0Œ0_ÿ
U
r et ur n
i f ( event . t ype == K Y O N and
E DW
event . key == K ESC PE) : # ESC
_ A 0Lb¼0U0Œ0_ÿ
r et ur n
; u; —b0nfô e°
u; —b0k}u0’cÏ0D0_0‰0 k! 0n}u0’cÏ 0O 0k 0¯0ê0¢0W 0Q
RM 0j 0Œ0p 0 RM0n}u0Lk‹ 0Š0c0q0j 0W
0k
0j 0Š0~0Y0 N Š 0× 0í0°0é0à0g0o 0 screen.fill( (0,0,0) ) 0h0W 0 Qhu; —b0’XW 0d0v 0W 0D0~
0f 0Š 0f
0Y0L0 screen.fill( color, rect ) 0hc [š 0Y0Œ0p 0 rect 0nX4b@ 0Q 0Š0d0v0Y0S0h0L0g0M
0` XW 0~
0Y0
O‹ ÿ Player,Ball 0k0B0‹ Move •¢ep 0’e9• 0W 0 •êR 0nRM •n 0` 0Q 0Š
˜L 0f 0nOM XW 0d0v0Y0ˆ 0F0k
0W 0• 0ˆ 0F0
0f
9. ÿ ÿ ÿ s‰ 0’X—0„0Y
Ball 0¯0é0¹0x0n•ýR 0h0 main•¢ep 0’k! 0n 0‚0n0kfø 0M 0H 0O 0U
cÛ 0f 0` 0D0
cl ass B l l :
a
def __i ni t __( s el f , s cr , vx, vy) : # 0¯0é0¹0nR g S
s el f . r ect = pygam . R ct ( 0, 0, 10, 10) # bal l0n0µ0¤0º
e e
s el f . col or = ( 255, 128, 0) # bal l 0n‚r
s el f . r ect . cent er = ( 160, 100) # pl ayer0n xy §j
^
s el f . s cr = s cr # u; —b0n•¢•#NØ0Q
s el f . scr R ct = s cr . get _r ect ( ) # 0¹0¯0ê0ü0ó0nY' 0M
e 0U
s el f . vx = vx # x¹T 0nyûRÕ• ^¦
e
s el f . vy = vy # y¹T 0nyûRÕ• ^¦
e
&
def R f r ect ( s el f , pl R ct ) :
e e
i f s el f . r ect . col l i der ect ( pl R ct ) : # pl R ct0h•êR 0L0v0d0K0Œ0p
e e
s el f . vy = - sel f . vy
def m i n( ) :
a
&
pl ayer = Pl ayer ( s cr een)
bal l s = [ ]
f or i i n r ange( 5) :
bal l s . append( B l l ( s cr een) )
a
&
w i l e 1:
h
cl ock. t i ck( 60)
pl ayer . MveK yi n( )
o e
f or i i n r ange( 5) :
bal l s [ i ] . Mve( )
o
bal l s [ i ] . R f r ect ( pl ayer . r ect )
e
bal l s [ i ] . D aw m ge( )
r I a
pl ayer . D aw m ge( )
r I a
pygam . di s pl ay. f l i p( ) # u; —b0’SÍf
e
&
10. Main 0n•ýR 0W for 0’k! 0n 0‚0n0k•n 0M 0H 0O 0U
0_ cÛ 0f 0` 0D0
cl ass B l l :
a
def __i ni t __( s el f , s cr , vx, vy) : # 0¯0é0¹0nR g S
&
s el f . r ef cnt = 0 #_S0c0_VÞep
&
def R f r ect ( s el f , pl R ct ) :
e e
i f s el f . r ect . col l i der ect ( pl R ct ) : # pl R ct0h•êR 0L0v0d0K0Œ0p
e e
s el f . vy = - sel f . vy
s el f . r ef cnt = s el f . r ef cnt + 1
r et ur n s el f . r ef cnt
&
f or i i n r ange( l en( bal l s ) ) :
&
i f bal l s [ i ] . R f r ect ( pl ayer . r ect ) > 5: bal l s . pop( i ) ; br eak
e
; 0ê0¹ 0È0n•ýR 0hRJ–d
0ê0¹ 0È0k0o 0 append() 0’O• 0c0f •ýR 0Y0‹0S0h0L0g0M0~0Y0 0~0_ 0 0] 0n‰•} 0’mˆ
S»0Y0‹
0h0M 0 pop() 0’O• 0H
0o 0pmˆ
0Y0S0h0L0g0M0~0Yÿ kcxº0k0o 0 pop 0o push,pop 0n pop 0g0Y0n
0g 0 0] 0nP$0’SÖ 0ŠQú0W ch 0f 0‹0 0Lkc 0W O• 0D 0g0Yÿ 0
0f 0D e¹
ÿ ÿ }B0• 0Š0k
—^^80k™Æ0Q•³0g 0 0B0~0Šz• 0c•¼0“0` ‰ãŠ¬ 0‚0[ 0Z0kRÕO 0n}9NË0’0W 0_0L0 0D0K
0~0W 0L0g
0_0g0W 0K0 Python0o 0 0 –ûl` 0LNØ^ 0W 0D0~0Yÿ quot;Battery Includedquot; ÿ 0 0nvz`ó
0W 0‡0F 0f
0g 0 O• 0H0‹0é0¤0Ö 0é0ê0L0K0j 0Š ^ 0W 0D0~0Y0L0 0U
NØ 0f 0‰0k0é0¤0Ö0é0ê0’•ýR 0Y0‹0S0h0g
‚r 0 0j 0S0h0’ 0 kÔ• v„|! SX 0³0ü0Ç 0£0ó0°0gˆL 0F0S0h0L0g0M
0j 0~0Y0
NÊVÞ0o‰æ0Œ0f 0D0~0[ 0“0L0 Python 0’0¤0ó0¹ 0È0ü0ë0W 0D0j 0D
0f Nº0n0_0•0k 0 0Ð 0¤0Ê 0ê0g
‘M 0Y0‹0_0•0n0é0¤0Ö0é 0ê0‚0B0Š0~0Y0W P2P 0’RÕ0K
^ 0 0Y0_0•0n0Õ0ì0ü0à0ï0ü 0¯0‚•‹vz 0U
0Œ0f 0D0~0Y0 0~0_ 0 Windows 0g0B0Œ0p 0 IronPython 0’O• 0F0S0h0g 0 .NET Framework 0h0‚
•#d: 0L0h0Œ 0 GUINØ0n 0½0Õ 0È0’|! SX0kO 0‹0S0h0‚0g0M0~0Y0
Pygame 0o 0 0ï0ó0é0¤0Ê0ü0K0‰Y'‰•j! 0½0Õ 0È0~0g 0 0B0‰0†0‹X4—b0gm;Ž•0g0M0‹Python
0nSï€ý`' 0n0r 0h0d0g0Y0 Pygame 0` 0K0‰0h0D0c0f 0 0²0ü0àO 0Š0k 0W O• 0H 0D0 0h€ 0H
0K 0j
0‹0n0o0D0Q0~0[ 0“ 0 0°0é0Õ0’cÏ0D0_ 0Š0 |! SX GUI 0h0W O• 0c0_ 0Š0 Sï€ý`' 0oq! –PY' 0g
0j 0f
0Y0 0Y0y0f 0ovz`ó k! {, 0g0Y0 •êu10j 0×0í0°0é0ß0ó0°0’i} 0W 0~0W
0• 0‡0F0