CIS 488/588 Bruce R. Maxim UM-Dearborn

Slides:



Advertisements
Similar presentations
Motion in 2D o Vectors o Projectile Motion Physics -101 Piri Reis University 2010.
Advertisements

Position, Velocity and Acceleration
Linear Motion Chapters 2 and 3.
CSE 380 – Computer Game Programming Pathfinding AI
Generated Waypoint Efficiency: The efficiency considered here is defined as follows: As can be seen from the graph, for the obstruction radius values (200,
Kinematics of Particles
Fundamental concepts and terminology of Verification and Validation Verification is the process that checks whether mathematical model was implemented.
1Notes. 2 Triangle intersection  Many, many ways to do this  Most robust (and one of the fastest) is to do it based on determinants  For vectors a,b,c.
1Notes  Reference  Witkin and Baraff, “Physically Based Modelling” course, SIGGRAPH 2001  Link on the course website.
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 2 : Dynamics & Numerical Methods Goal : To write a simple physics simulation Topics: Intro.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD.
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
1 Constant Following Distance Simulations CS547 Final Project December 6, 1999 Jeremy Elson.
Sistem Kontrol I Kuliah II : Transformasi Laplace Imron Rosyadi, ST 1.
Engineering Computation and Simulation Conor Brennan Dublin City University EE317.
Javier Junquera Molecular dynamics in the microcanonical (NVE) ensemble: the Verlet algorithm.
Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
An Introduction to Programming and Algorithms. Course Objectives A basic understanding of engineering problem solving process. A basic understanding of.
Today  Table/List operations  Parallel Arrays  Efficiency and Big ‘O’  Searching.
Tom Wilson, Department of Geology and Geography tom.h.wilson Dept. Geology and Geography West Virginia University.
Motion in One Dimension
Mark Nelson Movement and physics Fall 2013
Ch. 2: Describing Motion: Kinematics in One Dimension.
The Physics of Basketball
MGS3100_04.ppt/Sep 29, 2015/Page 1 Georgia State University - Confidential MGS 3100 Business Analysis Regression Sep 29 and 30, 2015.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Why is it so hard to get rubbish in the bin?
Introduction to Particle Simulations Daniel Playne.
CH02-1 Constant Net Force.
Let’s Bounce! or Physics of Collisions Part 1 Games Fundamentals © by Jarek Francik Kingston University, London
Calculus For AP Physics C. The derivative: The derivative is the slope of a line at a particular point. The line is the graph of a function which we.
Module 10Energy1 Module 10 Energy We start this module by looking at another collision in our two inertial frames. Last time we considered a perfectly.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
1 Computer Game Physics The very basics. 2 The Basics Force F Mass m Acceleration a: a = F/m Velocity v: v = a*t Position s: s = v*t …if F is constant.
CCHS Physics Introduction to and VELOCITY Outline Vector vs. Scalar Displacement vs. Distance Speed vs. Velocity Instantaneous vs. Average Factor Label.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Building a Better Jump J. Kyle Co-founder, Minor Key Games.
Algebra Final Exam General Review Find the domain and range. Is it a function? {(2,3),(-1,0),(2,-5),(0,-3)} Domain{2,-1,0} Range{3,0,-5,-3} Is it a function?
Shawn Weatherford Saint Leo University
Winning Strategy in Programming Game Robocode
Introduction to Kinematics
Speed & Velocity.
Movement using Shaft Encoders
CIS 488/588 Bruce R. Maxim UM-Dearborn
Projectile Motion Let’s Go Skydiving! Principles of Engineering
Solving Radical Equations
Projectile Motion Let’s Go Skydiving! Principles of Engineering
6.1 Algebraic Expressions & Formulas
Motion with Constant Acceleration
Rate of Change and Accumulation Review
Introduction to Kinematics
Designing Intelligence
CIS 487/587 Bruce R. Maxim UM-Dearborn
Projectile Motion Let’s Go Skydiving! Principles Of Engineering
CIS 488/588 Bruce R. Maxim UM-Dearborn
CIS 488/588 Bruce R. Maxim UM-Dearborn
CIS 488/588 Bruce R. Maxim UM-Dearborn
Where did we stop? The Bayes decision rule guarantees an optimal classification… … But it requires the knowledge of P(ci|x) (or p(x|ci) and P(ci)) We.
Physics.
Devil Physics Baddest Class on Campus AP Physics
CIS 488/588 Bruce R. Maxim UM-Dearborn
Acceleration Continued!!
Projectile Motion Let’s Go Skydiving!.
Motion in Real and Virtual Worlds
Robotics Programming Using Shaft Encoders
Straight Line Motion (continued)
Physics 1 – Sept 7, 2018 P3 Challenge – Do Now (on slips of paper)
Describing Motion.
Presentation transcript:

CIS 488/588 Bruce R. Maxim UM-Dearborn Physics CIS 488/588 Bruce R. Maxim UM-Dearborn 12/5/2018

Newtonian Physics Successful prediction of movement requires the level understanding used by physics engines All entities have certain physical properties (velocity, acceleration, center of mass) Velocity is derivative of the position v = dx/dt Acceleration is derivative of velocity A = dv/dt 12/5/2018

Numeric Integration One big problem in physics implementations is keeping track of position changes over time Position can be defined as the integral (or accumulation) of the velocity Numeric integrators are algorithms that compute values that change over time Integrators for position and velocity as time functions might be denoted as x(t) and v(t) 12/5/2018

Euler Integration Takes approach of estimating next values for v(t) and x(t) based on the derivative and the current value v(t + t) = v(t) + a(t) t x(t + t) = x(t) + v(t) t Computationally this becomes for clock ticks x_velocity = x_velocity + x_acceleration y_velocity = y_velocity + y_acceleration player_x = player_x + x_velocity player_y = player_y + y_velocity 12/5/2018

Problems with Euler Integration Acceleration often changes between time steps t Collisions need to be dealt with during time steps t More sophisticated approaches can help the physics model, but are not usually needed from a AI perspective 12/5/2018

Perfect Intersection - 1 It is possible to use physics to predict the collision of two moving points In 3D space position and velocity are p = [px, py , pz] and v = [vx, vy , vz] The position of a player at time t will be p(t) = p + vt If s is the speed of the projectile fired from the origin (0,0,0) then position will be |p(t)| = s2t2 12/5/2018

Perfect Intersection - 2 Computationally our aiming point becomes |p + vt| = s2t2 (px + vx)2 + (py + vy)2 + (pz + vz)2 = s2t2 With an appropriate variable substitution we get at2 + bt + c = 0 We can use the quadratic equation to get t = -b – sqrt(b2 – 4ac) / 2a 12/5/2018

Perfect Intersection - 3 The coefficient values are (0 <= i <= 2) a = -s2 +  vi2 b = 2  vipi2 c =  pi2 Note the result is defined as long as the radical expression is positive (meaning the projectile is moving fast enough to hit target) The positive quadratic root predicts negative values of t and really just predicts the past 12/5/2018

Predictor – 1 Predict function implements the math model Checks for visible players first If nearby enemy is found, its position and velocity are monitored The position and velocity values are plugged into the equation 12/5/2018

Predictor – 2 Predict function implements the math model Checks for visible players first If nearby enemy is found, its position and velocity are monitored The position and velocity values are plugged into the equation 12/5/2018

Mathematical Model const Vec3f e_pos = enemy.position - position; float a = -k_ProjectileSpeed * k_ProjectileSpeed, b = 0.0f, c = 0.0f; for (int i=0; i<3; ++i) { a += enemy.velocity[i] * enemy.velocity[i]; b += e_pos[i] * enemy.velocity[i]; c += e_pos[i] * e_pos[i]; } b *= 2.0f; // use constants to determine time of intersection const float t = (-b - sqrtf(b*b - 4*a*c)) / (2*a); // direction of travel is based on velocity return enemy.position + enemy.velocity * t; 12/5/2018

Predicting Behavior – 1 When predicting movement of living things, it does not matter how well the equations and integrator performs Real world creature behavior is not governed by rules There is lots of uncertainty in forces creatures can apply and their acceleration can vary 12/5/2018

Predicting Behavior – 2 Neither AI or human players have any knowledge of internal object states Object movement is observed and velocity is estimated by 3 observations at different times Noting initial position Understand velocity by processing position change Extract acceleration by noting velocity changes Estimating velocity and acceleration based on stopped/running basis is better than lag caused by trying to average observations 12/5/2018

Simulation Algorithm Simulation can be used to predict target collisions as opposed to creating a perfect physics equations The simulation algorithm can use successive iterations to find an acceptable estimate for the point in time for the intersection of the paths of the projectile and its target 12/5/2018

12/5/2018

Finding Collision Point Using Forward Integration repeat // update enemy position during time step enemy.position += enemy.position + delta; // increment time step time += delta; // compute projectile flight time to enemy flight_time = length(enemy.position – origin) / projectile.speed; // compute distance between enemy and projectile difference = abs(time – flight_time); until((difference < threshold) or (time > max_time)); 12/5/2018

Evaluation Linear search for collision point is OK, as long as it can be found after a small number of iterations If we used a much larger time step the point of collision could be found in O(log(n)) time If the simulation goes to far, we need to back and redo the last step with a smaller delta 12/5/2018

Code Needed to Adjust Delta // if sign changes simulation has gone too far if sign XOR time < flight_time then // reverse direction and decrease delta delta = - delta / 2.0; // remember when enemy is farther than projectile sign = time < flight_time; 12/5/2018

Evaluation There are few cases where the updated version of the algorithm is preferred The author claims that in practice this approach often takes longer to compute the same result as the first algorithm A purely mathematical algorithm might be better if greater precision is needed In the first algorithm it is easier for AI to anticipate changes in enemy velocity 12/5/2018

Colin Anticipates enemy position based on what it can see Checks to see is enemy path is blocked by a wall If wall can be side-stepped enemy velocity can be adjusted by guessing If wall is major blockage simulation is halted and that point is used as a target 12/5/2018

Experimentation - 1 To emphasize benefits of prediction the animats use a blaster that fire slow projectiles Fight finish, but last long enough to evaluate animat abilities Forcing animats to shoot from great distance also showcases their prediction ability (in fact these animats will not attack “close” enemies) Simple movement code can be used to test prediction (e.g. Pinbot) 12/5/2018

Experimentation - 2 Animats need to be modified to look in direction or enemy during combat rather than in the direction of travel To allow movement without seeing the obstacles, requires the animats to use physical sensors to bounce off walls Steering behaviors are acceptable using this strategy since humans often cannot look backward while firing weapons 12/5/2018

Evaluation – 1 In many cases shooting without prediction can be acceptable (e.g. enemy close by or running in line of fire) At distance, predictions skills are surprisingly good for Colin (esp. in large areas with few turns required for movement) Moving average gives good performance, but needs to be biased toward recently observed velocity (e.g. 80%/20%) 12/5/2018

Evaluation – 2 With two animats movement prediction is essentially one dimensional When animats are on different levels requires a 2D prediction strategy The mathematical model will be fooled by a animat running up a stairway Colin will be fooled by enemies running into walls and will not shoot at them Bots using dodging tactics will also fool Colin into firing where the bot was last 12/5/2018