Jump to content
IGNORED

Adding 1-player mode to Dodgeball?


tschak909

Recommended Posts

Hey, I'd like some opinions from other engineers here, to get a direction on adding 1-player mode to Dodgeball (which is currently 2 player)

 

I'm sort of at a loss for a "robot" algorithm that would effectively traverse a playfield with horizontal and vertical obstacles, without literally "face hugging" the obstacles... The issue is of course, since this is a VCS game, there isn't enough memory to hold, for example, a vector map...

 

Is it a lost cause?

 

-Thom

 

Z7NGCSN.png

  • Like 1
Link to comment
Share on other sites

You probably have enough rom space to store a bunch (10-40) waypoints, and a list of which other points they connect to (in a way that naturally routes around walls). Then if you have to take the player "off-route" for some reason, you could use a dumb wall-hugging route to get back to a known waypoint.

 

I dunno, there's probably reasons that wouldn't work, but it was the first thing that came to my head.

  • Like 1
Link to comment
Share on other sites

I think the important behavior is that the AI agent chooses a path that appears to atticipate distant obstacles while chasing/fleeing.

 

What you could do is split the playfield into a grid with each cell being carefully designed so each cardinal direction is either blocked or allowed for every position in the entire cell. In other words if you put a wall on the bottom of the cell it should span the entire width of the cell and be flat.

 

A simple algorithm can be created to decide what the desired location is. If the AI has both balls it would want to chase the player. If neither had balls it would want to chase the closest ball etc.

 

If the AI is in the same cell as it's target you simply calculate the optimal direction and head that way. If the target is in a different cell you use a lookup table to determine which direction to head. The lookup table would have four values for each cell. Each value would be a direction to head if the target is above, below, left, or right of the AI. If it's above and left you would look up both values and combine the results. The cool part about this is that each value can only be 2 bits allowing all 4 values to fit perfectly in a single byte. I'd go with 10 cells by 10 cells so each playfield would require a 100 bytes lookup table. Since they are mirrored you could get it down to 50 bytes with a more complex algorithm, but I'd just stay with 100 and keep my sanity.

 

Of course everything should be aligned on power of 2 boundaries so bitwise operators can be used for optimal performance. Cells should be 8, 16, or 32 pixels wide/tall. Using 16x16 cells works nicely with a 160x160 playfield which is why I recommend a 10 cell by 10 cell grid.

 

If you decide to use this idea and need more details or help writing it I'd be happy to help.

 

Here's an example of a playfield where each cell is consistently limited in each direction. Cell 1,3 would have the value of left for all 4 target positions. So after picking up a ball in 1,3 the AI would immediately head back to the left so it doesn't get trapped. Cell 0,2, cell 0,3, and cell 0,4 would map to up and down only. The AI would clear the obstacle before heading to the right.

//#00001111222233334444
//0XXXXXXXXXXXXXXXXXXXX
//0X               X  
//1X       XXXXXXXXX  
//1X               XXXX
//2X   XXXXXXXX        
//2X   XXXXXXXX        
//3X       XXXX      
//3X       XXXX      
//4X   XXXXXXXX        
//4X   XXXXXXXX        
//5X                  
//5X                  
//6X                  
//6XXXXXXXXXXXXXXXXXXXX
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...