[SH15] Elders of Ethos
Onewing

{"name":"609511","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/0\/80e245fe9794e4f0fc7edda64c2084c3.png","w":799,"h":623,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/0\/80e245fe9794e4f0fc7edda64c2084c3"}609511

Source
Resources

Windows Binary
Version 1.1 - speedhack entry (see thread for windows compatibility code modifications)

I'll try to put the binary (Mac app) up later. For now, time to put up the white flag and get a nap in before work. 8-)

EDIT:
=== Some Side Notes===

  • You can press the Up key to cycle through previously input commands

  • I did program the BACKSPACE function...for a Mac keyboard. In windows, this seems to map to the DELETE key. :(

  • There is a crash that I didn't solve in time if you press two arrow keys at the same time (or close to the same time). This is probably the root of other crashes as well.

  • If you are not getting particles in the background, that's concerning. The windows build I just uploaded has them fine.

  • To get the annoying sound, put all your spirits to guidance and proceed until ghosts fill up the game. They make the sound (and flash white as particles in the background)

  • If you get angels, you will start to see them appear as white spirit-particles in the background. This apparently is less frequent than I intended, so you might have to wait a bit.

  • I was going to have all the levels of The Hierarcy of Needs, but I didn't make it in time and cut out the planes I couldn't get to.

  • I was going to have other tribes that were doing the same thing as you and you could see their progress, as well as trade with them or potentially send spirits to slow them down if they were getting ahead of you.

  • My main objective was I wanted the user to feel out where to put spirits based on game feedback, but since I didn't get the rest in, this usually just takes a single play through to figure out. I've got some random events that can trigger at any moment to try to keep it somewhat exciting. :)

GullRaDriel

Well done Onewing !
Can't wait to have all SH binaries ^^

Edit:
Mac Only ?

Onewing

Mac only

For now...yes. I have a PC at home too that I'll try to get a functioning windows build, but gonna have to spend family time tonight and got a big site launch tomorrow evening, so that will have to wait a bit.

GullRaDriel

I'll wait for your build then ^^

devo_au

From the screenshot, looks like you put a lot of effort into the dialog.. Look forward to a windows version when you get around to it..

Edgar Reynaldo

I too am waiting for a windows binary. I tried building it with CB and MinGW but it fails to compile with several warnings and an error about not being able to find the arc4random function. Also, how do you compile .m files? Are those Obj-C?

Bruce Pascoe

Yes, it's completely nonsensical but .m is an Objective-C file. No idea how that will ever be able to be ported, I thought Obj-C was an Apple-only thing.

Onewing

Yeah, I haven't been coding very much past few years and when I do, I'm coding Objective-C for non-allegro projects in xcode. I've completely forgotten the make processes and how to do so.

Our site just launched, so I'm going to eat some dinner and play around with getting a windows build for you guys. Apologies for the delays!

Edgar Reynaldo

Here's the full compile log for the *.cpp files at least :

#SelectExpand
1 2c:\ctwoplus\progcode\allegro5\SpeedHack2015entries\Elders_of_Ethos>srclist.bat 3 4c:\ctwoplus\progcode\allegro5\SpeedHack2015entries\Elders_of_Ethos>mingw32-g++ -Wall -g -Ic:\mingw\LIBS\A5111distro\include -o EldersOfEthos.exe -Lc:\mingw\LIBS\A5111distro\lib *.cpp -lallegro_monolith-debug.dll 5game.cpp:426:2: warning: #warning "Currently skipping AI turns" [-Wcpp] 6 #warning "Currently skipping AI turns" 7 ^ 8In file included from game.cpp:14:0: 9game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 10 Game(Game const&)=delete; 11 ^ 12game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 13 void operator=(Game const&)=delete; 14 ^ 15game.cpp: In member function 'void Game::ProcessCommand()': 16game.cpp:226:24: warning: unused variable 'from' [-Wunused-variable] 17 TRIBEPARAMETER from = this->currentTribe->FindParameterInUstrInRange(this->input, 0, (int)al_ustr_length(this->input)); 18 ^ 19In file included from main.cpp:15:0: 20game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 21 Game(Game const&)=delete; 22 ^ 23game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 24 void operator=(Game const&)=delete; 25 ^ 26main.cpp: In function 'int main(int, char**)': 27main.cpp:25:11: warning: unused variable 'bouncer_x' [-Wunused-variable] 28 float bouncer_x = SCREEN_W / 2.0 - BOUNCER_SIZE / 2.0; 29 ^ 30main.cpp:26:11: warning: unused variable 'bouncer_y' [-Wunused-variable] 31 float bouncer_y = SCREEN_H / 2.0 - BOUNCER_SIZE / 2.0; 32 ^ 33main.cpp:27:11: warning: unused variable 'bouncer_dx' [-Wunused-variable] 34 float bouncer_dx = -4.0, bouncer_dy = 4.0; 35 ^ 36main.cpp:27:30: warning: unused variable 'bouncer_dy' [-Wunused-variable] 37 float bouncer_dx = -4.0, bouncer_dy = 4.0; 38 ^ 39In file included from message.cpp:10:0: 40game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 41 Game(Game const&)=delete; 42 ^ 43game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 44 void operator=(Game const&)=delete; 45 ^ 46In file included from parameter.cpp:11:0: 47game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 48 Game(Game const&)=delete; 49 ^ 50game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 51 void operator=(Game const&)=delete; 52 ^ 53In file included from particle.cpp:13:0: 54game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 55 Game(Game const&)=delete; 56 ^ 57game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 58 void operator=(Game const&)=delete; 59 ^ 60particle.cpp: In constructor 'Particle::Particle(PARTICLESPIRIT)': 61particle.cpp:16:26: error: 'arc4random' was not declared in this scope 62 this->x = arc4random() % SCREEN_W; 63 ^ 64particle.cpp: In member function 'void Particle::Draw()': 65particle.cpp:68:105: error: 'arc4random' was not declared in this scope 66 al_draw_filled_circle(this->x-this->dx*4, this->y-this->dy*4, this->size, al_map_rgb(arc4random() % 20 + 235, arc4random() % 20 + 235, arc4random() % 20 + 235)); 67 ^ 68particleengine.cpp: In member function 'void ParticleEngine::Update(int, int, int)': 69particleengine.cpp:58:102: error: 'arc4random' was not declared in this scope 70 if(this->count < (maxCount + ghosts + angels) && this->count < MAX_PARTICLES && (int)(arc4random() % 100) >= 80) { 71 ^ 72In file included from plane.cpp:10:0: 73game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 74 Game(Game const&)=delete; 75 ^ 76game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 77 void operator=(Game const&)=delete; 78 ^ 79In file included from tribe.h:13:0, 80 from tribe.cpp:12: 81game.h:77:23: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 82 Game(Game const&)=delete; 83 ^ 84game.h:78:33: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11 [enabled by default] 85 void operator=(Game const&)=delete; 86 ^ 87tribe.cpp: In member function 'void Tribe::KillRandomSpirit()': 88tribe.cpp:102:24: error: 'arc4random' was not declared in this scope 89 if((arc4random() % 100 < 20 || breakOut > 100) && this->purity->spirits > 0) { 90 ^ 91tribe.cpp: In member function 'bool Tribe::RandomlyDetermineUnwillingSpirit()': 92tribe.cpp:145:29: error: 'arc4random' was not declared in this scope 93 int choose = arc4random() % 50; 94 ^ 95tribe.cpp: In member function 'void Tribe::UpdateEnergy()': 96tribe.cpp:344:43: error: 'arc4random' was not declared in this scope 97 this->energy->stock -= arc4random() % 10; 98 ^ 99tribe.cpp: In member function 'void Tribe::UpdateMeditation()': 100tribe.cpp:359:47: error: 'arc4random' was not declared in this scope 101 this->meditation->stock -= arc4random() % 10; 102 ^ 103tribe.cpp: In member function 'void Tribe::UpdateGuidance()': 104tribe.cpp:374:45: error: 'arc4random' was not declared in this scope 105 this->guidance->stock -= arc4random() % 10; 106 ^ 107tribe.cpp: In member function 'const char* Tribe::DetermineEvent()': 108tribe.cpp:601:29: error: 'arc4random' was not declared in this scope 109 int choose = arc4random() % range; 110 ^ 111tribe.cpp: In member function 'const char* Tribe::ProcessEvent(EventChance*)': 112tribe.cpp:629:33: error: 'arc4random' was not declared in this scope 113 deaths = arc4random() % 4 + 1; 114 ^ 115 116c:\ctwoplus\progcode\allegro5\SpeedHack2015entries\Elders_of_Ethos>echo off 117 118c:\ctwoplus\progcode\allegro5\SpeedHack2015entries\Elders_of_Ethos>

Onewing

Little progress, but I'm (obviously) going to have to get allegro 5 installed on a windows machine. My PC is not connected to the internet and is running Windows XP. I'll have better luck on my work machine which can dual boot to windows. Got to refresh up on makefiles, so that's good. ;)

Fortunately, the only error I'm seeing from Edgar's post is regarding arc4random, which will just need the right include file most likely. The warnings don't look too concerning.

Mark Oates

I tried compiling on clang but realized I needed to for solve Cocoa and ended up getting distracted on Facebook. #windowsbuild

Onewing

FYI, the two .m files (ViewController.m and main.m) can be deleted and are not required for building. I deleted them (apparently, just the reference) from the project and never touched/saw them again, but accidentally blindly copied them into the source I uploaded.

Mark Oates

So I've created a build. I had to make a few modifications.

modifications

1

I created a replacement for the arc4random() function, just using rand()

#include <time.h>
#include <stdlib.h>

int arc4random()
{
  static bool initialized = false;
  if (!initialized) { srand(time(0)); initialized = true; }

  return rand();
}

2

Added the *.wav files into the resources file (the game would crash without them).

3

Took out the unnecessary .m files.

4

Compiled with -std=gnu++11

5

Added #include "allegro5/allegro_primitives.h" and al_init_primitives_addon() in main.cpp. The game was crashing without the addon being initialized.

6

Had to go hunt down chintzy.ttf on the internet, and put it in the root folder. The font rendering appears different than in your screenshot, I'm not sure what the cause of this is. A result is that the fonts are quite a bit more difficult to read. It's possible that I grabbed an older version of chintzy.ttf that doesn't render as well.
{"name":"609560","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3e9951383b82d2eed478b3d5b645e0f1.png","w":838,"h":662,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/e\/3e9951383b82d2eed478b3d5b645e0f1"}609560

7

I did my make like this

CPP_FILES := $(wildcard *.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))

main.exe: $(OBJ_FILES)
	g++ -o $@ $^ -LE:/allegro-5.1.11-mingw-edgar/lib -lallegro_monolith-debug.dll

obj/%.o: %.cpp
	g++ -std=gnu++11 -c -o $@ $< -IE:/allegro-5.1.11-mingw-edgar/include

conclusion

I haven't played the game through, yet, but I'm assuming it will work to the end. Here's the binary (including the DLLs).

Elders of Ethos - Win32

And here's the revised source and makefile I used:

EoE - revised source

SiegeLord

Got it compiled, and after 1 false start, I managed to win it. That was pretty fun! By the way, you're missing the font (I had to substitute it with a different font without issue).

This is another game that could have used the backspace key ;).

Mark Oates

It's possible that I grabbed an older version of chintzy.ttf that doesn't render as well.

Sure enough ;)

I downloaded the chintzy.ttf font from another website and it was a newer verion. It renders much more nicely now.
{"name":"609561","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/4\/24642286653b61209b05da0a93ac2482.png","w":842,"h":662,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/4\/24642286653b61209b05da0a93ac2482"}609561
I've updated the downloads to include the new font.

Edgar Reynaldo

Oates, your first download link gives a 404 not found error. The second source link works though.

Bruce Pascoe

I'll have to try this now. The screenshots look very 90s-retro (that's a good thing). Like a Wolfenstein 3D-era DOS game. :)

Mark Oates

Oates, your first download link gives a 404 not found error. The second source link works though.

Yikes! Sorry about that. Fixed now. Here's that link again:

Elders of Ethos - Win32

GullRaDriel
SiegeLord said:

This is another game that could have used the backspace key ;).

Yes!

That aside it was a nice polished entry. A bit monotone but it's not crashing and the ambiance is cool :-)

Thanks Mark for the Windows build ;-)

Peter Hull

Mark: On the subject of arc4random, I don't think your implementation is strictly correct

int arc4random()
{
  srand(time(0));
  return rand();
}

Reason (from cppreference)

Quote:

Generally speaking, the pseudo-random number generator should only be seeded once, before any calls to rand(), and the start of the program. It should not be repeatedly seeded, or reseeded every time you wish to generate a new batch of pseudo-random numbers.

I think it actually doesn't matter here because the time between each of the user's entries is going to be random anyway.
Since we're in C++11, might as well use <random>:

#include <random>
#include <stdint.h>

static std::uniform_int_distribution<uint32_t> uni;
static std::default_random_engine engine;

uint32_t arc4random() {
  return uni(engine);
}

Onewing: I've got a Linux makefile if you want.

Cheers,
Pete

Mark Oates

Mark: On the subject of arc4random, I don't think your implementation is strictly correct

You are correct, it isn't. I wasn't in the business of creating the ideal PRNG, just make a random number generator and make it work. My implementation of arc4random() doesn't meet the specification of the original arc4random() (return uint32_t for example), but it does adequately meet the requirements of its use case in the game.

Peter Hull

but it does adequately meet the requirements of its use case in the game.

Well, yes and no. On my Linux it makes the particles go all in a line - and maybe affects the gameplay too, I couldn't tell.
{"name":"609564","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/5\/258550c9e7f0d5b59382a8404ea08a63.jpg","w":1600,"h":1200,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/5\/258550c9e7f0d5b59382a8404ea08a63"}609564

Mark Oates

Interesting. :-/

devo_au

Spent 20 minutes getting 10 from purity to the top. Had some weird shit going on with meditation requiring every follower to rest at one point before stabilising and moving them back to other disciplines. Good speedhack entry, well done.

Peter Hull

Aha! I see the definition of arc4random you gave in your spoiler isn't the same as I found in your source zip file; with the addition of the if (!initialized) bit, yes, I agree, it should work perfectly fine!
Cheers,
pete

Mark Oates

Aha! I see the definition of arc4random you gave in your spoiler isn't the same as I found in your source zip file

caught. 8-)

SiegeLord

I just did sed -i'' 's/arc4random/rand/g' *.cpp.

Elias

I liked this entry, but it crashed several times (Using Mark's Windows binary). Also sometimes energy got depleted within a turn I think.

[edit:] And I didn't seen any particle effects at all...

SiegeLord

Yeah, I had a few crashes too. I learned not to press any unnecessary buttons, and it worked ok. It's a bit mysterious how the energy and meditation levels work: running out of energy was how I lost the first time. My winning strategy was to ignore the calls to promote spirits and instead put as many spirits into guidance until I had 70-80'ish spirits, with about 50 in guidance. Then I promoted all the extra ghosts and had plenty of reserves to just dump into energy if it budged from the max.

This entry really gave me Master Of Orion vibes, where you had to fiddle with the planet's meters. Even though this is a simple entry, I really liked the atmosphere it gave.

bamccaig
SiegeLord said:

I just did sed -i'' 's/arc4random/rand/g' *.cpp.

That shouldn't work. :-/ The shell should remove the '' following the -i and the s/// would be interpreted as a file name. You probably want -i -e instead. >:(

SiegeLord

Sounds like somebody needs to RTFM more often ;).

Mark Oates

#bamslam

bamccaig

I'll concede that it appears to work, but I can't imagine how... Please enlighten me if you know.

Onewing

Thanks, Mark Oates, for getting a build for everybody to play with.

I finally created the official binary based off your findings (updated OP with link). I made this compatible with Visual Studio 2012 using some of your findings + a few other things that Studio complained about.

I did all my work on a repo that I've opened up: Elders of Ethos Repo

I created a tag of the exact code snapshot that I submitted as well as a tag for the official Visual Studio 2012 compliant build. If you review all the commits to the windows_compatibility branch, you can see each step I took to get to that latter tag.

Please try out the new binary and let me know if I'm missing any dll's: Elders of Ethos - Version 1.1

=== And lastly, some side notes===

  • You can press the Up key to cycle through previously input commands

  • I did program the BACKSPACE function...for a Mac keyboard. In windows, this seems to map to the DELETE key. :(

  • There is a crash that I didn't solve in time if you press two arrow keys at the same time (or close to the same time). This is probably the root of other crashes as well.

  • If you are not getting particles in the background, that's concerning. The windows build I just uploaded has them fine.

  • To get the annoying sound, put all your spirits to guidance and proceed until ghosts fill up the game. They make the sound (and flash white as particles in the background)

  • If you get angels, you will start to see them appear as white spirit-particles in the background. This apparently is less frequent than I intended, so you might have to wait a bit.

  • I was going to have all the levels of The Hierarcy of Needs, but I didn't make it in time and cut out the planes I couldn't get to.

  • I was going to have other tribes that were doing the same thing as you and you could see their progress, as well as trade with them or potentially send spirits to slow them down if they were getting ahead of you.

  • My main objective was I wanted the user to feel out where to put spirits based on game feedback, but since I didn't get the rest in, this usually just takes a single play through to figure out. I've got some random events that can trigger at any moment to try to keep it somewhat exciting. :)

Bruce Pascoe

Re: Backspace: I looked at the code and your check for backspace is weird: You handle KEY_CHAR and test for e.keyboard.unichar == 127. What you should do instead is check if e.keyboard.keycode == ALLEGRO_KEY_BACKSPACE. That's a more reliable check and easier to read as well.

Trivia: ASCII 127 is actually the control code for Delete, Backspace is ASCII 8.

Onewing

Thanks, Bruce. I was just printing out the codes to the console of what I typed and 127 is what came back (for a Mac wireless keyboard for where the backspace is). Had I made it over to Windows in time, it would've been a 5 minute "oh duh" moment. 8-)

Bruce Perry

Interesting: the game responds to 'Delete' but not 'Backspace'. Allegro portability issue? (Will post more comments later when I've played it more.)

GullRaDriel

No, it's because delete and backspace are two different keys you have to deal with when building your keyboard management.

Bruce Perry

Very well presented. Good work on that front!

I found the gameplay a little unforgiving the first time I played. It seemed as if my attempts to restore energy and whatever else was running out were too little, too late, and I didn't have enough people to recover. I restarted and did better the next time, and then it was a bit too easy. Once I had to do sequences of at least three instructions (at least one free, then promote and purity) over and over, it became a bit tedious. These seem like things that could be fixed if there is more time to spend on gameplay design, and what you've done is pretty good for a SpeedHack :)

No, it's because delete and backspace are two different keys you have to deal with when building your keyboard management.

I know that, but are you telling me you expect Onewing to have programmed Delete rather than Backspace and not noticed it was strange? It seems more likely to me that whatever works on the Mac behaves differently on the PC, which in my view is a bug in Allegro whereby the key codes aren't matched up correctly across the two platforms. Or that Mac users honestly expect to be pressing different keys, which seems less likely.

Elias

I agree, backspace should send ASCII 8. This is not technically a bug in Allegro as we make no guarantees about which unicode code any key produces. On a German keyboard ALLEGRO_KEY_Y might produce a "z". ALLEGRO_KEY_CLOSEBRACE simply may not exist at all on some keyboards (that was a problem in Mark's entry).

However, I think it would be good to have a small exception there and ensure that on all platforms:

- The Return key produces ASCII 13
- The Tab key produces ASCII 9
- The Backspace key produces ASCII 8
- The Escape key produces ASCII 27
- The Delete key produces ASCII 127

This will make it easier to at least have working text input across platforms and layouts :)

Onewing

Perhaps this will shed some light. The keyboard does in fact say "delete", so it's not surprising that the key maps to that unicode. However, I don't look at what I'm typing and I just mechanically hit where my fingers are programmed to hit backspace. In the Mac app of the game, this works as intended and I never thought twice about it.

{"name":"609572","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca925ff7e8750588c6ee7162e2507dab.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca925ff7e8750588c6ee7162e2507dab"}609572

and what you've done is pretty good for a SpeedHack

Thanks! First time I've actually finished a Speedhack entry. Pretty proud of what I accomplished in a limited weekend for my first allegro 5 project in a Mac environment. :)

Another interesting sidenote: I never could figure out how to get Ogg files to play, so I tried to find a wav file which are obviously expensive size-wise. I ended up finding a song and used a free tool to compress it down further. The free version of the tool cuts the song in half, but this happens to loop perfectly so it was acceptable. I'll take it. 8-)

Bruce Perry

Elias, I've always checked for key codes (not chars) when dealing with special keys like Enter and Backspace - might be worth having a similar guarantee for those too?

I wonder what the Mac currently does if you check for ALLEGRO_KEY_DELETE. Perhaps it should never generate that code, and if you want anything, you have to check for ALLEGRO_KEY_BACKSPACE? And/or ALLEGRO_KEY_DELETE could be deprecated and replaced with ALLEGRO_KEY_DELETE_PC or ALLEGRO_KEY_DELETE_TO_RIGHT?

Thread #615499. Printed from Allegro.cc