This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2012-04-27 13:54:18

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Sure! In fact, I've set it up so that all you have to do is code a funciton called "moveRed" or "moveBlue" which takes in a board and spits out a board whith your move done, and I handle the rest. I'll even release UI games for each entry so "spectators" can try battling them themselves by clicking on the hexagon!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#52 2012-04-27 14:27:35

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

Sure! In fact, I've set it up so that all you have to do is code a funciton called "moveRed" or "moveBlue" which takes in a board and spits out a board whith your move done, and I handle the rest. I'll even release UI games for each entry so "spectators" can try battling them themselves by clicking on the hexagon!

Cool  smile  how is the board represented? It'd be neat if there were built-in ways for representing the board, placing pieces, etc. (They'd have to copy the board, as opposed to modifying it in-place, so you can use it to investigate multiple states, of course.)

For the sake of elegance it would be nicer to have a single function -- couldn't you just have one "move" function containing the AI code, and then flip the x/y co-ordinates behind the scenes for the other player?

The UI (human versus computer) option is a good idea -- I was going to suggest that. It'd let you test your AI by playing it yourself!

You should have a single html file download containing the basic framework, for everyone to code their AIs in. Ideally, it'd have a <textarea> built-in for coding your function right there on the page  big_smile

Then for the competition, you can use a modified version containing each entry (in a dictionary of functions?) and automate them competing.

For the judging, beautifulness of code should definitely be a factor.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#53 2012-04-28 03:43:23

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Hardmath123 wrote:

Sure! In fact, I've set it up so that all you have to do is code a funciton called "moveRed" or "moveBlue" which takes in a board and spits out a board whith your move done, and I handle the rest. I'll even release UI games for each entry so "spectators" can try battling them themselves by clicking on the hexagon!

Cool  smile  how is the board represented? It'd be neat if there were built-in ways for representing the board, placing pieces, etc. (They'd have to copy the board, as opposed to modifying it in-place, so you can use it to investigate multiple states, of course.)

