Game Physics

Game Physics

Game Physics
Robocode Processing Loop

 

The order that Robocode runs is as follows:

  • All robots execute their code until taking action
  • Time is updated (currentTime++)
  • All bullets move and check for collisions
  • All robots move (heading, accel, velocity, distance, in that order)
  • All robots perform scans (and collect team messages)
  • The battlefield draws
Time (t)

 

Robocode time is measured in "ticks", which are equivalent to frames displayed on the screen. Each robot gets one turn per tick. 1 tick = 1 turn = 1 frame.

 

Distance Measurement

 

Robocode's units are basically measured in pixels, with two exceptions. First, all distances are measured with double precision, so you can actually move a fraction of a pixel. Second, Robocode automatically scales down battles to fit on the screen. In this case, the unit of distance is actually smaller than a pixel.

 

 

Acceleration (a)

 

Robots accelerate at the rate of 1 pixel/tick. Robots decelerate at the rate of 2 pixels/tick. Robocode determines acceleration for you, based on the distance you are trying to move.

 

Velocity Equation(v)

 

v = at. Velocity can never exceed 8. Note that technically, velocity is a vector, but in Robocode we simply assume the direction of the vector to be the robot's heading.

 

Distance Equation (d)

 

d = vt.

 

Max rate of rotation of robot

 

(10 - .75 * abs(velocity)) degrees / tick. The faster you're moving, the slower you turn.

 

Max rate of rotation of gun

 

20 degrees / tick. This is added to the current rate of rotation of the robot.

 

Max rate of rotation of radar

 

45 degrees / tick. This is added to the current rate of rotation of the gun.

 

Damage

 

4 * firepower. If firepower > 1, it does an additional 2 * (power - 1).

 

Velocity

 

20 - 3 * firepower;

 

GunHeat generated

 

1 + firepower / 5. You cannot fire if gunHeat > 0. All guns are hot at the start of each round.

 

Power returned on hit

 

3 * firepower.

 

With Another Robot

 

Each robot takes .6 damage. If a robot is moving away from the collision, it will not be stopped.

 

With a Wall

 

