Nick’s Code

Search

XNA MVP

Contact

Donate

Categories

Latest News

Twitter


follow nickgravelyn at http://twitter.com



RSS Feed

Mousey Update

Posted in Challenges on March 20, 2008 at 11:52pm.
There are no comments.

I’ve had a few people ask me to define “cheating” in the context of the Mousey challenge. They want to know if the goal is getting there the fastest and whether doing X, Y, or Z is cheating. Honestly people, it’s only cheating if you feel cheated yourself. Nobody is grading anything and nobody is winning anything. The idea is to get you to think about how to create a smart AI mouse that will find the cheese but is also fairly believeable.

From this simple mouse AI you could extrapolate out to a first person shooter AI. In a first person shooter AI the computer is the mouse and you (as the player) are the cheese. If you think in those terms, you obviously want the mouse to find the cheese eventually, but you certainly don’t just want the mouse to be psychic and know right where it is. Maybe you program your mouse to look a few spaces ahead. Or scan surrounding spaces.

So again, don’t worry about making it get there in the least number of steps. Focus on creating a compelling mouse AI. Create a mouse that has some actual intelligence and is believable. Because if you make a psychic mouse or one that walks through walls, you are really only hurting yourself.



Challenges: #1 - Mousey

Posted in Challenges on March 20, 2008 at 1:18am.
There are 20 comments.

I’m happy to announce a new way for me to help you help yourself. One thing that I noticed (and was annoyed a little by) when doing my videos was it seemed a lot of people were just watching along to copy the code and get a basic understanding. It seemed far too many people weren’t learning much so when they wanted a new feature, they simply wanted me to show them how to do it. This isn’t helping you get any better.

So what I’ve decided to do is start releasing “challenges” to the readers. The idea of each challenge is that I provide a basic template of an application or game (yes we’ll possibly do both) and you take that and see what you can come up with. The problem lots of new programmers face is that they don’t have any idea of what a reasonable goal to work for is. So what I’ve done is created a base program and given you the instructions. Then you can run off and see how well you can solve the problem.

These aren’t going to be graded or reviewed and there is no deadline; the idea is simply for you to have a goal to work towards. However you are free to discuss them in the comments, post ideas, and review each others’ work (comments with code samples WILL be deleted so use a pastebin and link it please). The other benefit of the simple challenges is that the programs themselves are simple enough with a well-defined task that it should be pretty easy to evaluate yourself.

With that I present you the first challenge: Mousey. Mousey is a simple application where you are to work on creating the AI (artificial intelligence) for a mouse trying to find some cheese in a maze. The maze handles its own rendering and the rendering of the mouse. Even the UI is created for you:

You have a MazePanel which handles the drawing of the maze and mouse for you and a few buttons for starting and stopping the test as well as generating a new random maze. In the MazePanel, the blue cell is the starting location and the yellow cell is the cheese. The mouse, when visible, is a green cell. The test tracks how many frames it takes to find the cheese and displays that when the test is completed (or aborted) so you can easily use that to work on making your mouse efficient.

Your challenge is to create a new class that derives from the included Mouse type to implement the AI needed to navigate the maze and locate the cheese. There is a MyDumbMouse class implemented already to give you some ideas for how to approach the problem. There are also lots of comments in the files, some of which containing suggestions or ideas as well.

When you first open the project, right click on MazePanel.cs and choose “View Code”. In there you will find some helpful advice as well as the Maze and MazePanel classes. The Maze panel is the “API” you will use when programming your mouse so try and study how it works. Also before opening the MazeForm in design mode, right click on the project and select “Rebuild” so that the MazePanel control is ready to use

I know this is quite a whopper of a challenge, but I wanted to really give you guys something challenging (that’s the point, right?). If you have any questions feel free to ask. Also if you create a really cool mouse AI, let me know and maybe I can host a project with some of the best AI mice included.

I enjoyed setting this up and hopefully you will all enjoy working on it (or at least enjoy reading the code I made to get it working). Let me know what you think of this challenge idea in general and this specific challenge in the comments. Good luck!

Challenge 1 - Mousey.zip