HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavascriptMajor

Is my AI solution to Untrusted Game considered logical or "ethical"?

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
untrustedconsideredgameethicalsolutionlogical

Problem

I am applying to a university to study Computational Linguistics, and as I read, it would be recommended to have a background in Artificial Intelligence.

The Admission board asked me to prepare a portfolio of my works, and I am considering to add this solution to the portfolio.

I have been lazy to develop an AI to bypass the default obstacles, so I added mine to ease the movement of the robot.

```
/*
* robotNav.js
*
* The green key is located in a slightly more
* complicated room. You'll need to get the robot
* past these obstacles.
*/

function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function startLevel(map) {
map.placePlayer(0, map.getHeight() - 1);
var player = map.getPlayer();

map.defineObject('robot', {
'type': 'dynamic',
'symbol': 'R',
'color': 'gray',
'onCollision': function (player, me) {
me.giveItemTo(player, 'greenKey');
},
'behavior': function (me) {
for(i = 2; i<9; i++){
map.placeObject(map.getWidth() - 20, i, 'block');
}
for(i = 2; i<9; i++){
map.placeObject(map.getWidth() - 3, i, 'block');
}
if(me.canMove('down') && !me.canMove('left')){
me.move('down');
}else{
if(me.canMove('right') && !me.canMove('down')){
me.move('right');
}
if(me.canMove('up') && !me.canMove('right')){
if(me.canMove('left')){
me.move('up');
}else{
me.move('down');
}

}
if(!me.canMove('up') && me.canMove('right')){
me.move('right');
}
if(!me.canMove('up') && !me.canMove('right')){
me.move('down');
}
}
}
});

map.defin

Solution

I'm one of the developers of Untrusted (neunenak). Your solution is completely ethical/fair/okay. The whole idea behind the game was that the player could write whatever code they needed to be able to progress to the next level. We do have a lot of code in the game's framework designed to make really easy and uncreative solutions impossible, but that's just to try to force the player to think creatively - if the code you wrote lets you get Dr. Eval to the next level, it's all good. After all, in the real world you don't get more points for writing a complicated AI when a shell script solves your actual problem just as well!

Thanks for playing the game by the way! We're glad you're enjoying it :)

Context

StackExchange Code Review Q#46650, answer score: 23

Revisions (0)

No revisions yet.