Aco pacMan Curriculum page of 32



Yüklə 215,5 Kb.
Pdf görüntüsü
səhifə3/7
tarix14.10.2017
ölçüsü215,5 Kb.
#4780
1   2   3   4   5   6   7

 

PacMan (Continued)

 

ACO PacMan Curriculum v2.0 



Page 8 of 32 

Scalable Game Design 



Time to Create Behaviors for your Agents 

Step 13 

Create an agent 

behavior 

 

Click on an agent 

and its behavior 

window will 

appear below the 

world. 

 

You are going to 

drop and drag 

the conditions (on 

the left) and the 

actions (on the 

right) to create 

the rules.   

 

This rule says:  

 

IF the user  presses the up arrow,  

AND I Do NOT See a Wall in the up direction, 

THEN my PacMan will move UP 

 

Tip: Click on the See condition, then the NOT button at the bottom of 

the window to make the NOT see condition. 

 

Create 3 more rules to make PacMan move right, left and down.  

  

NOTE: Click on the rule you made, then click on the +RULE button 

at the bottom of the window to create each new rule. 

 

Step 14 

Program the 

PacMan to eat 

the pellets. 

First, take a moment to think about the PacMan and the Pellets 

When the PacMan collides with the Pellets, then the Pellet 

disappears, making it look like the PacMan ate it.   

Take a look at this code when the Pellet sees the PacMan above or 

below him: It says… 

 

IF 

I see a PacMan above or below me

 

THEN

… 

erase myself (the pellet)

 


 

PacMan (Continued)

 

ACO PacMan Curriculum v2.0 



Page 9 of 32 

Scalable Game Design 



Play with adding a wait time before erase. What happens when wait 

before adding the pellet? Choose a wait time (or no wait time) that 

you think makes the eating behavior look the way you want it. 

Step 15 

Program the 

Ghosts to move 

randomly 

Click on the agent to add behaviors to that agent. 

 

How can you make the Ghost move faster or slower? Experiment with 

the number in the once every condition.  

The ghost should also move on the pellets so add a second rule! 

 

Be mindful of what will happen if both commands have the same time for 

“once every”. 

(see Appendix I: 

Guidance on Ghost’s Random Movement

 for more 

help)

 

 



Step 16 

Create rule to 

end the game 

when the 

PacMan is next to 

the Ghost 

 

Click on PacMan 

and add this rule. 

 

Note: You need a 

similar rule for 

each different 

Ghost shape. 

This second Ghost rule says:



 

 

IF I am NEXT TO at least 1 PacMan 



THEN, stop the simulation,  show a message “You lose!” AND    Reload 

the World 



Very Important Tip: Put 

 and/or 

 in your 



Game ending rule.  

 

If you forget to do thisAgentCubes Online will do the game ending rule 



over and over until you are able to type the Return Key to click the OK on 

the dialog box and then immediately after use the mouse to click on the stop 

game button 

 (the red square).  

 

If you cannot click on the stop game button before the dialog box appears, 



you must close the browser window, then open a new browser window, go to 

AgentCubes Online, find your project and click on the edit button so it opens. 

 

 

 

 



 

 

PacMan



 

 

ACO PacMan Curriculum v2.0 



Page 10 of 32 

Scalable Game Design 



Student Handout 2 

Part 2 – Making the Ghost Chase the PacMan 

 

 



Step 1: The best 

way to initialize PacMan’s S agent attribute is to set it when PacMan is drawn 

on the world because then PacMan s attribute will always start at the same value.  

 

To do this, create a new Method by clicking on the +Method button. Click on the word “on” in 



the new method’s black and yellow striped tape and change the label from “on” to “when-

creating-new-agent”.



 

 

Your when-creating-new-agent method should look as follows: 



 

 

 



If you use this method to set PacMan’s S attribute, make sure that you erase and redraw PacMan 

and then SAVE the World.  

 

So far, your Ghost just moves randomly, either just on the floor, or on the floor and the pellets…he 



doesn’t actually chase the PacMan, does he?  That’s about to change! 

 

The Ghost will intelligently seek the PacMan agent using a computational thinking pattern called 



“searching.” In this instance, we will use a specific method of searching called Hill Climbing.  

Imagine the PacMan agent emits a scent. Hill climbing is a procedure or algorithm to find the 

direction in which the scent is strongest.  

 

The scent will spread out, or be propagated, by the ground agents using a computational thinking 



pattern called “diffusion.”  Diffusion is a fundamental process (physical, biological, and social) by 

which objects move from areas of highest concentration to areas of lowest concentrations.  The 

closer to the source of the scent, the greater its value

1

.  



 

This phase of the project introduces the concept of an “agent attribute,” which is unique 

information that is stored within each occurrence of an agent. Computer scientists call this agent 

attribute a local variable

 



Yüklə 215,5 Kb.

Dostları ilə paylaş:
1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə