News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Bezerk game help?

Started by Scott_Bro, October 09, 2020, 01:38:22 PM

Previous topic - Next topic

Scott_Bro

I have finished the original 65536 levels.
Scroll around and see for yourself.

I am now having trouble figureing the robot a.i.
Can someone please help?

There is a room_grid array that shows each cells surrounding walls.

http://www.retrogamedeconstructionzone.com/2020/03/decoding-berzerk-ai.html

here's the tutorial i'm trying to get.

Kevin, may i please get your attention.

I'm working hard on it but need some help too a bit.

Thanks and please give my code respect.
Scott B

kevin


  I was messing around with Shamus remake or sorts last year while laid up,  I do remember talking a bit about some ways to cobble together character AI..  You could try here.  Building Vic20 Shamus In PlayBASIC (Blog)
   
  The rules outlined on Decoding the Berzerk AI seem like they'd work to me. 


kevin


  Why did you remove the code ?   How is anyone meant to help then ?



 

Scott_Bro

Sorry, Did'nt think anyone wanted to help.
But here it is I've got 65536 rooms but the A.i. for the robots has got me stumped.
I've tried many things many ways but I'm really really have a hard time with it.

It's suppose to use...

If x_robot < x_Player then x_robot = x_robot +1
if x_robot > x_player then x_robot = x_robot - 1

and

if y_robot < y_player then y_robot = y_robot + 1
if y_robot > y_player then y_robot = y_robot -  1


seems easy right? well, nah!

tracking is what it mostly but which way the walls stop the robots and turn them back on is baffleing.

they say it's primitive but maybe so but to me it's diffucult as heck!!!!! to match the orginal arcade.
old school maybe but until you tried I would say it's easy pleaseeeeeazzzzzzzzzzz.

Thanks for listening to my ramble but i've also tried a couple of peoples ideas on how to approach it but to no avale.

But really if anyone one can really help it would be fantastic!!!!!

So here it is again!

Thanks,
Scottie B.


stevmjon

from what i can see from running your code, is you seem to have the robot movement rules set correct, by looking at the link in post #1.

the issue i see is the distance the robot needs to be inside the new cell. you have it stop too early when moving from one cell to a new cell. it needs to be a min distance inside the new cell before it stops. that is why it gets stuck on the wall ends.

hope this helps.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

Scott_Bro

Thanks that sort of helps a bit but...
The real issue is still just that. I can't see how to code it up and work correctly. Like as in the first link. I see it's a finite state machine also but...
I really just need help with proper movement.  It's not I repeat not! just moving to and fro cells.
Anyone who could help me code it up would be greatly appreciated.
Thanks,
Scottie B.

kevin

 
Quotethey say it's primitive but maybe so but to me it's diffucult as heck!!!!! to match the orginal arcade.
old school maybe but until you tried I would say it's easy pleaseeeeeazzzzzzzzzzz.


  Sadly that's very true,  a lot of classic games were written by highly skilled engineers having to overcome so many limitations modern coders would faint.    Did a quick search before and there's some disassembled versions of the game.  Which might not be much use directly (say writing a convertor/emulator of the logic), but you might be able to gleem some finer logic from the code.   


   Only had a quick look before, will have a look later on



Links:

  Map Generator Tidbits
  The Story Of Robotron(playlist)




Scott_Bro

Yes, That is where I learned to make the maze of 65536 rooms.

but the a.i. for the robots is what's got me so messed up.
Maybe, someone else can give it a try and show me how it's done?
I was really sticking to the original because that's what I'm shooting for.
So, If anyone could code up the robots a.i. it would be awesome!!

Thanks,
Scottie B.

stevmjon

i just made a demo to show only the robots 'movement' AI.
this is kept as close to the rules in the bezerk game in the website link.

the demo is all my code, with the bare minimum, just to showcase your first map screen. i didn't add shooting, as the movement was the focus.
you have a lot of code, and i just wanted to simplify the demo into a small one and to the point.

** just focus on the "Robots AI" tab in the demo.

NOTE: the robot may look funny sometimes in their movements, because they don't move closer to any walls than what they currently are, only towards and open wall.
so the robot may look like it is stuck on a wall end, but it will move when there is no wall between the player and robot.
i let the player move through walls for test purposes for the robots AI.

i know this is a small demo, but hope it helps,  steve
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#9
 Here's a few coin-op play through for reference.   Watching the videos there's something more going on than just compute the delta X & Y / compute for collision in those directions, if none, move.  Which is what I would have done from memory :)





Scott_Bro

Steve, Thanks for writing up a piece of code for me to look at.
I'll give it a spin soon. If your interested I could include you in the write up later. Just wonder how kevin is looking at it? Don't do quite know what you mean by...

"there's something more going on than just compute the delta X & Y / compute for collision in those directions, if none, (move). "??? Which is what I would have done from memory.

Kev, Could you please explain what you meant a bit.

Could you maybe show me a demo like steve a did?  I don't mind doing this a a combined effort and giving credit! really don't since this one is a little tricky to me anyways.

Thanks Y'All! for the help so far in my endeavors.

Scott B.


kevin

#11
PlayBASIC Code: [Select]
 //  Find the delta (distance) between robot and player

DX = PlayerX - RobotX
DY = PlayerY - RobotY


// Convert delta to movement vector /speed (in the range of -1 to 1)

MoveMentX=ClipRange(DX ,-1 , 1)
MoveMentY=ClipRange(DY , -1 , 1)


// Check grid tile ROBOT is standing in

MapGridX = RobotX / MapGridWidth
MapGridY = RobotY / MapGridHeight


// Read Map at robots position. We assume the tiles have bottom 4 bits to tag what walls that have.

// bit 0 = LEFT WALL
// bit 1 = Right WALL
// bit 2 = Top Wall
// bit 3 = Bottom Wall

Collision_WALL_BITS = Map(MapGridX,MapGridY)


// Turn our movement vector into a 4 bit mask the same as the one collision map contains
MovementMask = (MovementX<0)*1 // Check if we're moving left ?
MovementMask |= (MovementX>0)*2 // Check if we're moving right ?
MovementMask |= (MovementY<0)*4 // Check if we're moving up ?
MovementMask |= (MovementY>0)*8 // Check if we're moving down ?


// Check for collisions.

// If the tile the robot is standing upon has a WALL to the left and the robots wants top move left, we just turn it's movement off (set to zero)
if (Collision_WALL_BITS & 1 ) and MovementMask then MovementX =0

// If the tile the robot is standing upon has a WALL to the RIGHT and the robots wants top move RIGHT, we just turn it's movement off (set to zero)
if (Collision_WALL_BITS & 2 ) and MovementMask then MovementX =0

// stop y axis
if (Collision_WALL_BITS & 4 ) and MovementMask then MovementY =0
if (Collision_WALL_BITS & 8 ) and MovementMask then MovementY =0

// move the robot
RobotX+=MovementX
RobotY+=MovementY





   This is basically what I was saying above.   Compute the direction from the robot to the player, convert that to a movement vector.  Then check for intersections with the map that prohibit the BOT bot from moving in that direction.

   I'm NOT suggest this is how it's done, as it'd need more conditionals.  Such as how close the robot is allowed to moved to walls and those times where the bot move diagonals between tiles.  If you watch the videos the bots have delays and seem to move every couple of frames also.  I dunno



Scott_Bro

Thanks Kev, That's cool stuff. Your right there is a finite state machine thingy going on there I think.
But that helps with movement more like steve has done a bit too.
So, I'll look  it over for a bit before moving on but really thanks a bunch guys and I'll get back to you later.
Bye, for now.
Peace is always in!!!

Scott B.

kevin



Scott,

     was thinking about this the other day and if you strip away the game and just work on the logic for the character within one section of the grid/map.  Then work out/tweak the bot movement to follow the mouse on the various states.   Inside the same grid, bellow/above/left and right of it.   

     Although watching the video above there does seem to be some oddball cases where the bot doesn't do what I'd expect....



Scott_Bro

Kevin, I got your idea up and running a bit but now I'm having trouble once
I try to turn arrays to floats for timing variables game speed it malfunctions.
What do you think the problem may be? This time I'm really lost as soon a I change it
it flaws out. Have a look.
Thanks,
Scott B.