Mini AI contest

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

Mini AI contest

Postby Darryl » Tue Mar 21, 2006 3:13 pm

Ok I know I had promised a Risk AI, and it is finished and ready to go, but I think because of the complexity there wasn't enough interest (between 2 websites even), so I am gonna hold onto it for a bit. Anyway, what I do have is a much simpler AI that even beginners may fair well at while still giving a challenge to the regulars....drum roll please............

Announcing: A Minesweeper AI contest:

Rules:
1. You are to derive a class from the provided Player class.
2. Please remit by email (littled at gmail) one file .h or .hpp to me with your implementation.
3. You must overide all virtual functions
4. If your implementation crashes my computer or locks it up in an infinite loop you will be disqualified.
5. Entries should be submitted by April 8th 12:00pm EST
6. Winning: The player receiving the highest score wins.
7. Scoring is as follows: 1000 random boards will be created. Each player will play each of the boards. Every square you uncover that is not a bomb, you get 1 point. every time you blow up, you lose 9 points. If you complete a board(uncover all non-bombs) you get 500 points.
8. You may not call srand() in your code.
9. You may not use any tricks to call/read private members of the minefield class
10. A reference to the minefield class is passed to your class in the getMove() call. You can call any public method it has. See code below for available methods.
11. I will post a test framework in a few days, but initially I don't want to distract from the task at hand.
12. FYI: the gridsize/bomb count used is equivilent to the expert level in the windows version
13. More FYI: When instanciating a base class player, it typically scores -200 just randomly picking squares. I have created a slightly better than random player that typically scores around 20000. Both of these will be playing, but should be easy to beat. I might also enter an unofficial advance player if I have time.
14. Even More FYI: Maximum achievable points = 881000, min = -7000, Max with no wins = 372000
15. NEW The first move is guaranteed non-bomb, and because of this, I have revised scoring system. - Thanks Colin
16. NEW Not really new, but I didn't mention it before. Returning an invalid position or a square that is already uncovered will be treated as a BOMB!

17. The most important rule: Have Fun!!!


Code: Select all
Code removed in favor of download of code


Get Code Here
Last edited by Darryl on Mon Apr 03, 2006 8:30 am, edited 6 times in total.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Corsix » Tue Mar 21, 2006 4:52 pm

I have some friend who do AI coding in Lua. If I write a Player class that loads up and uses a Lua file, could they enter using that and Lua code they write?
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby MXP » Tue Mar 21, 2006 7:51 pm

I've wanted to write a program to do this for a while. Hopefully I'll have time to write it up this week.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby Darryl » Tue Mar 21, 2006 11:54 pm

Corsix wrote:I have some friend who do AI coding in Lua. If I write a Player class that loads up and uses a Lua file, could they enter using that and Lua code they write?


I don't know a thing about LUA, what kind of file would it be? dll? Give me more details on what it would require on my part.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby MXP » Tue Mar 21, 2006 11:56 pm

Is the first square you uncover guaranteed to not be a mine? This is the case for the standard Minesweeper game on Windows.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby Darryl » Wed Mar 22, 2006 1:20 am

Colin Jeanne wrote:Is the first square you uncover guaranteed to not be a mine? This is the case for the standard Minesweeper game on Windows.

After the thousands of games of minsweeper I've played, I've never realized this was the case. I didn't put this in but I I will add it. Unfortunately, this will create slightly different boards for each player as I shuffle bombs that would had been the first pick. I may have to revise scoring also, I standardized it on a random player ending as close to 0 points as possible using integers.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Re: Mini AI contest

Postby Beer Hunter » Wed Mar 22, 2006 1:58 am

Darryl wrote:11. I will post a test framework in a few days, but initially I don't want to distract from the task at hand.
Lol? Well, whatever. I made a couple of breaking changes to the interfaces, but nothing that'll give people much trouble. I eagerly await the part where people point out all my bugs. ;-)
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Re: Mini AI contest

Postby Darryl » Wed Mar 22, 2006 3:42 am

Beer Hunter wrote:I eagerly await the part where people point out all my bugs. ;-)


:lol:
I am not getting the minesleft variable. It appears you decrement it everytime you uncover an empty square. You'll run out of mines long before all the empty squares are uncovered. Just to make things clear, in my framework, you are only uncovering empty square and NOT marking bombs unlike the real game where you do mark the bombs. Additionally, like the real minesweeper, the game should end when you hit a mine
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Beer Hunter » Wed Mar 22, 2006 5:27 am

Not quite sure how I managed that one — I wanted to count the number of remaining moves. Fixed now; you may need to refresh the page.
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Darryl » Wed Mar 22, 2006 8:29 am

Code: Select all
if (!mf.isWithinBounds(pos)) throw std::logic_error("Position not within bounds");

This is not an error, however so you know, my framework treats out of bounds moves as a bomb.

Oh what the heck, I'll just post mine as well, cuz I don't want people getting confused and there's no point of you having to keep modifying yours to match mine. (see original post for link)
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Corsix » Wed Mar 22, 2006 3:17 pm

Darryl wrote:
Corsix wrote:I have some friend who do AI coding in Lua. If I write a Player class that loads up and uses a Lua file, could they enter using that and Lua code they write?


I don't know a thing about LUA, what kind of file would it be? dll? Give me more details on what it would require on my part.
Download Lua 5.1, make a static library out of all the .c files apart from lua.c and luac.c and then link that to the application you want to add lua support to. Finally add the lua src directory to the VS include directories.

Edit: Oh and found an error in the framework; when this code is called:
Code: Select all
for (size_t i = 0; i < players.size();i++)
    {
        std::cout << players[i]->getName() <<": " << scores[i] << "\n";
    }
All of the player objects that were created in the while loop wil now be out of scope and therefore it is not safe to call the method of it.
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby Alvaro » Wed Mar 22, 2006 8:02 pm

The restriction of not using srand() sounds kind of silly. It is fairly easy to find implementations of srand() and rand() online and give them different names.

What is the purpose behind this rule?

By the way, very nice idea for a contest. I'll see if I can find any time to participate,
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby Darryl » Wed Mar 22, 2006 11:28 pm

Alvaro wrote:The restriction of not using srand() sounds kind of silly. It is fairly easy to find implementations of srand() and rand() online and give them different names.

What is the purpose behind this rule?



Back when I first came to this site when Ryan did the Clue contest, I discovered an easy way to cheat using srand() (8th post down). If the player calls srand with the same seed as the framework and duplicates any rand() calls, they could duplicate any random events created in the framework, in the case of Ryans clue contest, I duplicated the picking of the 3 hidden cards that was the suspect, location and weapon. In this contest a person could regenerate the board with the known position of the bombs. Though admittedly, it would be harder here because I am not running my program in a batch the way Ryan did, so srand is only being called once for all 1ooo of my iterations which means a player could probably only cheat on the first board because there'd be no way for them to know the rand() calls the other players are making.

Unless you duplicated my compilers exact srand, using and alternative srand probably would generate a different sequence of numbers than my call to srand
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby t i l e x » Wed Mar 22, 2006 11:42 pm

Ahahahahah ! My first really really really beta try earned me -1099. I'm very far from finished though.

*Edit* I have started working on my entry and after a few hours coding I really think you should give us perhaps 1 more week. I can only really code about 1 or 2 days a week and most of the time in those days is shared between sleeping and guitar :wink:
User avatar
t i l e x
 
Posts: 3604
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)

Postby Darryl » Thu Mar 23, 2006 5:43 am

t i l e x wrote:Ahahahahah ! My first really really really beta try earned me -1099. I'm very far from finished though.

*Edit* I have started working on my entry and after a few hours coding I really think you should give us perhaps 1 more week. I can only really code about 1 or 2 days a week and most of the time in those days is shared between sleeping and guitar :wink:


Don't know if you noticed, but the deadline had been extended. or do you mean a week past the new deadline?
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Next

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests