![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: Coder's Block Arena - The Game AI Platform
Well, my algorithm works... kinda. Initially I implemented it using "X", "O" and "-" and was surprised when it broke, but it's fine now. Still loses games sometimes, so I need to work out the bugs.
It uses trees: calculates every single path (though I can specify a maximum depth), algorithmically works out which is best by working out each win and lose path and giving each one a rank based on how soon it'll happen, and goes down the best one. Here's the tutorial code in Python: import cbapi
from time import sleep
def playCBArena():
cb = cbapi.cb_arena(0)
cb.login("Trogdor the Burninator", "********", "TIC-TAC-TOE");
if cb.cmd("CHECK") != "OKAY":
return cb.cleanup()
print "Looking For Game ..."
reply = cb.cmd("GETGAME")
while reply == "WAIT":
sleep(5)
reply = cb.cmd("GETGAME")
if reply == "":
return cb.cleanup()
print "Playing against", reply
while True:
print "Waiting for turn ..."
reply = cb.cmd("GETBOARD")
while reply == "WAIT":
sleep(3)
reply = cb.cmd("GETBOARD")
if reply == "":
return cb.cleanup()
elif reply == "WIN" or reply == "LOSE" or reply == "TIE":
print "Game over:", reply
return cb.cleanup()
# Make Move By Updating One Of The Pieces In 'reply'
reply = cb.cmd(reply)
if reply != "OKAY":
print "Disqualified For Illegal Move Or Timed Out"
return cb.cleanup()
else:
print "Made Move"
return cb.cleanup()
if __name__ == "__main__":
playCBArena()Last edited by Ooble; Mar 24th, 2008 at 9:33 PM. Reason: Removed a couple things that are part of my code only. |
|
|
|
|
|
#12 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: Coder's Block Arena - The Game AI Platform
Sane, I'm not sure, but you can bet I'll be testing it and figuring out why.
![]() |
|
|
|
|
|
#13 |
|
Banned
![]() ![]() |
Re: Coder's Block Arena - The Game AI Platform
That's perfect! I will be sure to add that to the tutorial. I'm currently busy with school, so I'll get to it later tomorrow. Thanks.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#14 |
|
Professional Programmer
|
Re: Coder's Block Arena - The Game AI Platform
Hey, im thinking of making a very poor attempt making an AI just one quick question how do you send your updated board to the server, is it just via
cb.cmd(newBoard as string) where 1 character has been changed from a '0' to a '1' ? |
|
|
|
|
|
#15 |
|
Banned
![]() ![]() |
Re: Coder's Block Arena - The Game AI Platform
Correct.
![]() And make sure the length of the string remains 9. The very first validation that occurs is checking to see if the response was 9 characters long.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#16 |
|
Professional Programmer
|
Re: Coder's Block Arena - The Game AI Platform
Well i guessed that much, unfortunatly you and i both know im a newcome to these things and this is very much just going to be me making soem random code of the fly and then improving it as i get a better understanding
thank you for that anyway |
|
|
|
|
|
#17 |
|
Banned
![]() ![]() |
Re: Coder's Block Arena - The Game AI Platform
I could see it as a potential problem if you make a string of 20 letters, and then only bother using the first 9 characters. In certain circumstances, you could end up sending all 20 letters through without meaning to. Issues like that can be common depending on what language you are using.
And that sounds like a good idea. Good luck.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#18 |
|
Professional Programmer
|
Re: Coder's Block Arena - The Game AI Platform
Ah that is true, and just so you know im using Python so it could be good fun plus help me develop lots in many areas.
I hope i can get some form of AI up soon just to see how i do |
|
|
|
|
|
#19 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: Coder's Block Arena - The Game AI Platform
I figured out my problem: when ranking moves, I would count permutations of the same board to be different, so the ranking algorithm unfairly over-ranks symmetric boards. Unfortunately, paid work has taken over for now, and while it's a lot less interesting, it does pay.
![]() |
|
|
|
|
|
#20 |
|
Banned
![]() ![]() |
Re: Coder's Block Arena - The Game AI Platform
I can pay too!
![]()
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visualizing How Game Development Would Take Place | Josef_Stalin | Coder's Corner Lounge | 4 | Mar 14th, 2008 11:52 AM |
| Text based game | jayme | Existing Project Development | 25 | Dec 15th, 2005 8:26 AM |
| Text based game | jayme | C++ | 12 | Nov 22nd, 2005 12:03 PM |
| Java programmers, game developers, artists, be ware! RPG game team is recruiting! | atcomputers.us | Paid Job Offers | 7 | Sep 25th, 2005 8:25 PM |
| Programmers Needed! Online Game | troy_eisert | C++ | 2 | Jan 29th, 2005 1:51 PM |