Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2008, 9:13 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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()
__________________
Me :: You :: Them

Last edited by Ooble; Mar 24th, 2008 at 9:33 PM. Reason: Removed a couple things that are part of my code only.
Ooble is offline   Reply With Quote
Old Mar 24th, 2008, 9:14 PM   #12
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 24th, 2008, 9:27 PM   #13
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Mar 26th, 2008, 2:51 PM   #14
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 445
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
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' ?
Freaky Chris is offline   Reply With Quote
Old Mar 26th, 2008, 3:08 PM   #15
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Mar 26th, 2008, 3:09 PM   #16
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 445
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
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
Freaky Chris is offline   Reply With Quote
Old Mar 26th, 2008, 3:21 PM   #17
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Mar 26th, 2008, 3:30 PM   #18
Freaky Chris
Professional Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 445
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
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
Freaky Chris is offline   Reply With Quote
Old Mar 27th, 2008, 8:50 AM   #19
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 27th, 2008, 9:10 AM   #20
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC