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

#126 2012-05-17 06:53:04

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

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Well, again, you have managed to convince me of something, though I'm not sure exactly what yet... maybe it'll come to me as I write out this reply.

...  big_smile

What you're suggesting is that each player is a "Bob", so to speak. The AI doesn't need to know who it's playing for, it just needs to play for top-to-bottom. The problem I see there is that how does it know which pieces it put down? Unless you always put down a 1 and all pieces are negated each time behind the scenes, but that sounds rather ugly in my opinion.  hmm

Correct — it knows that all its pieces are +1 pieces; as you said the top-to-bottom player is +1. And the placing of the pieces would be handled by the framework, as the function just returns the co-ordinates, I thought.  smile

Hmm.

I guess that is a quite interesting way to look at it then; it's sort of the way each Chess player sees his pawns moving forwards, and sees the opponent's pawns move backwards. So by both flipping the pieces and rotating the board I am actually setting it up such that each player plays White (I'm continuing with the Chess analogy; I still agree with +1 and -1 pieces rather than "R" and "B"). This sounds great — the AI only really needs to implement putting in a piece going vertically. My problem is rotation: should the rotation only rotate clockwise? Or should it alternate clockwise and counter-clockwise? If so, how will a recursive AI know in which direction it should rotate it? If it rotates the wrong way, wouldn't the board sort of flip? Wouldn't that ruin many runtime optimizations? There are just so many problems which crop up as soon as you mention rotation, it really puts me off the idea. Also, as a minor quibble, negating each piece is kinda expensive and still seems ugly to me.


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

Offline

 

#127 2012-05-17 10:49:07

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

blob8108 wrote:

Hardmath123 wrote:

What you're suggesting is that each player is a "Bob", so to speak. The AI doesn't need to know who it's playing for, it just needs to play for top-to-bottom. The problem I see there is that how does it know which pieces it put down? Unless you always put down a 1 and all pieces are negated each time behind the scenes, but that sounds rather ugly in my opinion.  hmm

Correct — it knows that all its pieces are +1 pieces; as you said the top-to-bottom player is +1. And the placing of the pieces would be handled by the framework, as the function just returns the co-ordinates, I thought.  smile

Hmm.

I guess that is a quite interesting way to look at it then; it's sort of the way each Chess player sees his pawns moving forwards, and sees the opponent's pawns move backwards. So by both flipping the pieces and rotating the board I am actually setting it up such that each player plays White (I'm continuing with the Chess analogy; I still agree with +1 and -1 pieces rather than "R" and "B"). This sounds great — the AI only really needs to implement putting in a piece going vertically.

Yup.  smile

My problem is rotation: should the rotation only rotate clockwise? Or should it alternate clockwise and counter-clockwise? If so, how will a recursive AI know in which direction it should rotate it? If it rotates the wrong way, wouldn't the board sort of flip? Wouldn't that ruin many runtime optimizations? There are just so many problems which crop up as soon as you mention rotation, it really puts me off the idea.

Why not rather than rotation, just flip the x/y values? ie., a reflection in y=x. The point [2,3] goes to [3,2], for example.  smile

Also, as a minor quibble, negating each piece is kinda expensive and still seems ugly to me.

...but not that expensive.  tongue  *I* think it's quite a nice way of doing it...


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

Offline

 

#128 2012-05-17 14:41:07

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

Re: AI Strategy Tournament: Rescheduled to June 1st

let's go for R&B, ok?
the algorithm only has to calculate the best place for red pieces, playing top-down. but i think empty should be empty string, not '-' (bool check)

Offline

 

#129 2012-05-18 02:24:09

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

Re: AI Strategy Tournament: Rescheduled to June 1st

roijac wrote:

let's go for R&B, ok?
the algorithm only has to calculate the best place for red pieces, playing top-down. but i think empty should be empty string, not '-' (bool check)

Empty will be 0.


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

Offline

 

#130 2012-05-18 02:26:03

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

Is there a char data type in JS?  You might use 'r', 'b', and 'e' for red, blue, and empty.

Offline

 

#131 2012-05-18 03:02:06

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

Re: AI Strategy Tournament: Rescheduled to June 1st

No. But I like -1, +1, and 0. What have you got against it?  tongue


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

Offline

 

#132 2012-05-18 08:46:23

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

Char takes up less memory than int and short.

Offline

 

#133 2012-05-18 09:04:42

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

Re: AI Strategy Tournament: Rescheduled to June 1st

amcerbu wrote:

Char takes up less memory than int and short.

I didn't think JS had a char type...  hmm  Perhaps a "byte" one, unless I misremember?


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

Offline

 

#134 2012-05-18 09:10:35

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

Re: AI Strategy Tournament: Rescheduled to June 1st

amcerbu wrote:

Char takes up less memory than int and short.

come on, it's not a commodor64 we're programming on

Offline

 

#135 2012-05-18 22:15:19

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

roijac wrote:

amcerbu wrote:

Char takes up less memory than int and short.

come on, it's not a commodor64 we're programming on

Haha, true.  I guess a byte type would work (although you'd have to make sure it wasn't unsigned if you wanted -1, 0, and 1).

Offline

 

#136 2012-05-18 22:21:00

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: AI Strategy Tournament: Rescheduled to June 1st

amcerbu wrote:

roijac wrote:

amcerbu wrote:

Char takes up less memory than int and short.

come on, it's not a commodor64 we're programming on

Haha, true.  I guess a byte type would work (although you'd have to make sure it wasn't unsigned if you wanted -1, 0, and 1).

var...


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#137 2012-05-18 23:34:30

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

Right.  I always forget about implicit variable types...

Offline

 

#138 2012-05-19 00:33:11

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Amcerbu, are you a C coder? Because you really ought to learn JS, it's a great language for this sort of thing (where the algorithm is more important than the actual coding).

P.S. You can get rid of the Xenon banner, I don't think we need it anymore...  tongue

Last edited by Hardmath123 (2012-05-19 00:34:04)


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

Offline

 

#139 2012-05-19 12:48:10

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

@Hardmath123: Yeah, C++ and C#.  C# has "var," but I never use it.  Oh, right, Xenon...

Offline

 

#140 2012-05-20 03:29:27

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

Re: AI Strategy Tournament: Rescheduled to June 1st

UPDATE

After a really cool discussion with Blob and roijac, where he offered lots of suggestions; and a lot of daydreaming at home, here's the new and improved Framework plan:

As before, the framework will be a HexBoard object, where the contents property is a 10x10 array with either -1, 0, or +1. When your AI function is called, it will be given a HexBoard such that your pieces are +1 and the opponents' are -1. Blank cells are 0. Don't worry about how that would work, that has caused a lot of confusion earlier on the topic, and now that I think I have figured it out, I don't need to get lost again. You need to return a X/Y coordinates of where you need to place your piece (Again, thanks to a discussion with Blob. I personally favor returning a brand new HexBoard with the new piece put on, but he somehow managed to convince me otherwise. Ask him why, I seem to have forgotten.) You need to move so that you make a chain connecting top-to-bottom. My back-end will handle everything else.

The framework will be out by June 1, I'm working on it. It will have a flip board function and a function which checks if you can move to a particular cell. It  might have a whoWon function by then, but I'm not sure I'll have the time.

The IDE will be out a few days after the framework because I'm still working on the GUI and haven't even started in the back-end.


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

Offline

 

#141 2012-05-20 03:41:35

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

P.S. You can get rid of the Xenon banner, I don't think we need it anymore...  tongue

lol yeah xenon... i remember when i was a noob and got mad on you of not letting me in so i made graphs in about a week  big_smile

Offline

 

#142 2012-05-20 04:53:34

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

Re: AI Strategy Tournament: Rescheduled to June 1st

roijac wrote:

Hardmath123 wrote:

P.S. You can get rid of the Xenon banner, I don't think we need it anymore...  tongue

lol yeah xenon... i remember when i was a noob and got mad on you of not letting me in so i made graphs in about a week  big_smile

Oh yeah.

Sorry about that, by the way. I was just sore from Chrono Wars.  tongue


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

Offline

 

#143 2012-05-26 05:11:55

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Gah!I feel like crying!  mad

I was done with most of the framework: the flipping, who won (that was lots of fun to code), and a better drawing with real hexagons. I was editing in Xcode, which is awesome if you code a lot. Unfortunately I had another Xcode project (a Mac app for animation) open which due to a silly mistake glitched. The glitch made Xcode crash (that's the first time that happened to me, by the way) and it took all my changes with it. Grr.

I'm sorry guys, but I really don't feel like rewriting all that code, so I'm not doing this framework. Either someone else can take over or we can decide on another competition or we can abandon this entirely, but the framework is not coming back. It's a shame it got lost just like that, I worked hard on it. I literally cut the code to paste it into my "safe copy" when Xcode crashed taking both the pasteboard data and my edits.  sad

I guess I learned something though: never experiment with objective C memory management when another window has precious data.

EDIT: Since we are hopelessly framework-less, but everyone is still (I hope) kind of excited about the tournament, would you guys like to suggest something else we could do instead? Maybe a run-of-the-mill constrained programming challenge (like you have to code something within 500 characters)? I'm really disappointed it didn't work out and I made this huge thread with 6 pages just to blow it by forgetting to deallocate an NSArray.

Last edited by Hardmath123 (2012-05-26 05:23:55)


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

Offline

 

#144 2012-05-26 05:52:52

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Nooo! Don't give up! D: *sadface*  sad

—I'll rewrite the framework!  big_smile  It sounds fun; and you won't have to deal with me constantly telling you how you should do it.  tongue

(Without trying to annoy: this is why you should use version control. It makes my head hurt sometimes, but the reassurance of knowing all the changes are saved there, somewhere, is lovely... you have to have commited the changes, of course.  hmm )

Then again, it seems crazy to me that it isn't saved anywhere. Are you sure it hasn't saved it to a temporary file somewhere, or something?

(Also, you should check out Alfred. As well as being an awesome Spotlight replacement, it includes (nearly) unlimited clipboard history, which is sooo useful.)

Could you send me any code you do still have? — I think you posted a UI a few pages back? I'll have a look...  smile

Last edited by blob8108 (2012-05-26 05:53:42)


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

Offline

 

#145 2012-05-26 06:35:29

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

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Nooo! Don't give up! D: *sadface*  sad

—I'll rewrite the framework!  big_smile  It sounds fun; and you won't have to deal with me constantly telling you how you should do it.  tongue

(Without trying to annoy: this is why you should use version control. It makes my head hurt sometimes, but the reassurance of knowing all the changes are saved there, somewhere, is lovely... you have to have commited the changes, of course.  hmm )

Then again, it seems crazy to me that it isn't saved anywhere. Are you sure it hasn't saved it to a temporary file somewhere, or something?

(Also, you should check out Alfred. As well as being an awesome Spotlight replacement, it includes (nearly) unlimited clipboard history, which is sooo useful.)

Could you send me any code you do still have? — I think you posted a UI a few pages back? I'll have a look...  smile

Zilch. You see, I'm normally hyper-paranoid about these things. If you've seen me write JS, you'll know what I mean: I literally press command-s six times just to be safe. I never delete code, I practically always comment out what I don't need, then do a huge comment-removal session every few days.

This time around, I was editing my JS in Xcode (because it's the best code editor I have). Usually to test code, I wrote myself this cool little app which you can paste JS in and test out. That helps me avoid clearing my cache every time I increment a variable. I just copy and paste in the JS and it runs it for me on a UIWebView. I accidentally command-x'ed instead of command c-ing. So the code was cut out onto my clipboard. Then, before I got to think, Xcode went bonkers and it saved an empty .js file and cleared my clipboard (which I found crazy, but hey; I always found Objective-C mysterious)!

It's awfully nice of you to offer to help rewrite the framework!  smile  But there are a couple of things nagging me: it's May 26th so you have 5 days, and you're gonna be taking part so it doesn't seem to fair for you to be writing the code (not that I doubt you, but if you won...). Also, writing a whole AI is a rather daunting task, and although you're so thrilled, I'm not sure others would like to face this (it's a lot of code if you want a good AI). If you see the first few pages, you'll find a couple of posts saying "If I were better at JS..." or "If I had the time...". This makes me think maybe a lighter-weight competition might be better; looking both at the amount of work both we and the competitors want to do. Some lighter-weight competitions are, as I mentioned earlier, simple constrained coding competitions. I was quite thrilled about this Hex game, but it just seems like too much right now.  sad

But if you insist... ( tongue ) here are the things you need to know to rewrite the framework: I made practically no changes to the UI (save for wording, minor tweaks to colors/measurements to my box models) so just edit what I posted. You'll need to rewrite the HexBoard.js file. Feel free to make your own or just give up, I'm fine either way. Thanks again!  smile


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

Offline

 

#146 2012-05-26 06:46:26

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

Re: AI Strategy Tournament: Rescheduled to June 1st

Hardmath123 wrote:

Zilch. You see, I'm normally hyper-paranoid about these things. If you've seen me write JS, you'll know what I mean: I literally press command-s six times just to be safe. I never delete code, I practically always comment out what I don't need, then do a huge comment-removal session every few days.

This time around, I was editing my JS in Xcode (because it's the best code editor I have). Usually to test code, I wrote myself this cool little app which you can paste JS in and test out. That helps me avoid clearing my cache every time I increment a variable. I just copy and paste in the JS and it runs it for me on a UIWebView. I accidentally command-x'ed instead of command c-ing. So the code was cut out onto my clipboard. Then, before I got to think, Xcode went bonkers and it saved an empty .js file and cleared my clipboard (which I found crazy, but hey; I always found Objective-C mysterious)!

It's awfully nice of you to offer to help rewrite the framework!  smile  But there are a couple of things nagging me: it's May 26th so you have 5 days

That's not an issue.  tongue  I have lots of time over the next few days...

Also, writing a whole AI is a rather daunting task, and although you're so thrilled, I'm not sure others would like to face this (it's a lot of code if you want a good AI). If you see the first few pages, you'll find a couple of posts saying "If I were better at JS..." or "If I had the time...". This makes me think maybe a lighter-weight competition might be better; looking both at the amount of work both we and the competitors want to do. Some lighter-weight competitions are, as I mentioned earlier, simple constrained coding competitions. I was quite thrilled about this Hex game, but it just seems like too much right now.  sad

Darn, you're right. How about a tic-tac-toe/noughts-and-crosses AI?  big_smile  Or something new entirely. And simpler. I dunno...

Last edited by blob8108 (2012-05-26 06:46:51)


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

Offline

 

#147 2012-05-26 06:53:30

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

Re: AI Strategy Tournament: Rescheduled to June 1st

blob8108 wrote:

Hardmath123 wrote:

Zilch. You see, I'm normally hyper-paranoid about these things. If you've seen me write JS, you'll know what I mean: I literally press command-s six times just to be safe. I never delete code, I practically always comment out what I don't need, then do a huge comment-removal session every few days.

This time around, I was editing my JS in Xcode (because it's the best code editor I have). Usually to test code, I wrote myself this cool little app which you can paste JS in and test out. That helps me avoid clearing my cache every time I increment a variable. I just copy and paste in the JS and it runs it for me on a UIWebView. I accidentally command-x'ed instead of command c-ing. So the code was cut out onto my clipboard. Then, before I got to think, Xcode went bonkers and it saved an empty .js file and cleared my clipboard (which I found crazy, but hey; I always found Objective-C mysterious)!

It's awfully nice of you to offer to help rewrite the framework!  smile  But there are a couple of things nagging me: it's May 26th so you have 5 days

That's not an issue.  tongue  I have lots of time over the next few days...

I have the next week free, too.  smile

Also, writing a whole AI is a rather daunting task, and although you're so thrilled, I'm not sure others would like to face this (it's a lot of code if you want a good AI). If you see the first few pages, you'll find a couple of posts saying "If I were better at JS..." or "If I had the time...". This makes me think maybe a lighter-weight competition might be better; looking both at the amount of work both we and the competitors want to do. Some lighter-weight competitions are, as I mentioned earlier, simple constrained coding competitions. I was quite thrilled about this Hex game, but it just seems like too much right now.  sad

Darn, you're right. How about a tic-tac-toe/noughts-and-crosses AI?  big_smile  Or something new entirely. And simpler. I dunno...

Tic-Tac-Toe can (and will) have ties.


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

Offline

 

#148 2012-05-26 11:58:34

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

Re: AI Strategy Tournament: Rescheduled to June 1st

HardMath123 wrote:

blob8108 wrote:

HardMath123 wrote:

Also, writing a whole AI is a rather daunting task, and although you're so thrilled, I'm not sure others would like to face this (it's a lot of code if you want a good AI). If you see the first few pages, you'll find a couple of posts saying "If I were better at JS..." or "If I had the time...". This makes me think maybe a lighter-weight competition might be better; looking both at the amount of work both we and the competitors want to do. Some lighter-weight competitions are, as I mentioned earlier, simple constrained coding competitions. I was quite thrilled about this Hex game, but it just seems like too much right now.  sad

Darn, you're right. How about a tic-tac-toe/noughts-and-crosses AI?  big_smile  Or something new entirely. And simpler. I dunno...

Tic-Tac-Toe can (and will) have ties.

Darn. Hadn't thought of that. Hmm...


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

Offline

 

#149 2012-05-26 12:12:31

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: AI Strategy Tournament: Rescheduled to June 1st

What if we all just take a fresh start and go with something like Reversi/Othello, or Go?  I'm sorry about that, Hardmath.  By the way, does anyone know if you can use Visual Studio to program in JavaScript?

Offline

 

#150 2012-05-26 23:10:06

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

Re: AI Strategy Tournament: Rescheduled to June 1st


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

Offline

 

Board footer