Scripting challenges!

Started by ., Jun 10, 2015, 10:13 AM

Previous topic - Next topic

maxorator

#30
Here we go...
[spoiler]Code:
http://pastebin.com/tum2Xgj4
Sprites:
http://imgur.com/a/tcdaz
Filenames for them should be board.png, cellx.png and cello.png.[/spoiler]

This is actually my first script in Squirrel which is not just a few lines of code to test some feature.

Oh, forgot to mention. I was too lazy to mess with relative positioning so it just places them so it looks good on 1920x1080 resolution. Anything too much smaller and the board will probably be somewhere off-screen.

Server currently running this script is at: maxorator.empiro.co.uk:8192

Sebastian

@maxorator
I have tested your Tic-Tac-Toe with @Skirmant, and I enjoyed it alot ! 8)
I like that you don't freeze the player, in this way the TTT being a cool bonus to the normal gameplay.

Unfortunately, after the first game, it started to be buggy...
After I started the second/third game, and played a while, I got an unexpected message: game ended and a player was selected to be the winner.

Also, I have a little suggestion: set the first one who plays to be random.
Was kinda annoying when I was challenging Skirmant and he was always the first one. :D

EK.IceFlake

Quote from: Stormeus on Jun 14, 2015, 04:45 PM
Quote from: NE.CrystalBlue on Jun 14, 2015, 02:58 PM
Quote from: S.L.C on Jun 14, 2015, 02:48 PM
Quote from: NE.CrystalBlue on Jun 14, 2015, 12:31 PMThis requires CreateSprite which is not yet compiled...

What do you mean it's not yet compiled? Have you created a sprite before?

.Func(_SC("CreateSprite"), CreateSprite, 8, _SC("tsiiiini"))
Who said we load the whole module? We just load squirrel... Pure and native support only

... sprites are pure and native to Squirrel. End of discussion.
They are pure and native to VCMP. End of discussion.

Honey

You're damned. End Of discussion.

.

Quote from: NE.CrystalBlue on Jun 15, 2015, 02:57 PMThey are pure and native to VCMP. End of discussion.

Do you even have any idea what native means in this context?
.

Stormeus

Quote from: NE.CrystalBlue on Jun 15, 2015, 02:57 PM
Quote from: Stormeus on Jun 14, 2015, 04:45 PM
Quote from: NE.CrystalBlue on Jun 14, 2015, 02:58 PMWho said we load the whole module? We just load squirrel... Pure and native support only

... sprites are pure and native to Squirrel. End of discussion.
They are pure and native to VCMP. End of discussion.

The purpose of this thread is diverse. It doesn't just entail completing a task using the default Squirrel natives. What SLC has provided is a real-world example of a script that people could adopt in the future, and is challenging scripters to try to construct it, which, IMO, is far more interesting than the abstract challenges that are less relevant to this community (but still do a good job enforcing syntax, which some people still fail to do).

If you have an issue with this thread not being limited to the Squirrel core libraries, you're welcome to leave. You can send any further criticism to my or SLC's PM inbox, but I don't want to hear another word of it in this thread, because we're already venturing off topic.

dEaN

I think first impressions are important when i pick up a Main.nut script and I'm sticking to the script, I'm putting that organic feeling back in the game.
-Since 2012-

EK.IceFlake

I know this is an 18-month bump, but these were quite nice. Do you have any plans on continuing them?

.

Quote from: EK.CrystalBlue on Dec 19, 2016, 11:43 AMI know this is an 18-month bump, but these were quite nice. Do you have any plans on continuing them?

If you find one at a level close to the average vcmp scripter and at the same time to actually be challenging. Then feel free to post it here and I'll put it into the first post.

All I've got so far is "print("hello world!");" :P

Joking aside, I know these were fun, but it's hard to also keep it challenging and simple enough for others to follow. That being said, anyone is free to come up with ideas.

The only rule is that they must not require a lot of coding. The real challenge usually must be to keep the code to a minimum.

Also, I'll have to start individual topics because having one huge topic might get a little messy.
.

DizzasTeR

Okay here is a little challenge if you would like to take.

Challenge: Create a simple table which does not throw an index does not exist error if you try to add any value in an undefined index.

Probably too simple for someone or too hard for someone else but meh keeping it short and less stressful as SLC said above :D

jWeb

[spoiler]
local mm = {
    _get = function(k) { return null; }
    _set = function(k, v) { this.rawset(k, v); }
};

local person = { name = "Bawss" }.setdelegate(mm);

print(person.name);
// Do not exist (yet)
print(person.age);
print(person.city);

// Note the '=' and not '<-'
person.age = 37;
person.city = "Candyland";

print(person.name);
// Now they exist
print(person.age);
print(person.city);
[/spoiler]

EK.IceFlake

[spoiler]t1 <- {a=1, b=2};[/spoiler]
Usage:
[spoiler]try
{
    t1["d"] = t1["c"];
}
catch (e) {}[/spoiler]

Serious usage:
[spoiler]
t1["d"] <- 3;
[/spoiler]

KAKAN

Quote from: EK.CrystalBlue on Dec 21, 2016, 03:27 PM...
There's a difference between your code and doom's challenge. Anyone can insert a new slot( using the '<-' sign ). The question was completely different. Try to understand the question again.
oh no

EK.IceFlake

Quote from: KAKAN on Dec 21, 2016, 04:06 PM
Quote from: EK.CrystalBlue on Dec 21, 2016, 03:27 PM...
There's a difference between your code and doom's challenge. Anyone can insert a new slot( using the '<-' sign ). The question was completely different. Try to understand the question again.
Well... I can't now, since after posting my reply, I read jWebs answer.

Anik

Here's a little challenge from me.

Challenge : Write a program that uses a numeric variable and displays that number of rows of *, with one * in the first row, two in the second row, and so on. For each row, the asterisks are preceded by the number of '.' needed to make all the rows display a total number of characters equal to the number of rows.

A sample run would look like this:
Number of rows :  5
....*
...**
..***
.****
*****
Number of rows :  7
......*
.....**
....***
...****
..*****
.******
*******