Post-Mortem
In February 2014, we rebooted weekend-challenge and created a code-challenge tag.
Here are some stats (as of 2014年03月02日):
- First entry was posted on 2014年02月02日 (14 votes, java)
- Last entry submitted in February was posted on 2014年02月24日 (10 votes, actionscript-3)
- 8 entries were submitted during the month, by 7 users.
- 23 answers were posted - that makes it 2.875 answers per question (std.dev 1.36 which, in my books, means the 2.875 is very representative).
- 4,107 views, or 513.375 per question (std.dev 503.815 which means the data is quite scattered, ranges from 55 to 1,373)
- 11.125 average question score (std.dev 2.642 which means most entries earned the participant a [badge:nice-question]).
Add to that @syb0rg's late entry posted 2014年03月04日 (17 votes, c), with 1,206 views and 4 answers (13-8-3-1 votes), currently the top-voted code-challenge post, and then consider that @SimonAndréForsberg hasn't posted his already publicly playable game as of yet, we're looking at a very, very successful event that is positively affecting the site's overall stats.
April 2014
Let's do this again, shall we? Let's take all of March to decide what the next challenge should be (and to let other late entries get posted).
What should the next code-challenge be?
Note: it's the number of votes that determines the winner - downvotes don't count!
And the winner is...
2-player card fighting game (+15/-1)
Please tag questions/entries with game, code-challenge, as well as any other applicable tag(s).
For people that can't see the vote breakdown:
- Standard-Compliant Container Implementation (+14/-4)
- Puyo-Puyo (+12/0)
- Rock Paper Scissors AI (+7/0)
-
1\$\begingroup\$ Last entry, should be "most recent entry"! As you know, I'm not done yet :) \$\endgroup\$Simon Forsberg– Simon Forsberg2014年03月06日 21:29:37 +00:00Commented Mar 6, 2014 at 21:29
-
5\$\begingroup\$ I like that we are extending the time period to let new challenge ideas come about. It should bring about a few neat ideas that people will want to participate in! \$\endgroup\$syb0rg– syb0rg2014年03月06日 23:41:52 +00:00Commented Mar 6, 2014 at 23:41
-
3\$\begingroup\$ Note: It's the number of upvotes that determines the winner, downvotes don't count! \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年03月12日 13:40:49 +00:00Commented Mar 12, 2014 at 13:40
-
\$\begingroup\$ I don't understand this. What is the challenge? \$\endgroup\$Ilya Gazman– Ilya Gazman2014年04月06日 11:23:40 +00:00Commented Apr 6, 2014 at 11:23
-
1\$\begingroup\$ @Ilya_Gazman to participate, you write an implementation for the (very loosely specified) winning proposal (2 player card fighting game), and submit it for review; then you can follow the code-challenge tag and review other people's implementations. Lots of reviewers hardly ever "ask a question" on the site, this makes an opportunity for it! These posts tend to get high visibility, too :) \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年04月06日 14:35:34 +00:00Commented Apr 6, 2014 at 14:35
-
1\$\begingroup\$ What are votes on questions tagged 'code-challenge' supposed to represent? Is it the same as usual code review questions, or is it a rating of the code posted? \$\endgroup\$Ben Aaronson– Ben Aaronson2014年04月18日 00:43:01 +00:00Commented Apr 18, 2014 at 0:43
-
\$\begingroup\$ @BenAaronson these "challenges" are just for fun, they do tend to get attention, but so do most questions... take it as an idea for a piece of code you could write for the heck of it and then get it peer reviewed on CR (and then to review other people's implementations), a bit like a sport, but one that has nothing to do with golf. So yeah, same as every other question! ;) \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年04月18日 01:10:44 +00:00Commented Apr 18, 2014 at 1:10
-
\$\begingroup\$ @Mat'sMug Okay, sure! I realise it's just for fun of course, was just wondering if it was supposed to be a competition rated by votes or not \$\endgroup\$Ben Aaronson– Ben Aaronson2014年04月18日 01:17:28 +00:00Commented Apr 18, 2014 at 1:17
-
1\$\begingroup\$ Nah, everybody wins! \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年04月18日 01:18:24 +00:00Commented Apr 18, 2014 at 1:18
5 Answers 5
2-player card fighting game
This is not about playing cards as in "Hearts, Diamonds, Clubs and Spades".
This is a game where 2-players (or more if you are really enthusiastic) can play/use cards or spells to do some effect against themselves or their opponent(s).
Minimum requirement:
- Two players
- Players have hit points (call it whatever you want, the effect remains the same)
- At least 10 different playable cards
- When a player has 0 hit points, he's out of the game. Last player standing wins.
You may freely decide how many cards each player starts with on hand and how the logic of your game goes. In case you don't want to or can't come up with something, below is a...
Description of how Castle Wars 2 works:
- Each player has a deck of at least 75 cards.
- Each player always has exactly 8 cards on hand
- Each player has hit points in the form of a castle and a wall
- There are three kinds of resources: Bricks, Weapons, and Crystals
- At the start of each turn you get resources from your resource producers: Builders (produces bricks), Recruit (for Weapons) and Wizards (for Crystals)
- On each of your turns you can either play a card or discard up to three cards
- For each card you play or discard you draw a new card
- You can win by getting your castle up to 100, or your opponent's castle down to 0.
Extending it further...
If you'd like to, you can make your game more advanced by adding cards that remain in game after they have been played. The games Yu-Gi-Oh! and Magic: The Gathering has certain types of cards that can be used while on the "battlefield". They can be used in battle one per turn and some cards has abilities that can be activated.
See these resources for inspiration:
- Castle Wars (playable game, Flash)
- Castle Wars 2 (playable game, Flash)
- Yu-Gi-Oh! Card Guide and Rules
- Magic: The Gathering and Rules
- Hearthstone - wiki
If you are not familiar with Yu-Gi-Oh! or Magic: The Gathering, I suggest making your version of Castle Wars 2.
Take the challenge as far as you would like!
If you have any questions or need some ideas, add a comment or find me in The 2nd Monitor
If you need ideas...
- Two players
- Both players starts with 5 cards on hand, no maximum hand size.
- Players start with 30 health.
- When a player has 0 hit points, he's out of the game. Last player standing wins.
- Each player has
Mages
,Warriors
andKings
as resources. A player starts with 5 warriors and 3 mages and one king. - Only one card can be played each turn, if no card can be played you just have to skip your turn.
- At the beginning of your turn, you draw a card
- At the beginning of your turn, you gain mages and warriors equal to the number of kings that you have.
- 10 playable cards:
Attack
: Costs 3 warriors. Deal 5 damage to your opponentRecruit
: Costs 2 mages. Gain 5 warriors.Panic Kingdom
: Costs 1 king, gain 10 warriors and 10 mages.Pick a King, Any King
: Costs 6 warriors and 6 mages, gain 1 king.Heal Me
: Costs 2 mage, gain 4 health.All-In!
: Costs 10 warriors. Deal 15 damage to your opponentMega Heal
: Costs 5 mages, gain 11 health.Transforming
: Costs 2 warriors, gain 3 mages.Wizards in the city
: Costs 2 warriors, gain 4 mages.Slay Kingdom
: Costs 7 warriors and 7 mages, destroy all enemy warriors and mages.
- How you construct the decks the players use is up to you :) If a player runs out of cards in the deck, the deck is rebuilt from it's ordinary state.
Note that I have no idea how balanced this game would be, these cards and rules are primarily meant as inspiration. Game balance is not important, only code is important.
-
2\$\begingroup\$ Hearthstone could be an example too. (the new game of Blizzard) \$\endgroup\$Marc-Andre– Marc-Andre2014年03月11日 15:44:07 +00:00Commented Mar 11, 2014 at 15:44
-
\$\begingroup\$ You want to implement the crafting mechanics, Class-Compliant decks and the whole story around that?? Good Luck... \$\endgroup\$Vogel612– Vogel6122014年03月12日 14:57:27 +00:00Commented Mar 12, 2014 at 14:57
-
1\$\begingroup\$ @Vogel612 Absolutely not necessary. I'm aware that Magic and Yu-Gi-Oh! are way too big to implement everything. Take the challenge as far as you would like. Just a few of the cards is enough. \$\endgroup\$Simon Forsberg– Simon Forsberg2014年03月12日 15:07:31 +00:00Commented Mar 12, 2014 at 15:07
-
2\$\begingroup\$ @Vogel612 I don't know if you were asking to me or Simon, but I was just mentioning another example of a card game so we have more ideas/examples. You don't need to do an exact duplicate of the game. \$\endgroup\$Marc-Andre– Marc-Andre2014年03月13日 17:16:48 +00:00Commented Mar 13, 2014 at 17:16
Puyo-Puyo
(or Dr.Robotnik's Mean Bean Machine, or Kirby's Avalanche... just give it a fun name)
The object of the game is to defeat the opponent in a battle by filling their grid up to the top with garbage. The Puyos are little creatures with eyes who, in most variations of the game, fall from the top of the screen in a pair. The pair can be moved left and right and rotated. The pair falls until it reaches another puyo or the bottom of the screen.
Chain reactions
When four or more puyos of the same color form together to create a group, they disappear. Individual puyos can connect horizontally or vertically, but not diagonally; the whole group need not be a line, but can be any tetromino (or larger). This is called a Rensa (Chain)
Garbage
Whenever a rensa is achieved, Ojama (Garbage blocks) are sent to the opponent. The bigger the Fluent Rensa is, the more ojamas are sent to the opponent. It is calculated by the overall score of the chain divided by 70 and rounded up to the nearest integer. For example:
Player A forms a group of 4 red puyos as a single chain.
The score card reads "40 x 1" (Simply by the following: (Puyo * 10) x (Puyo - 3) -> (4 * 10) x (4 - 3) -> 40 x 1).
40 is the total score of the chain, so this is divided by 70, to give 0.571 (to 3.s.f)
This value is rounded up to the nearest integer, which is 1. One ojama will fall on the opponent's grid. If more puyos are erased in succession due to a Fluent Rensa, the amount of garbage will keep going up until the chain ends. Ojama puyos are dropped in rows of six, with the extra ojamas distributed in random columns. If more than 30 ojamas are sent, they will be dropped in groups of 30.
Ojama block the opponent's playing field, and can cause them to lose if they reach up to the top of the grid. Ojama are eliminated if puyos are eliminated adjacent to them.
I've (削除) spent (削除ここまで) wasted countless hours of my life playing that game. Now I feel like making my own. Not sure 1 month is enough though.
-
5\$\begingroup\$ An alpha version is probably about 4 hours' work, so a month could be enough time to get a version which is ready to submit for review. \$\endgroup\$Peter Taylor– Peter Taylor2014年03月11日 19:00:17 +00:00Commented Mar 11, 2014 at 19:00
-
\$\begingroup\$ Will this be split screen sharing a single computer, or running on two computers across a network/internet? \$\endgroup\$trichoplax is on Codidact now– trichoplax is on Codidact now2014年03月15日 16:37:52 +00:00Commented Mar 15, 2014 at 16:37
-
1\$\begingroup\$ @githubphagocyte that's all up to you! You can make it an XNA game on Xbox, or a single player demo on Android (tweak the garbage rules as needed), or whatever you want it to be ;) \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年03月15日 16:42:32 +00:00Commented Mar 15, 2014 at 16:42
Standard-Compliant Container Implementation
What?
Pick a language of your choosing and a container of your choosing and implement it, fully conformant to the standard. For example, this could mean picking C++ and implementing std::unordered_map
or std::vector
, or perhaps Java's java.util.ArrayList
or java.util.HashMap
.
Note: a standard container doesn't strictly have to be chosen. It's just fun to implement standard containers :).
Why?
Challenges in the past have focused on relatively complicated design, but I find it refreshing to focus on technical details from time to time. If you've never implemented a standard container before, I can guarantee that you'll learn at least half a dozen things.
A lot of clever thought and language knowledge is required to efficiently and effectively implement a standard compliant container. For example, implementing even one of the relatively simple containers in C++ requires detailed knowledge of memory management, exception safety, const correctness, and templating.
Implementing a container can also help understand why certain design decisions were made. For example, anyone familiar with C++'s std::stack
may have wondered before why pop()
returns void
. Careful thought about how to safely implement a value returning pop
will reveal the answer. (Hint: is there a way to safely implement a returning pop
?)
Testing
In addition to learning about a language, containers are a great opportunity for unit testing. In addition to the implementation, this challenge will require that a test suite be provided that thoroughly tests the container. Optionally, an existing test suite could be used (for example LLVM has very thorough tests for all of the C++ containers).
Details
- Pick a language with a well defined, language-level container library (C++, Java, C#, etc)
- Pick a container -- ones without algorithmic requirements (e.g. balanced trees) will be simpler
- Either carefully read the standard, or just copy the method signatures and read the documentation on each method
- Little by little, add tests and functionality until the container is complete and well tested
-
\$\begingroup\$ So in C# that would be implementing a
Stack<T>
or aQueue<T>
, or aList<T>
, or whatever? \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年03月11日 02:40:40 +00:00Commented Mar 11, 2014 at 2:40 -
\$\begingroup\$ Is it intentional that the Java suggestions are classes rather than interfaces (
java.util.List
,java.util.Map
)? \$\endgroup\$Peter Taylor– Peter Taylor2014年03月11日 12:28:49 +00:00Commented Mar 11, 2014 at 12:28 -
\$\begingroup\$ @Mat'sMug Correct. \$\endgroup\$Corbin– Corbin2014年03月11日 18:35:07 +00:00Commented Mar 11, 2014 at 18:35
-
\$\begingroup\$ @PeterTaylor It was just to be consistent with the C++ suggestions since
ArrayList
andHashMap
are more or less the Java analogues ofstd::vector
andstd::unordered_map
. In an actual implementation, the interface would be implemented. It's just that the implementation might act as one of those concrete classes. (And don't forget that the rules are pretty open -- any container can be implemented) \$\endgroup\$Corbin– Corbin2014年03月11日 18:37:36 +00:00Commented Mar 11, 2014 at 18:37 -
\$\begingroup\$ Should concurrency be a consideration for this challenge? \$\endgroup\$skiwi– skiwi2014年03月15日 20:26:05 +00:00Commented Mar 15, 2014 at 20:26
-
\$\begingroup\$ @PeterTaylor For Java, I think that you want to implement the interface, while mimicking the design of the concrete implementation. So you could be mimicking
ArrayList
, while implementing theList
interface. \$\endgroup\$skiwi– skiwi2014年03月15日 20:30:03 +00:00Commented Mar 15, 2014 at 20:30 -
\$\begingroup\$ @skiwi It could be, but it's not required to meet the criteria of the challenge. In general though, unless someone is already very familiar with non-concurrent containers, I would discourage the concurrent route. Performant concurrent containers can get very tricky very quickly. \$\endgroup\$Corbin– Corbin2014年03月15日 20:36:09 +00:00Commented Mar 15, 2014 at 20:36
-
3\$\begingroup\$ "It's just fun to implement standard containers :)." -- IMHO it has become no longer a huge amount of fun to review standard containers: how many "linked list" implementations do you want to review? \$\endgroup\$ChrisW– ChrisW2014年03月18日 14:31:08 +00:00Commented Mar 18, 2014 at 14:31
-
\$\begingroup\$ @ChrisW I'm afraid I just agree. Lately linked list have become quite a bore. Hopefully though, people would implement more interesting containers, and, by the end of April, maybe the Great Linked List Surge of March will have been forgotten. \$\endgroup\$Corbin– Corbin2014年03月18日 15:21:30 +00:00Commented Mar 18, 2014 at 15:21
My idea is to make a Rock Paper Scissors AI!
Basic idea:
The goal of the challenge is to build a client that supports:
- The ability to enter Rock, Paper or Scissors as human.
- An AI opponent.
- The ability to play a RPS-game against an AI as a human.
Rules of the AI:
- The gesture (Rock, Paper or Scissors) of the current turn of the player (AI's opponent), may not be used for deciding the current turn's gesture of the AI.
Goal of the AI:
- Always win from the player, with a win defined as having more than 50% wins over a set number of games.
Future ideas:
The AI's should battle against other AI's, instead of other humans!
To faciliate this, we need:
- A common communication model for all AI's, possibly system in/out or network communication.
- A server that supports a load of programming languages to run every AI and match them up accordingly.
A ranking will be posted after playing a set number of games, where each AI battles every other AI an equal amount of times.
-
3\$\begingroup\$ An AI is a good idea, but I don't think RPSLS is the best game to do it in. But in case you are interested, check this one out: nytimes.com/interactive/science/… \$\endgroup\$Simon Forsberg– Simon Forsberg2014年03月15日 23:29:00 +00:00Commented Mar 15, 2014 at 23:29
-
\$\begingroup\$ @SimonAndréForsberg An interesting link... I do not see your arguments to not do this challenge though. \$\endgroup\$skiwi– skiwi2014年03月16日 11:41:47 +00:00Commented Mar 16, 2014 at 11:41
-
\$\begingroup\$ Might have to do with @Simon having already implemented AI for his RPSLS solution... \$\endgroup\$Mathieu Guindon– Mathieu Guindon2014年03月16日 14:59:01 +00:00Commented Mar 16, 2014 at 14:59
Late to the game,
but I've set my own challenge, write a Gaussian elimination routine.
More specifically, to solve this challenge : http://www.enigmagroup.org/missions/programming/9/
I would be interested to see how other people would solve this, I already have found many ways to do this wrong.
Good question from @rolfl:
it basically shows a 5 by 5 grid with 5 symbols and symbol values.
So:
- 2 circles and 3 squares is 230
- 2 circles and 2 triangles is 500
- 3 squares and 5 triangles is 1000 etc etc
What are the values of circle, square, triangle etc.
I plan to to have an array of rules that contain the variables and the sum value, the solver will return an array with the value for each variable.
I also should disclose that this question is a terrible implementation of trying to solve this problem. And that my inspiration for this came from RobH's comment.
Finally, the HTML grid looks like this : http://jsbin.com/romiw/9 The code looks terrible, I am mostly messing around at this point ;)
-
2\$\begingroup\$ You must be logged into EnigmaGroup.org to complete the missions. .... what is the challenge? \$\endgroup\$rolfl– rolfl2014年03月21日 15:14:52 +00:00Commented Mar 21, 2014 at 15:14
-
\$\begingroup\$ @rolfl Updated the question \$\endgroup\$konijn– konijn2014年03月21日 17:56:41 +00:00Commented Mar 21, 2014 at 17:56