The board is represented by a 10x10 array (I've posted this bit earlier). The framework will include a copy(array) function, and you will be given a copy of the board to operate on.

For the sake of elegance it would be nicer to have a single function -- couldn't you just have one "move" function containing the AI code, and then flip the x/y co-ordinates behind the scenes for the other player?

Yep! You will have to create a single function which takes in a board and returns the board with your move done. I take care of everything else.

The UI (human versus computer) option is a good idea -- I was going to suggest that. It'd let you test your AI by playing it yourself!

The HTML file will also have a "random" player so that you can test it against a random player, too.

You should have a single html file download containing the basic framework, for everyone to code their AIs in. Ideally, it'd have a <textarea> built-in for coding your function right there on the page  big_smile

It will allow you to import, view, and test code from a .js file.

Then for the competition, you can use a modified version containing each entry (in a dictionary of functions?) and automate them competing.

For the judging, beautifulness of code should definitely be a factor.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#54 2012-04-28 04:42:25

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

blob8108 wrote:

Hardmath123 wrote:

Sure! In fact, I've set it up so that all you have to do is code a funciton called "moveRed" or "moveBlue" which takes in a board and spits out a board whith your move done, and I handle the rest. I'll even release UI games for each entry so "spectators" can try battling them themselves by clicking on the hexagon!

For the sake of elegance it would be nicer to have a single function -- couldn't you just have one "move" function containing the AI code, and then flip the x/y co-ordinates behind the scenes for the other player?

Yep! You will have to create a single function which takes in a board and returns the board with your move done. I take care of everything else.

So there isn't a separate "moveRed" and a "moveBlue"?  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#55 2012-04-28 06:46:57

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Hardmath123 wrote:

blob8108 wrote:


For the sake of elegance it would be nicer to have a single function -- couldn't you just have one "move" function containing the AI code, and then flip the x/y co-ordinates behind the scenes for the other player?

Yep! You will have to create a single function which takes in a board and returns the board with your move done. I take care of everything else.

So there isn't a separate "moveRed" and a "moveBlue"?  tongue

Oh, I see what you meant now. I thought you meant that both entries must be submit in the form of a single function, but now I realized you meant the name should be the same. The problem is, if the name is the same, how do I call a specific one my code? If both functions were named "move", if I call "move", both functions will get called. So, depending on your team (not who should move), you name your function moveRed or moveBlue. My back-end basically does the dirty work like alternating between players and rotating the board for you.  wink


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#56 2012-04-28 16:38:51

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Magnie wrote:

Hardmath123 wrote:

Magnie wrote:

May 1st - 31st is the end of the school year for everyone, so people will be studying for the End-of year tests and stuff. I suggest either doing it sooner, or waiting till summer vacation starts up.  smile

Good point, Magnie. How about June 1 to June 15th?

I think that would work.  smile

Maybe the whole month of June and then judge the projects in July? (Not sure which day would be "perfect" though)

i'm away on july  sad

Offline

 

#57 2012-04-28 17:42:27

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

blob8108 wrote:

Hardmath123 wrote:

Yep! You will have to create a single function which takes in a board and returns the board with your move done. I take care of everything else.

So there isn't a separate "moveRed" and a "moveBlue"?  tongue

Oh, I see what you meant now. I thought you meant that both entries must be submit in the form of a single function, but now I realized you meant the name should be the same. The problem is, if the name is the same, how do I call a specific one my code? If both functions were named "move", if I call "move", both functions will get called. So, depending on your team (not who should move), you name your function moveRed or moveBlue. My back-end basically does the dirty work like alternating between players and rotating the board for you.  wink

Sorry — I think I'm perhaps being slightly unclear  tongue  I was (stupidly) assuming you were still having one entry per person ~ in which case, I would suggest doing it as follows:

Each person writes an entry that consists of a single function. This function would just handle a single case (blue, perhaps) and your code would flip both the colors and the co-ordinates behind the scenes for the other (red) player. Alternatively, if you really need the AI code to handle the cases for each color, it might be nicer to pass it which team it is in as an argument to the function (eg move("red") or move("R") or something like that).

Having just a single function is nicer — it just seems more elegant to me. And then if you ever have more than two teams, you can play any of the AIs against any other one.

Just a thought  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#58 2012-04-29 03:38:47

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Having just a single function, or single name? Obviously, the name can't be the same due to namespace issues. By naming functions differently, I can mix and match within my code. For example, I can write a debugging moveRand function to move to a random hexagon, or a moveHuman function which moves to a user-selected spot.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#59 2012-04-29 04:27:32

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Rescheduled? Excellent! At the moment it looks like I can make that date for a competition!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#60 2012-04-29 04:42:59

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

can we get an object like RedRecord for caching?

Offline

 

#61 2012-04-29 05:06:14

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

sparks wrote:

Rescheduled? Excellent! At the moment it looks like I can make that date for a competition!

Whoo!  big_smile

Players
Roijac
bobbybee
blob8108
rookwood101
sparks
Hardmath123 (if there are an odd number of players)
These will be organized into two teams randomly once there are 9 or 10 applicants. I figured that's the fairest way.

roijac wrote:

can we get an object like RedRecord for caching?

You can always cache as:
1. window.redteamcache=contents;
2. document.body.innerHTML=document.body.innerHTML+"<div id='redteamcache'>contents</div>";
3. a cookie

Use the first option.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#62 2012-04-29 06:07:25

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

Having just a single function, or single name? Obviously, the name can't be the same due to namespace issues. By naming functions differently, I can mix and match within my code. For example, I can write a debugging moveRand function to move to a random hexagon, or a moveHuman function which moves to a user-selected spot.

A single function  tongue

I'm still in favour of doing this individually ~ without trying to be antisocial, I never find team/collab things work too well :S


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#63 2012-04-29 06:20:32

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

True, that's a good point, but some people were hesitant (see the first page) and teams build confidence. Maybe we could allow individual entries too? But then how would I run them against each other? Maybe run all programs against all others and see who has the most wins? So many unanswered questions... Suddenly having a month to figure all this stuff out seems like a godsend!  tongue


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#64 2012-04-29 06:34:23

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

True, that's a good point, but some people were hesitant (see the first page) and teams build confidence. Maybe we could allow individual entries too? But then how would I run them against each other? Maybe run all programs against all others and see who has the most wins?

Yes, do that. All of them against all the others!  big_smile

So many unanswered questions... Suddenly having a month to figure all this stuff out seems like a godsend!  tongue

Absolutely...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#65 2012-04-29 14:24:28

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

Suddenly having a month to figure all this stuff out seems like a godsend!  tongue

now you have time to build the engine so we can test our AIs!  big_smile
where are you going to dev it? sourceforge?

Offline

 

#66 2012-04-30 05:10:38

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

roijac wrote:

Hardmath123 wrote:

Suddenly having a month to figure all this stuff out seems like a godsend!  tongue

now you have time to build the engine so we can test our AIs!  big_smile
where are you going to dev it? sourceforge?

I'll just post the HTML page on Google Docs for you guys to download and use.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#67 2012-04-30 10:00:26

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

UPDATE/POLL: I'm almost done with the layout after struggling with CSS3 for an hour. Here's a question: how do you want to be able to test your code? Here are your choices:
• Save it in an external file and import it into the document (drag into document)
• Copy and paste code into textarea
Also, do you want to be able to code an opponent yourself, or should I just include a few defaults for you to pick from?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#68 2012-04-30 11:29:20

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

UPDATE/POLL: I'm almost done with the layout after struggling with CSS3 for an hour. Here's a question: how do you want to be able to test your code? Here are your choices:
• Save it in an external file and import it into the document (drag into document)
• Copy and paste code into textarea
Also, do you want to be able to code an opponent yourself, or should I just include a few defaults for you to pick from?

maybe something like 'paste here code to be executed before starting the game' where you can define your functions etc., and a 'call this function' box for red player and for blue player, where you provide a 'pick by mouse' function and chooseRandomEmpty function?

Offline

 

#69 2012-04-30 13:23:52

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

UPDATE/POLL: I'm almost done with the layout after struggling with CSS3 for an hour. Here's a question: how do you want to be able to test your code? Here are your choices:
• Save it in an external file and import it into the document (drag into document)
• Copy and paste code into textarea
Also, do you want to be able to code an opponent yourself, or should I just include a few defaults for you to pick from?

It'd be really neat to do both — have a textarea on the page that loads its contents from a string somewhere in the html file when you load the page, but you can then edit in the textarea in the page. That way, you can use your own text editor if you prefer; but you also get the convenience of being able to edit it in the page  smile

Now, if only JS supported triple-quoted strings...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#70 2012-05-02 02:07:54

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Ok, another question: due to absolutely un-thought-out CSS whitespace compatibility in textareas, you have a choice of being able to indent your code, or having code scroll horizontally rather than wrap if the line is too long. Which would you prefer? Should you be able to expand the coding window to the whole screen (it currently resides in a sidebar)?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#71 2012-05-04 04:37:17

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

bump


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#72 2012-05-04 05:55:24

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

doesn't matter for me^^

Offline

 

#73 2012-05-04 05:57:58

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

Ok, another question: due to absolutely un-thought-out CSS whitespace compatibility in textareas, you have a choice of being able to indent your code, or having code scroll horizontally rather than wrap if the line is too long. Which would you prefer? Should you be able to expand the coding window to the whole screen (it currently resides in a sidebar)?

Horizontal scrolling is a pain. Expanding it might be useful; but I imagine one would mainly use a real text editor, to be honest. Indentation is much more important; go with that.  smile

...what precisely was the problem with CSS/textareas?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#74 2012-05-04 06:02:25

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Hardmath123 wrote:

Ok, another question: due to absolutely un-thought-out CSS whitespace compatibility in textareas, you have a choice of being able to indent your code, or having code scroll horizontally rather than wrap if the line is too long. Which would you prefer? Should you be able to expand the coding window to the whole screen (it currently resides in a sidebar)?

Horizontal scrolling is a pain. Expanding it might be useful; but I imagine one would mainly use a real text editor, to be honest. Indentation is much more important; go with that.  smile

...what precisely was the problem with CSS/textareas?

Agreed.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#75 2012-05-04 07:10:46

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Hardmath123 wrote:

Ok, another question: due to absolutely un-thought-out CSS whitespace compatibility in textareas, you have a choice of being able to indent your code, or having code scroll horizontally rather than wrap if the line is too long. Which would you prefer? Should you be able to expand the coding window to the whole screen (it currently resides in a sidebar)?

Horizontal scrolling is a pain. Expanding it might be useful; but I imagine one would mainly use a real text editor, to be honest. Indentation is much more important; go with that.  smile

...what precisely was the problem with CSS/textareas?

Textareas do not support whiteSpace:pre. They only support no-wrap (scroll but don't indent) and pre-wrap (indent but don't scroll). I will go for indentation, as you suggested, since I don't expect you to code there, just tweak numbers.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer