🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Hello world

Published July 18, 2008
Advertisement
Well, it's official - Epoch has its first fully implemented and operational program!

It's just a boring number guessing game, of course, but it still counts - as it should after the amount of effort that's gone into the VM just to get this tiny bit of code running.

The source that created that game is a bit convoluted because of the VM's structure, but it should be easy enough to follow with some concentration:

std::wstring var_inputstring(L"inputstring");std::wstring var_inputnumber(L"inputnumber");std::wstring var_randomnumber(L"randomnumber");std::wstring var_quitflag(L"quit");std::wstring const_zero(L"zero");std::wstring param_maximum(L"maximum");std::wstring msg_guess(L"Guess my secret number... it's between 1 and 100.");std::wstring msg_toolow(L"Too low! Try again.");std::wstring msg_toohigh(L"Too high! Try again.");std::wstring msg_youwin(L"You're right! You win!");VM::IntegralRValue one(1);VM::Scope scope;scope.AddStringVariable(var_inputstring, EMPTYSTRING);scope.AddIntegralVariable(var_inputnumber, 0);scope.AddIntegralVariable(var_quitflag, 0);scope.AddIntegralVariable(const_zero, 0);VM::Scope parameters;parameters.AddIntegralVariable(param_maximum, 99);scope.AddIntegralVariable(var_randomnumber, VM::TypesManager::CastRValue(*Library::RandomIntegralValue().Invoke(parameters)).GetValue());VM::Operations::AssignExpression(var_randomnumber, new VM::Operations::SumIntegralVariableConstant(var_randomnumber, 1)).Execute(scope);VM::Operations::DebugWriteStaticString(msg_guess).Execute(scope);VM::Block* loopbody = new VM::Block;loopbody->AddOperation(new VM::Operations::AssignExpression(var_inputstring, new VM::Operations::DebugReadStaticString()));loopbody->AddOperation(new VM::Operations::AssignExpression(var_inputnumber, new VM::LexicalCast::StringToIntegral(var_inputstring)));VM::Operation* lessthancondition = new VM::Operations::IsLesser(var_inputnumber, var_randomnumber);VM::Block* lessthanblock = new VM::Block;lessthanblock->AddOperation(new VM::Operations::DebugWriteStaticString(msg_toolow));loopbody->AddOperation(new VM::Operations::If(lessthancondition, lessthanblock, NULL));VM::Operation* greaterthancondition = new VM::Operations::IsGreater(var_inputnumber, var_randomnumber);VM::Block* greaterthanblock = new VM::Block;greaterthanblock->AddOperation(new VM::Operations::DebugWriteStaticString(msg_toohigh));loopbody->AddOperation(new VM::Operations::If(greaterthancondition, greaterthanblock, NULL));VM::Operation* wincondition = new VM::Operations::IsEqual(var_inputnumber, var_randomnumber);VM::Block* winblock = new VM::Block;winblock->AddOperation(new VM::Operations::DebugWriteStaticString(msg_youwin));winblock->AddOperation(new VM::Operations::AssignValue(var_quitflag, one));loopbody->AddOperation(new VM::Operations::If(wincondition, winblock, NULL));VM::Operation* quitcondition = new VM::Operations::IsEqual(var_inputnumber, const_zero);VM::Block* quitblock = new VM::Block;quitblock->AddOperation(new VM::Operations::AssignValue(var_quitflag, one));loopbody->AddOperation(new VM::Operations::If(quitcondition, quitblock, NULL));VM::Operation* loopcondition = new VM::Operations::IsEqual(var_quitflag, const_zero);VM::Operation* loop = new VM::Operations::DoWhileLoop(loopcondition, loopbody);loop->Execute(scope);



So thus far the objectives for Epoch are holding steady:
  • Create a solid VM for experimentation and prototyping

  • Develop applications from day one that use the language directly

  • Make games!


Here it is in all its console-tastic glory:

Epoch guessing game

Not much to look at, to be sure, but still a proud moment for me. I might actually get this crazy project off the ground after all [grin]
Previous Entry Actual Epoch Work! Yayy!
Next Entry Musings on Epoch
0 likes 2 comments

Comments

rip-off
Congratulations! Just remember: no matter how terrible you might screw up the syntax of your new language (when you decide to do that), you can't to any worse than C++ [grin]
July 18, 2008 08:24 PM
Telastyn
Congrats! Though I'm not sure that counts as the language's first fully functional program. Seems like the VM should get the credit there...
July 18, 2008 10:02 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement