Sunday, May 29, 2011

Python game...

I've recently been working on a game written in Python. The game is a 'programming' game, in the fact that you write a program for a robot. The robot then goes into an arena, and it runs its program. The goal is to destroy the other robots, which are put there by your opponents..

One of the criteria I made for this, is that the robots have zero knowledge of where they are, and what direction they are facing. Its easy for the code to not allow the player not to have access to that in the program, but I'm making it a hard rule by writing the actual code for the robot that way. There is no code in the file that refers to position or direction. This has caused some interesting problems for me to solve.

When the robot fires its weapon, how does the app know which direction to fire it, and determine if it hit anything? How I ended up solving this is by the environment the robot is in, in my case, a 'maze' object, stores the position and the direction of the robots. When the robot fires, it creates a new 'maze action', with the robot as the parent or initiator.  Once the action is created, the maze executes it. Since the action knows the originator, the action can retrieve the position and direction from the maze, and perform its action.

Using this methodology also works really well for handling the movement of the robots. Since the robots don't know where they are, the robot asks the maze to handle the changes thats it performs.

This is really the hard way to do things. But I wanted to do this the 'right way', even though it may be more work.. Since this is my own private project, I have the luxury of time.

I have many ideas for this game, and maybe someday will make available.

No comments:

Post a Comment