AdvancedRobots take Math.abs(velocity) * .5 - 1; (Never < 0)

 
Game physics ------------------------ 本书更像是一本物理学概论,游戏开发的部分偏少,下与不下你自己定夺。 ---------------------------------------- Trademarks Figures Tables Preface About the CD-ROM INTRODUCTION 1.1 a brief history of the world 1.2 a summary of the topics 1.3 Examples and Exercises Basic Concepts from Physics 2.1 Rigid body Classification 2.2 Rigid body Kinematics 2.2.1 Single Particle 2.2.2 Particle Systems and Continuous Materials 2.3 Newton's Laws 2.4 Forces 2.4.1 Gravitational Forces 2.4.2 Spring Forces 2.4.3 Friction and Other Dissipative Forces 2.4.4 2.4.5 Torque Equilibrium 2.5 Momenta 2.5.1 2.5.2 2.5.3 2.5.4 Linear Momentum Angular Momentum Center of Mass Moments and Products of Inertia 2.5.5 Mass and Inertia Tensor of a Solid Polyhedron viii Contents 2.6 Energy 79 2.6.1 Work and Kinetic Energy 79 2.6.2 Conservative Forces and Potential Energy 81 Chapter Rigid Body motion 87 3.1 Newtonian dynamics 88 3.2 Lagrangian dynamics 100 3.2.1 Equations of Motion for a Particle 102 3.2.2 Time-Varying Frames or Constraints 114 3.2.3 Interpretation of the Equations of Motion 117 3.2.4 Equations of Motion for a System of Particles 118 3.2.5 Equations of Motion for a Continuum of Mass 121 3.2.6 Examples with Conservative Forces 133 3.2.7 Examples with Dissipative Forces 139 3.3 Euler's Equations of motion 152 Chapter *T DEFORMABLE BODIES 161 4.1 Elasticity, stress, and strain 161 4.2 Mass-Spring Systems 164 4.2.1 One-Dimensional Array of Masses 164 4.2.2 Two-Dimensional Array of Masses 166 4.2.3 Three-Dimensional Array of Masses 170 4.2.4 Arbitrary Configurations 171 4.3 Control point deformation 173 4.3.1 B-Spline Curves 173 4.3.2 NURBS Curves 183 4.3.3 B-Spline Surfaces 187 4.3.4 NURBS Surfaces 188 4.3.5 Surfaces Built from Curves 190 4.4 Free-Form deformation 197 4.5 Implicit Surface deformation 203 4.5.1 Level Set Extraction 206 4.5.2 Isocurve Extraction in 2D Images 208 4.5.3 Isosurface Extraction in 3D Images 212 Contents IX Chapter Physics Engines 5.1 Unconstrained Motion 223 5.1.1 An Illustrative Implementation 228 5.1.2 A Practical Implementation 234 5.2 Constrained Motion 240 5.2.1 Collision Points 240 5.2.2 Collision Response for Colliding Contact 242 5.2.3 Collision Response for Resting Contact 5.2.4 An Illustrative Implementation 270 5.2.5 Lagrangian Dynamics 278 5.3 Collision detection with Convex polyhedra 280 5.3.1 The Method of Separating Axes 284 5.3.2 Stationary Objects 286 5.3.3 Objects Moving with Constant Linear Velocity 311 5.3.4 Oriented Bounding Boxes 334 5.3.5 Boxes Moving with Constant Linear and Angular Velocity 342 5.4 Collision Culling: Spatial and Temporal Coherence 348 5.4.1 Culling with Bounding Spheres 349 5.4.2 Culling with Axis-Aligned Bounding Boxes 354 5.5 Variations 361 Chapter Physics and Shader Programs 6.1 Introduction 6.2 vertex and pixel shaders 6.3 Deformation by vertex Displacement 6.4 Skin-and-Bones Animation 6.5 Rippling Ocean Waves 6.6 Refraction 6.7 Fresnel reflectance 6.8 Iridescence X Contents Chapter 7 Chapter Chapter Linear Complementarity and Mathematical Programming 7.1 Linear programming 7.1.1 A Two-Dimensional Example 7.1.2 Solution by Pairwise Intersections 7.1.3 Statement of the General Problem 7.1.4 The Dual Problem 7.2 The Linear Complementarity problem 7.2.1 The Lemke-Howson Algorithm 7.2.2 Zero Constant Terms 7.2.3 The Complementary Variable Cannot Leave the Dictionary 7.3 Mathematical Programming 7.3.1 Karush-Kuhn-Tucker Conditions 7.3.2 Convex Quadratic Programming 7.3.3 General Duality Theory 7.4 Applications 7.4.1 Distance Calculations 7.4.2 Contact Forces Differential Equations 8.1 First-Order Equations 8.2 Existence, Uniqueness, and Continuous dependence 8.3 Second-order Equations 8.4 General-Order Differential Equations 8.5 Systems of Linear Differential Equations 8.6 Equilibria and Stability 8.6.1 Stability for Constant-Coefficient Linear Systems 8.6.2 Stability for General Autonomous Systems Numerical methods 9.1 euler's method 9.2 Higher-Order Taylor Methods Contents XI 9.3 METHODS VIA AN INTEGRAL FORMULATION 462 9.4 RUNGE-KUTTA METHODS 465 9.4.1 Second-Order Methods 466 9.4.2 Third-Order Methods 468 9.4.3 Fourth-Order Method 469 9.5 multistep methods 470 9.6 Predictor-Corrector methods 472 9.7 Extrapolation methods 473 9.7.1 Richardson Extrapolation 473 9.7.2 Application to Differential Equations 474 9.7.3 Polynomial Interpolation and Extrapolation 476 9.7.4 Rational Polynomial Interpolation and Extrapolation 476 9.7.5 Modified Midpoint Method 477 9.7.6 Bulirsch-Stoer Method 478 9.8 VERLET INTEGRATION 478 9.8.1 Forces without a Velocity Component 479 9.8.2 Forces with a Velocity Component 480 9.8.3 Simulating Drag in the System 481 9.8.4 Leap Frog Method 481 9.8.5 Velocity Verlet Method 483 9.8.6 Gear's Fifth-Order Predictor-Corrector Method 485 9.9 Numerical Stability and its relationship to Physical Stability 487 9.9.1 Stability for Single-Step Methods 488 9.9.2 Stability for Multistep Methods 490 9.9.3 Choosing a Stable Step Size 491 9.10 Stiff Equations 503 Chapter Quaternions 507 10.1 rotation Matrices 507 10.2 The Classical Approach 512 10.2.1 Algebraic Operations 512 10.2.2 Relationship of Quaternions to Rotations 515 10.3 A Linear Algebraic Approach 517 Xll Contents 10.4 From rotation Matrices to Quaternions 522 Contributed by Ken Shoetnake 10.4.1 2D Rotations 523 10.4.2 Linearity 525 10.4.3 3D Rotations: Geometry 526 10.4.4 4D Rotations 529 10.4.5 3D Rotations: Algebra 531 10.4.6 4D Matrix 534 10.4.7 Retrospect, Prospect 538 10.5 Interpolation of Quaternions 539 10.5.1 Spherical Linear Interpolation 539 10.5.2 Spherical Quadrangle Interpolation 541 10.6 Derivatives of Time-Varying Quaternions 543 Appendix Linear Algebra 545 A.1 A REVIEW OF NUMBER SYSTEMS 545 A. 1.1 The Integers 545 A. 1.2 The Rational Numbers 545 A. 1.3 The Real Numbers 546 A. 1.4 The Complex Numbers 546 A. 1.5 Fields 547 A.2 Systems of Linear Equations 548 A.2.1 A Closer Look at Two Equations in Two Unknowns 551 A.2.2 Gaussian Elimination and Elementary Row Operations 554 A.2.3 Nonsquare Systems of Equations 558 A.2.4 The Geometry of Linear Systems 559 A.2.5 Numerical Issues 562 A.2.6 Iterative Methods for Solving Linear Systems 565 A.3 Matrices 566 A.3.1 Some Special Matrices 569 A.3.2 Elementary Row Matrices 570 A.3.3 Inverse Matrices 572 A.3.4 Properties of Inverses 574 A.3.5 Construction of Inverses 575 A.3.6 LU Decomposition 577 A.4 Vector Spaces 583 A.4.1 Definition of a Vector Space 588 A.4.2 Linear Combinations, Spans, and Subspaces 593 Contents ХШ A.4.3 Linear Independence and Bases 595 A.4.4 Inner Products, Length, Orthogonality, and Projection 601 A.4.5 Dot Product, Cross Product, and Triple Products 606 A.4.6 Orthogonal Subspaces 613 A.4.7 The Fundamental Theorem of Linear Algebra 616 A.4.8 Projection and Least Squares 621 A.4.9 Linear Transformations 624 A.5 Advanced Topics 634 A.5.1 Determinants 634 A.5.2 Eigenvalues and Eigenvectors 646 A.5.3 Eigendecomposition for Symmetric Matrices 652 A.5.4 S + N Decomposition 655 A.5.5 Applications 661 Appendix Д5 Affine Algebra 669 B.I Introduction 669 B.2 Coordinate Systems 673 B.3 Subspaces 675 B.4 Transformations 676 B.5 Barycentric Coordinates 677 B.5.1 Triangles 678 B.5.2 Tetrahedra 679 B.5.3 Simplices 680 B.5.4 Length, Area, Volume, and Hypervolume 681 Appendix Calculus 691 C.I Univariate Calculus 692 UNIVARIATE CALCULUS C.1.1 С 1.2 C.1.3 С 1.4 C.1.5 С 1.6 Limits Limits of a Sequence Continuity Differentiation LHopital's Rule Integration xiv Contents C.2 MULTIVARIATE CALCULUS 704 C.2.1 Limits and Continuity 704 C.2.2 Differentiation 705 C.2.3 Integration 708 C.3 Applications 710 C.3.1 Optimization 711 C.3.2 Constrained Optimization 715 C.3.3 Derivative Approximations by Finite Differences 718 APPENDIX Ordinary Difference Equations 727 D.I Definitions 727 D.2 Linear Equations 730 D.2.1 First-Order Linear Equations 730 D.2.2 Second-Order Linear Equations 731 D.3 Constant-Coefficient equations 734 D.4 Systems of Equations 736 Bibliography 739 index
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值